Skip to content

Commit 8aca27d

Browse files
authored
[ci] Use sccache for Windows CPU build. (#11979)
1 parent 4cf0948 commit 8aca27d

File tree

4 files changed

+99
-88
lines changed

4 files changed

+99
-88
lines changed

.github/workflows/windows.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: XGBoost CI (Windows)
1+
name: Windows
22

33
on: [push, pull_request]
44

@@ -28,7 +28,10 @@ jobs:
2828
- uses: actions/checkout@v6.0.1
2929
with:
3030
submodules: "true"
31-
- run: powershell ops/pipeline/build-win64-gpu.ps1
31+
- uses: dmlc/xgboost-devops/actions/msvc-dev-env@main
32+
- uses: dmlc/xgboost-devops/actions/sccache@main
33+
- run: ops/pipeline/build-win64.ps1 -variant gpu
34+
- run: sccache --show-stats
3235
- name: Stash files
3336
shell: powershell
3437
run: |
@@ -51,7 +54,7 @@ jobs:
5154
submodules: "true"
5255
- uses: dmlc/xgboost-devops/actions/msvc-dev-env@main
5356
- uses: dmlc/xgboost-devops/actions/sccache@main
54-
- run: powershell ops/pipeline/build-win64-cpu.ps1
57+
- run: ops/pipeline/build-win64.ps1 -variant cpu
5558
- run: sccache --show-stats
5659

5760
test-win64-gpu:

ops/pipeline/build-win64-cpu.ps1

Lines changed: 0 additions & 41 deletions
This file was deleted.

ops/pipeline/build-win64-gpu.ps1

Lines changed: 0 additions & 44 deletions
This file was deleted.

ops/pipeline/build-win64.ps1

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
## Build XGBoost on Windows (CPU or GPU)
2+
##
3+
## Usage:
4+
## build-win64.ps1 -variant <cpu|gpu>
5+
##
6+
## Parameters:
7+
## -variant cpu - Build CPU-only version (creates xgboost-cpu wheel)
8+
## -variant gpu - Build with CUDA support (creates default xgboost wheel, includes gtest)
9+
##
10+
## Examples:
11+
## # Build CPU wheel (xgboost-cpu)
12+
## ops/pipeline/build-win64.ps1 -variant cpu
13+
##
14+
## # Build GPU wheel with CUDA
15+
## ops/pipeline/build-win64.ps1 -variant gpu
16+
17+
param(
18+
[Parameter(Mandatory=$true)]
19+
[ValidateSet("cpu", "gpu")]
20+
[string]$variant
21+
)
22+
23+
$ErrorActionPreference = "Stop"
24+
25+
. ops/pipeline/enforce-ci.ps1
26+
27+
# Build common CMake arguments
28+
$cmake_args = @(
29+
"-G", "Ninja",
30+
"-DCMAKE_BUILD_TYPE=Release",
31+
"-DCMAKE_C_COMPILER_LAUNCHER=sccache",
32+
"-DCMAKE_CXX_COMPILER_LAUNCHER=sccache"
33+
)
34+
35+
if ($variant -eq "gpu") {
36+
Write-Host "--- Build libxgboost on Windows with CUDA"
37+
nvcc --version
38+
if ($LASTEXITCODE -ne 0) { throw "Last command failed" }
39+
40+
# Add CUDA-specific flags
41+
$cmake_args += @(
42+
"-DUSE_CUDA=ON",
43+
"-DGOOGLE_TEST=ON",
44+
"-DUSE_DMLC_GTEST=ON"
45+
)
46+
47+
# Only build SM75 for non-release branches (faster CI)
48+
if ($is_release_branch -eq 0) {
49+
$cmake_args += "-DGPU_COMPUTE_VER=75"
50+
}
51+
} else {
52+
Write-Host "--- Build libxgboost on Windows (CPU, minimal)"
53+
}
54+
55+
# Run CMake configure
56+
mkdir build
57+
cd build
58+
& cmake .. @cmake_args
59+
if ($LASTEXITCODE -ne 0) { throw "Last command failed" }
60+
61+
# Build
62+
cmake --build . -v
63+
if ($LASTEXITCODE -ne 0) { throw "Last command failed" }
64+
65+
Write-Host "--- Build binary wheel"
66+
cd ..
67+
68+
# For CPU variant, rename package to xgboost-cpu
69+
if ($variant -eq "cpu") {
70+
conda activate
71+
python ops/script/pypi_variants.py --use-suffix=cpu --require-nccl-dep=na
72+
if ($LASTEXITCODE -ne 0) { throw "Last command failed" }
73+
}
74+
75+
cd python-package
76+
conda activate
77+
& pip wheel --no-deps -v . --wheel-dir dist/
78+
if ($LASTEXITCODE -ne 0) { throw "Last command failed" }
79+
80+
python -m wheel tags --python-tag py3 --abi-tag none `
81+
--platform win_amd64 --remove `
82+
(Get-ChildItem dist/*.whl | Select-Object -Expand FullName)
83+
if ($LASTEXITCODE -ne 0) { throw "Last command failed" }
84+
85+
Write-Host "--- Upload Python wheel"
86+
cd ..
87+
if ($is_release_branch -eq 1) {
88+
python ops/pipeline/manage-artifacts.py upload `
89+
--s3-bucket 'xgboost-nightly-builds' `
90+
--prefix "$Env:BRANCH_NAME/$Env:GITHUB_SHA" --make-public `
91+
(Get-ChildItem python-package/dist/*.whl | Select-Object -Expand FullName)
92+
if ($LASTEXITCODE -ne 0) { throw "Last command failed" }
93+
}

0 commit comments

Comments
 (0)