From cecbe0cf7162bf4a7f7f56c344fd05afc6a8cc24 Mon Sep 17 00:00:00 2001 From: Jiaming Yuan Date: Wed, 20 Feb 2019 06:09:10 +0800 Subject: [PATCH] Fix test_gpu_coordinate. (#3974) * Fix test_gpu_coordinate. * Use `gpu_coord_descent` in test. * Reduce number of running rounds. * Remove nthread. * Use githubusercontent for r-appveyor. * Use githubusercontent in travis r tests. --- appveyor.yml | 2 +- tests/python-gpu/test_gpu_linear.py | 46 ++++++++++++++++++----------- tests/python/test_linear.py | 2 +- tests/travis/run_test.sh | 2 +- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 82c036593..a720b20f5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -49,7 +49,7 @@ install: - ps: | if($env:target -eq 'rmingw' -or $env:target -eq 'rmsvc') { #$ErrorActionPreference = "Stop" - Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "$Env:TEMP\appveyor-tool.ps1" + Invoke-WebRequest https://raw.githubusercontent.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "$Env:TEMP\appveyor-tool.ps1" Import-Module "$Env:TEMP\appveyor-tool.ps1" Bootstrap $DEPS = "c('data.table','magrittr','stringi','ggplot2','DiagrammeR','Ckmeans.1d.dp','vcd','testthat','lintr','knitr','rmarkdown')" diff --git a/tests/python-gpu/test_gpu_linear.py b/tests/python-gpu/test_gpu_linear.py index 755538ed0..47d6f92cf 100644 --- a/tests/python-gpu/test_gpu_linear.py +++ b/tests/python-gpu/test_gpu_linear.py @@ -3,31 +3,41 @@ import pytest import unittest sys.path.append('tests/python/') -import test_linear -import testing as tm +import test_linear # noqa: E402 +import testing as tm # noqa: E402 class TestGPULinear(unittest.TestCase): - datasets = ["Boston", "Digits", "Cancer", "Sparse regression", - "Boston External Memory"] + datasets = ["Boston", "Digits", "Cancer", "Sparse regression"] + common_param = { + 'booster': ['gblinear'], + 'updater': ['gpu_coord_descent'], + 'eta': [0.5], + 'top_k': [10], + 'tolerance': [1e-5], + 'alpha': [.005, .1], + 'lambda': [0.005], + 'coordinate_selection': ['cyclic', 'random', 'greedy']} @pytest.mark.skipif(**tm.no_sklearn()) def test_gpu_coordinate(self): - variable_param = { - 'booster': ['gblinear'], - 'updater': ['coord_descent'], - 'eta': [0.5], - 'top_k': [10], - 'tolerance': [1e-5], - 'nthread': [2], - 'alpha': [.005, .1], - 'lambda': [0.005], - 'coordinate_selection': ['cyclic', 'random', 'greedy'], - 'n_gpus': [-1] - } - for param in test_linear.parameter_combinations(variable_param): + parameters = self.common_param.copy() + parameters['n_gpus'] = [1] + for param in test_linear.parameter_combinations(parameters): results = test_linear.run_suite( - param, 200, self.datasets, scale_features=True) + param, 150, self.datasets, scale_features=True) + test_linear.assert_regression_result(results, 1e-2) + test_linear.assert_classification_result(results) + + @pytest.mark.mgpu + @pytest.mark.skipif(**tm.no_sklearn()) + def test_gpu_coordinate_mgpu(self): + parameters = self.common_param.copy() + parameters['n_gpus'] = [-1] + parameters['gpu_id'] = [1] + for param in test_linear.parameter_combinations(parameters): + results = test_linear.run_suite( + param, 150, self.datasets, scale_features=True) test_linear.assert_regression_result(results, 1e-2) test_linear.assert_classification_result(results) diff --git a/tests/python/test_linear.py b/tests/python/test_linear.py index e3d759910..245239685 100644 --- a/tests/python/test_linear.py +++ b/tests/python/test_linear.py @@ -72,7 +72,7 @@ class TestLinear(unittest.TestCase): 'feature_selector': ['cyclic', 'shuffle', 'greedy', 'thrifty']} for param in parameter_combinations(variable_param): - results = run_suite(param, 200, self.datasets, scale_features=True) + results = run_suite(param, 150, self.datasets, scale_features=True) assert_regression_result(results, 1e-2) assert_classification_result(results) diff --git a/tests/travis/run_test.sh b/tests/travis/run_test.sh index c2efa0e22..ebf39d296 100755 --- a/tests/travis/run_test.sh +++ b/tests/travis/run_test.sh @@ -94,7 +94,7 @@ if [ ${TASK} == "r_test" ]; then sudo ln -s /usr/local/lib/gcc/7 /usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0 fi - curl -OL http://raw.github.com/craigcitro/r-travis/master/scripts/travis-tool.sh + curl -OL https://raw.githubusercontent.com/craigcitro/r-travis/master/scripts/travis-tool.sh chmod 755 ./travis-tool.sh ./travis-tool.sh bootstrap make Rpack