-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[python] Windows wheels that support GPUs via OpenCL #3403
Merged
StrikerRUS
merged 70 commits into
microsoft:master
from
itamarst:windows-gpu-builds-take-3
Dec 19, 2020
Merged
Changes from all commits
Commits
Show all changes
70 commits
Select commit
Hold shift + click to select a range
b1841bd
Add specialized OpenCL/Python package build path
tpboudreau 27dffcb
Refer to upstream OpenCL repository
tpboudreau 2958084
Reset build job count in setup.py
tpboudreau eeb1104
Run test for dual CPU/GPU code in CI
itamarst 1494730
Merge remote-tracking branch 'tpboudreau/build_python_package_library…
itamarst 519a5b9
TEMPORARY: refer to OpenCL fork to ensure Linux CI builds succeed
tpboudreau 239dc49
Try switching to OpenCL 2.0
itamarst d8241b7
Add --opencl-python-pacakge option to wheel
itamarst e21fbc9
Fix some typos.
itamarst 84b6804
Remove intermediate cmake target
tpboudreau ec4b3f4
Restrict OpenCL headers to documented API version
tpboudreau c5263c3
Merge base branch in again
itamarst ed65913
Refresh the environment after installation
itamarst 3b0b910
Try testing with two processes
itamarst 1fc7878
Use command line definition to activate integrated build
tpboudreau bf226e3
Try newer OpenCL runtime
itamarst 3e57182
If we hit OpenCL code path that's good enough
itamarst 8e66b4e
Merge branch 'master' into build_python_package_library
tpboudreau 7747d63
Make tests run correctly
itamarst ed344fb
Correct directory
itamarst af176a6
Flag reference to unofficial repo with FIXME
tpboudreau e0c71cb
Merge branch 'master' into build_python_package_library
tpboudreau 81e6773
Merge branch 'master' into build_python_package_library
tpboudreau 4dac9f5
Merge branch 'master' into build_python_package_library (with conflic…
tpboudreau 180c929
TEMPORARY: update private repo tag for dependency
tpboudreau 3616acc
Merge remote-tracking branch 'tpboudreau/build_python_package_library…
itamarst 2bf13b9
Merge remote-tracking branch 'microsoft/master' into windows-gpu-buil…
itamarst 7ce6028
Further post-merge fixes.
itamarst d9ad5a7
Fix attribute name.
itamarst 69381fd
Reformat with black.
itamarst 67f4cb8
Rewrite config.h before library compilation for Windows wheel
tpboudreau c9b94a6
Merge branch 'master' into windows-gpu-builds-take-3
tpboudreau 25b1d88
Run dual cpu/gpu test once only for Windows bdist CI
tpboudreau 6df3eb6
Avoid C API tests when building gpu library for wheel
tpboudreau 67f2540
TEMPORARY -- add clinfo tool to vm for debugging
tpboudreau 4f04a94
Increase compilation logging
tpboudreau 1c28c46
Rename OpenCL registry parameter after driver installation
tpboudreau 477fd42
Install legacy OpenCL runtime
tpboudreau f6d0dee
...
tpboudreau 5fd426b
Remove config.h change, clinfo installation, latest opencl runtime re…
tpboudreau 4d3a724
Add explicit script exit
tpboudreau 7403314
Merge branch 'master' into windows-gpu-builds-take-3
tpboudreau 97489e3
revert to 18.1 intel driver
tpboudreau cbfec02
Run test_dual.py in two different modes
tpboudreau 78bd0a2
Revert "Run test_dual.py in two different modes"
tpboudreau 9f4c453
Remove unused expected failure test
tpboudreau 011fc9a
Merge from master with conflict resolution
tpboudreau 48f25fa
Install OpenCL in separate powershell script
tpboudreau a38977f
fix setup.py imports
tpboudreau b00d907
activate conda env after session update
tpboudreau 7e8c5bc
separate update functions; exit opencl installation on error
tpboudreau e721d95
nothing; start pipeline
tpboudreau ae74d0e
download from original source
tpboudreau cd50a78
specify tls version for installer download
tpboudreau 41915de
eliminate variable from command
tpboudreau c3031b6
download opencl installer in parts
tpboudreau e7d7d2f
Merge branch 'master' into windows-gpu-builds-take-3
tpboudreau bcaceb8
remove duplicate setup.py command class entry
tpboudreau 9396486
download smaller parts
tpboudreau 88b9c49
remove redundant bdist wheel class
tpboudreau 54a2eb4
Import chocolatey modules and use RefreshEnv
tpboudreau cf52ec0
insert pipeline cache for opencl installer
tpboudreau 817065c
rerun to ensure pipeline cache hit
tpboudreau 7abc286
add comments, test another pipeline cache hit
tpboudreau a119912
remove cache task; download full installer file from new location
tpboudreau 2f13375
try another installer download timing
tpboudreau 761a48c
reinsert pipeline cache
tpboudreau 822bb34
retain cache task; download full file on cache miss
tpboudreau f456487
test cache hit again
tpboudreau 29932a7
remove todo
tpboudreau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
Write-Output "Installing OpenCL CPU platform" | ||
|
||
$cache = "$env:PIPELINE_WORKSPACE\opencl_windows-amd_cpu-v3_0_130_135" | ||
$installer = "AMD-APP-SDKInstaller-v3.0.130.135-GA-windows-F-x64.exe" | ||
|
||
if ($env:OPENCL_INSTALLER_FOUND -ne 'true') { | ||
# Pipeline cache miss; download OpenCL platform installer executable into workspace cache | ||
|
||
Write-Output "Downloading OpenCL platform installer" | ||
Invoke-WebRequest -OutFile "$installer" -Uri "https://github.com/microsoft/LightGBM/releases/download/v2.0.12/$installer" | ||
|
||
Write-Output "Caching OpenCL platform installer" | ||
New-Item $cache -ItemType Directory | Out-Null | ||
Move-Item -Path "$installer" -Destination "$cache\$installer" | Out-Null | ||
|
||
if (Test-Path "$cache\$installer") { | ||
Write-Output "Successfully downloaded OpenCL platform installer" | ||
} else { | ||
Write-Output "Unable to download OpenCL platform installer" | ||
Write-Output "Setting EXIT" | ||
$host.SetShouldExit(-1) | ||
Exit -1 | ||
} | ||
} | ||
|
||
# Install OpenCL platform from installer executable expected in workspace cache | ||
|
||
Write-Output "Running OpenCL installer" | ||
Invoke-Command -ScriptBlock {Start-Process "$cache\$installer" -ArgumentList '/S /V"/quiet /norestart /passive /log opencl.log"' -Wait} | ||
|
||
$property = Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors | ||
if ($property -eq $null) { | ||
Write-Output "Unable to install OpenCL CPU platform" | ||
Write-Output "OpenCL installation log:" | ||
Get-Content "opencl.log" | ||
Write-Output "Setting EXIT" | ||
$host.SetShouldExit(-1) | ||
Exit -1 | ||
} else { | ||
Write-Output "Successfully installed OpenCL CPU platform" | ||
Write-Output "Current OpenCL drivers:" | ||
Write-Output $property | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""Tests for dual GPU+CPU support.""" | ||
|
||
import os | ||
import pytest | ||
|
||
import lightgbm as lgb | ||
import numpy as np | ||
from lightgbm.basic import LightGBMError | ||
|
||
|
||
@pytest.mark.skipif( | ||
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( | ||
os.environ.get("LIGHTGBM_TEST_DUAL_CPU_GPU", None) is None, | ||
reason="Only run if appropriate env variable is set", | ||
) | ||
def test_gpu_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": "gpu"} | ||
gbm = lgb.train(param, train_data, 10, valid_sets=[validation_data]) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a question. What does this syntax mean?
/V" ... opencl.log"
. I mean double quotes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The installer package has a program inside a program: the outer (extractor) program takes the /S and /V arguments. The value of the /V argument is the list of arguments you want passed to the inner (installer) program. You need to quote them to make sure they're all passed together, not interpreted as (unrecognized) arguments to the outer program. Since the ArgumentList is already single-quoted, you have to use double-quotes for the interior quotes.