Unverified Commit 1fb27443 authored by Nikita Titov's avatar Nikita Titov Committed by GitHub
Browse files

[docs][ci] added docs about GPU support out of the box for Windows wheels and...


[docs][ci] added docs about GPU support out of the box for Windows wheels and small refactoring for dual test (#3660)

* added docs about GPU support out of the box for Windows and small refactoring for dual test

* test

* Revert "test"

This reverts commit 45188103c2c9b3773bc62d97fbe865a2e5dd9120.

* fix docs

* fix docs

* hotfix config

* Apply suggestions from code review
Co-authored-by: default avatarTP Boudreau <tpboudreau@gmail.com>
Co-authored-by: default avatarTP Boudreau <tpboudreau@gmail.com>
parent e5554e16
...@@ -26,14 +26,15 @@ install: ...@@ -26,14 +26,15 @@ install:
- set PATH=C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;%PATH% - set PATH=C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;%PATH%
- set PYTHON_VERSION=%CONFIGURATION% - set PYTHON_VERSION=%CONFIGURATION%
- set CONDA_ENV="test-env" - set CONDA_ENV="test-env"
- ps: >- - ps: |
switch ($env:PYTHON_VERSION) { switch ($env:PYTHON_VERSION) {
"3.6" {$env:MINICONDA = "C:\Miniconda36-x64"} "3.6" {$env:MINICONDA = "C:\Miniconda36-x64"}
"3.7" {$env:MINICONDA = "C:\Miniconda37-x64"} "3.7" {$env:MINICONDA = "C:\Miniconda37-x64"}
default {$env:MINICONDA = "C:\Miniconda37-x64"} default {$env:MINICONDA = "C:\Miniconda37-x64"}
} }
$env:PATH="$env:MINICONDA;$env:MINICONDA\Scripts;$env:PATH" $env:PATH = "$env:MINICONDA;$env:MINICONDA\Scripts;$env:PATH"
- ps: $env:LGB_VER = (Get-Content $env:APPVEYOR_BUILD_FOLDER\VERSION.txt).trim() $env:BUILD_SOURCESDIRECTORY = "$env:APPVEYOR_BUILD_FOLDER"
$env:LGB_VER = (Get-Content $env:APPVEYOR_BUILD_FOLDER\VERSION.txt).trim()
build: false build: false
......
Write-Output "Installing OpenCL CPU platform" Write-Output "Installing OpenCL CPU platform"
$cache = "$env:PIPELINE_WORKSPACE\opencl_windows-amd_cpu-v3_0_130_135" $cache = "$env:PIPELINE_WORKSPACE\opencl_windows-amd_cpu-v3_0_130_135"
...@@ -6,7 +5,6 @@ $installer = "AMD-APP-SDKInstaller-v3.0.130.135-GA-windows-F-x64.exe" ...@@ -6,7 +5,6 @@ $installer = "AMD-APP-SDKInstaller-v3.0.130.135-GA-windows-F-x64.exe"
if ($env:OPENCL_INSTALLER_FOUND -ne 'true') { if ($env:OPENCL_INSTALLER_FOUND -ne 'true') {
# Pipeline cache miss; download OpenCL platform installer executable into workspace cache # Pipeline cache miss; download OpenCL platform installer executable into workspace cache
Write-Output "Downloading OpenCL platform installer" Write-Output "Downloading OpenCL platform installer"
Invoke-WebRequest -OutFile "$installer" -Uri "https://github.com/microsoft/LightGBM/releases/download/v2.0.12/$installer" Invoke-WebRequest -OutFile "$installer" -Uri "https://github.com/microsoft/LightGBM/releases/download/v2.0.12/$installer"
...@@ -25,7 +23,6 @@ if ($env:OPENCL_INSTALLER_FOUND -ne 'true') { ...@@ -25,7 +23,6 @@ if ($env:OPENCL_INSTALLER_FOUND -ne 'true') {
} }
# Install OpenCL platform from installer executable expected in workspace cache # Install OpenCL platform from installer executable expected in workspace cache
Write-Output "Running OpenCL installer" Write-Output "Running OpenCL installer"
Invoke-Command -ScriptBlock {Start-Process "$cache\$installer" -ArgumentList '/S /V"/quiet /norestart /passive /log opencl.log"' -Wait} Invoke-Command -ScriptBlock {Start-Process "$cache\$installer" -ArgumentList '/S /V"/quiet /norestart /passive /log opencl.log"' -Wait}
...@@ -42,4 +39,3 @@ if ($property -eq $null) { ...@@ -42,4 +39,3 @@ if ($property -eq $null) {
Write-Output "Current OpenCL drivers:" Write-Output "Current OpenCL drivers:"
Write-Output $property Write-Output $property
} }
...@@ -6,15 +6,9 @@ function Check-Output { ...@@ -6,15 +6,9 @@ function Check-Output {
} }
} }
# Import the Chocolatey profile module so that the RefreshEnv command # unify environment variable for Azure devops and AppVeyor
# invoked below properly updates the current PowerShell session enviroment.
$module = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
Import-Module "$module" ; Check-Output $?
# unify environment variables for Azure devops and AppVeyor
if (Test-Path env:APPVEYOR) { if (Test-Path env:APPVEYOR) {
$env:APPVEYOR = "true" $env:APPVEYOR = "true"
$env:BUILD_SOURCESDIRECTORY = $env:APPVEYOR_BUILD_FOLDER
} }
if ($env:TASK -eq "r-package") { if ($env:TASK -eq "r-package") {
...@@ -28,9 +22,11 @@ conda activate ...@@ -28,9 +22,11 @@ conda activate
conda config --set always_yes yes --set changeps1 no conda config --set always_yes yes --set changeps1 no
conda update -q -y conda conda update -q -y conda
conda create -q -y -n $env:CONDA_ENV python=$env:PYTHON_VERSION joblib matplotlib numpy pandas psutil pytest python-graphviz scikit-learn scipy ; Check-Output $? conda create -q -y -n $env:CONDA_ENV python=$env:PYTHON_VERSION joblib matplotlib numpy pandas psutil pytest python-graphviz scikit-learn scipy ; Check-Output $?
if ($env:TASK -ne "bdist") {
conda activate $env:CONDA_ENV
}
if ($env:TASK -eq "regular") { if ($env:TASK -eq "regular") {
conda activate $env:CONDA_ENV
mkdir $env:BUILD_SOURCESDIRECTORY/build; cd $env:BUILD_SOURCESDIRECTORY/build mkdir $env:BUILD_SOURCESDIRECTORY/build; cd $env:BUILD_SOURCESDIRECTORY/build
cmake -A x64 .. ; cmake --build . --target ALL_BUILD --config Release ; Check-Output $? cmake -A x64 .. ; cmake --build . --target ALL_BUILD --config Release ; Check-Output $?
cd $env:BUILD_SOURCESDIRECTORY/python-package cd $env:BUILD_SOURCESDIRECTORY/python-package
...@@ -39,7 +35,6 @@ if ($env:TASK -eq "regular") { ...@@ -39,7 +35,6 @@ if ($env:TASK -eq "regular") {
cp $env:BUILD_SOURCESDIRECTORY/Release/lightgbm.exe $env:BUILD_ARTIFACTSTAGINGDIRECTORY cp $env:BUILD_SOURCESDIRECTORY/Release/lightgbm.exe $env:BUILD_ARTIFACTSTAGINGDIRECTORY
} }
elseif ($env:TASK -eq "sdist") { elseif ($env:TASK -eq "sdist") {
conda activate $env:CONDA_ENV
cd $env:BUILD_SOURCESDIRECTORY/python-package cd $env:BUILD_SOURCESDIRECTORY/python-package
python setup.py sdist --formats gztar ; Check-Output $? python setup.py sdist --formats gztar ; Check-Output $?
cd dist; pip install @(Get-ChildItem *.gz) -v ; Check-Output $? cd dist; pip install @(Get-ChildItem *.gz) -v ; Check-Output $?
...@@ -54,7 +49,12 @@ elseif ($env:TASK -eq "sdist") { ...@@ -54,7 +49,12 @@ elseif ($env:TASK -eq "sdist") {
cp $env:BUILD_SOURCESDIRECTORY/build/lightgbmlib.jar $env:BUILD_ARTIFACTSTAGINGDIRECTORY/lightgbmlib_win.jar cp $env:BUILD_SOURCESDIRECTORY/build/lightgbmlib.jar $env:BUILD_ARTIFACTSTAGINGDIRECTORY/lightgbmlib_win.jar
} }
elseif ($env:TASK -eq "bdist") { elseif ($env:TASK -eq "bdist") {
# Import the Chocolatey profile module so that the RefreshEnv command
# invoked below properly updates the current PowerShell session enviroment.
$module = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
Import-Module "$module" ; Check-Output $?
RefreshEnv RefreshEnv
Write-Output "Current OpenCL drivers:" Write-Output "Current OpenCL drivers:"
Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors
...@@ -64,7 +64,6 @@ elseif ($env:TASK -eq "bdist") { ...@@ -64,7 +64,6 @@ elseif ($env:TASK -eq "bdist") {
cd dist; pip install --user @(Get-ChildItem *.whl) ; Check-Output $? cd dist; pip install --user @(Get-ChildItem *.whl) ; Check-Output $?
cp @(Get-ChildItem *.whl) $env:BUILD_ARTIFACTSTAGINGDIRECTORY cp @(Get-ChildItem *.whl) $env:BUILD_ARTIFACTSTAGINGDIRECTORY
} elseif (($env:APPVEYOR -eq "true") -and ($env:TASK -eq "python")) { } elseif (($env:APPVEYOR -eq "true") -and ($env:TASK -eq "python")) {
conda activate $env:CONDA_ENV
cd $env:BUILD_SOURCESDIRECTORY\python-package cd $env:BUILD_SOURCESDIRECTORY\python-package
if ($env:COMPILER -eq "MINGW") { if ($env:COMPILER -eq "MINGW") {
python setup.py install --mingw ; Check-Output $? python setup.py install --mingw ; Check-Output $?
...@@ -76,13 +75,14 @@ elseif ($env:TASK -eq "bdist") { ...@@ -76,13 +75,14 @@ elseif ($env:TASK -eq "bdist") {
if (($env:TASK -eq "sdist") -or (($env:APPVEYOR -eq "true") -and ($env:TASK -eq "python"))) { if (($env:TASK -eq "sdist") -or (($env:APPVEYOR -eq "true") -and ($env:TASK -eq "python"))) {
# cannot test C API with "sdist" task # cannot test C API with "sdist" task
$tests = $env:BUILD_SOURCESDIRECTORY + "/tests/python_package_test" $tests = $env:BUILD_SOURCESDIRECTORY + "/tests/python_package_test"
} elseif ($env:TASK -eq "bdist") { } else {
$tests = $env:BUILD_SOURCESDIRECTORY + "/tests" $tests = $env:BUILD_SOURCESDIRECTORY + "/tests"
}
if ($env:TASK -eq "bdist") {
# Make sure we can do both CPU and GPU; see tests/python_package_test/test_dual.py # Make sure we can do both CPU and GPU; see tests/python_package_test/test_dual.py
$env:LIGHTGBM_TEST_DUAL_CPU_GPU = "1" $env:LIGHTGBM_TEST_DUAL_CPU_GPU = "1"
} else {
$tests = $env:BUILD_SOURCESDIRECTORY + "/tests"
} }
pytest $tests ; Check-Output $? pytest $tests ; Check-Output $?
if (($env:TASK -eq "regular") -or (($env:APPVEYOR -eq "true") -and ($env:TASK -eq "python"))) { if (($env:TASK -eq "regular") -or (($env:APPVEYOR -eq "true") -and ($env:TASK -eq "python"))) {
......
...@@ -129,11 +129,11 @@ jobs: ...@@ -129,11 +129,11 @@ jobs:
key: '"opencl.windows" | "amd.cpu" | "v3.0.130.135" | "1"' key: '"opencl.windows" | "amd.cpu" | "v3.0.130.135" | "1"'
path: $(Pipeline.Workspace)/opencl_windows-amd_cpu-v3_0_130_135 path: $(Pipeline.Workspace)/opencl_windows-amd_cpu-v3_0_130_135
cacheHitVar: OPENCL_INSTALLER_FOUND cacheHitVar: OPENCL_INSTALLER_FOUND
condition: eq(variables.TASK, 'bdist') condition: eq(variables['TASK'], 'bdist')
displayName: 'Cache OpenCL' displayName: 'Cache OpenCL Installer'
- script: | - script: |
cmd /c "powershell -ExecutionPolicy Bypass -File %BUILD_SOURCESDIRECTORY%/.ci/install_opencl.ps1" cmd /c "powershell -ExecutionPolicy Bypass -File %BUILD_SOURCESDIRECTORY%/.ci/install_opencl.ps1"
condition: eq(variables.TASK, 'bdist') condition: eq(variables['TASK'], 'bdist')
displayName: 'Install OpenCL' displayName: 'Install OpenCL'
- script: | - script: |
cmd /c "conda init powershell" cmd /c "conda init powershell"
......
...@@ -24,7 +24,7 @@ You can find below a table of correspondence: ...@@ -24,7 +24,7 @@ You can find below a table of correspondence:
Legend: Legend:
\* AMD APP SDK is deprecated. On Windows, OpenCL is included in AMD graphics driver. On Linux, newer generation AMD cards are supported by the `ROCm`_ driver. You can download an archived copy of AMD APP SDK for Linux from `our GitHub repo`_. \* AMD APP SDK is deprecated. On Windows, OpenCL is included in AMD graphics driver. On Linux, newer generation AMD cards are supported by the `ROCm`_ driver. You can download an archived copy of AMD APP SDK from our GitHub repo (`for Linux`_ and `for Windows`_).
-------------- --------------
...@@ -159,7 +159,9 @@ Known issues: ...@@ -159,7 +159,9 @@ Known issues:
.. _ROCm: https://rocmdocs.amd.com/en/latest/ .. _ROCm: https://rocmdocs.amd.com/en/latest/
.. _our GitHub repo: https://github.com/microsoft/LightGBM/releases/download/v2.0.12/AMD-APP-SDKInstaller-v3.0.130.136-GA-linux64.tar.bz2 .. _for Linux: https://github.com/microsoft/LightGBM/releases/download/v2.0.12/AMD-APP-SDKInstaller-v3.0.130.136-GA-linux64.tar.bz2
.. _for Windows: https://github.com/microsoft/LightGBM/releases/download/v2.0.12/AMD-APP-SDKInstaller-v3.0.130.135-GA-windows-F-x64.exe
.. _NVIDIA CUDA Toolkit: https://developer.nvidia.com/cuda-downloads .. _NVIDIA CUDA Toolkit: https://developer.nvidia.com/cuda-downloads
......
...@@ -77,9 +77,9 @@ OpenCL SDK Installation ...@@ -77,9 +77,9 @@ OpenCL SDK Installation
Installing the appropriate OpenCL SDK requires you to download the correct vendor source SDK. Installing the appropriate OpenCL SDK requires you to download the correct vendor source SDK.
You need to know what you are going to use LightGBM! You need to know what you are going to use LightGBM!
- For running on Intel, get `Intel SDK for OpenCL`_ (NOT RECOMMENDED). - For running on Intel, get `Intel SDK for OpenCL`_ (**NOT RECOMMENDED**).
- For running on AMD, get `AMD APP SDK`_ (you may want to replace the ``OpenCL.dll`` from GPU driver package with the one from the SDK, if the one shipped with the driver lacks some functions). - For running on AMD, get AMD APP SDK (downloads `for Linux`_ and `for Windows`_). You may want to replace the ``OpenCL.dll`` from the GPU driver package with the one from the SDK, if the one shipped with the driver lacks some functions.
- For running on NVIDIA, get `CUDA Toolkit`_. - For running on NVIDIA, get `CUDA Toolkit`_.
...@@ -573,7 +573,9 @@ And open an issue in GitHub `here`_ with that log. ...@@ -573,7 +573,9 @@ And open an issue in GitHub `here`_ with that log.
.. _CUDA Toolkit: https://developer.nvidia.com/cuda-downloads .. _CUDA Toolkit: https://developer.nvidia.com/cuda-downloads
.. _AMD APP SDK: https://github.com/fireice-uk/xmr-stak/issues/1511 .. _for Linux: https://github.com/microsoft/LightGBM/releases/download/v2.0.12/AMD-APP-SDKInstaller-v3.0.130.136-GA-linux64.tar.bz2
.. _for Windows: https://github.com/microsoft/LightGBM/releases/download/v2.0.12/AMD-APP-SDKInstaller-v3.0.130.135-GA-windows-F-x64.exe
.. _Khronos official OpenCL headers: https://github.com/KhronosGroup/OpenCL-Headers .. _Khronos official OpenCL headers: https://github.com/KhronosGroup/OpenCL-Headers
......
...@@ -23,6 +23,8 @@ Install from `PyPI <https://pypi.org/project/lightgbm>`_ Using ``pip`` ...@@ -23,6 +23,8 @@ Install from `PyPI <https://pypi.org/project/lightgbm>`_ Using ``pip``
You may need to install `wheel <https://pythonwheels.com>`_ via ``pip install wheel`` first. You may need to install `wheel <https://pythonwheels.com>`_ via ``pip install wheel`` first.
Compiled library that is included in the wheel file supports both **GPU** and **CPU** versions out of the box. This feature is experimental and available only for **Windows** currently. To use **GPU** version you only need to install OpenCL Runtime libraries. For NVIDIA and AMD GPU they are included in the ordinary drivers for your graphics card, so no action is required. If you would like your AMD or Intel CPU to act like a GPU (for testing and debugging) you can install `AMD APP SDK <https://github.com/microsoft/LightGBM/releases/download/v2.0.12/AMD-APP-SDKInstaller-v3.0.130.135-GA-windows-F-x64.exe>`_.
For **Windows** users, `VC runtime <https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads>`_ is needed if **Visual Studio** (2015 or newer) is not installed. For **Windows** users, `VC runtime <https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads>`_ is needed if **Visual Studio** (2015 or newer) is not installed.
For **Linux** users, **glibc** >= 2.14 is required. For **Linux** users, **glibc** >= 2.14 is required.
......
# coding: utf-8
"""Tests for dual GPU+CPU support.""" """Tests for dual GPU+CPU support."""
import os import os
...@@ -5,32 +6,29 @@ import pytest ...@@ -5,32 +6,29 @@ import pytest
import lightgbm as lgb import lightgbm as lgb
import numpy as np import numpy as np
from lightgbm.basic import LightGBMError
from sklearn.metrics import log_loss
@pytest.mark.skipif( from .utils import load_breast_cancer
os.environ.get("LIGHTGBM_TEST_DUAL_CPU_GPU", None) is None,
reason="Only run if appropriate env variable is set",
)
def test_cpu_works():
"""If compiled appropriately, the same installation will support both GPU and CPU."""
data = np.random.rand(500, 10)
label = np.random.randint(2, size=500)
validation_data = train_data = lgb.Dataset(data, label=label)
param = {"verbosity": 2, "num_leaves": 31, "objective": "binary", "device": "cpu"}
gbm = lgb.train(param, train_data, 10, valid_sets=[validation_data])
@pytest.mark.skipif( @pytest.mark.skipif(
os.environ.get("LIGHTGBM_TEST_DUAL_CPU_GPU", None) is None, os.environ.get("LIGHTGBM_TEST_DUAL_CPU_GPU", None) is None,
reason="Only run if appropriate env variable is set", reason="Only run if appropriate env variable is set",
) )
def test_gpu_works(): def test_cpu_and_gpu_work():
"""If compiled appropriately, the same installation will support both GPU and CPU.""" # If compiled appropriately, the same installation will support both GPU and CPU.
data = np.random.rand(500, 10) X, y = load_breast_cancer(return_X_y=True)
label = np.random.randint(2, size=500) data = lgb.Dataset(X, y)
validation_data = train_data = lgb.Dataset(data, label=label)
params_cpu = {"verbosity": -1, "num_leaves": 31, "objective": "binary", "device": "cpu"}
param = {"verbosity": 2, "num_leaves": 31, "objective": "binary", "device": "gpu"} cpu_bst = lgb.train(params_cpu, data, num_boost_round=10)
gbm = lgb.train(param, train_data, 10, valid_sets=[validation_data]) cpu_score = log_loss(y, cpu_bst.predict(X))
params_gpu = params_cpu.copy()
params_gpu["device"] = "gpu"
gpu_bst = lgb.train(params_gpu, data, num_boost_round=10)
gpu_score = log_loss(y, gpu_bst.predict(X))
np.testing.assert_allclose(cpu_score, gpu_score, rtol=1e-4)
assert gpu_score < 0.25
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment