From e36d361674cb1b8fd599da891e1e91a427bb4159 Mon Sep 17 00:00:00 2001 From: Philip Hyunsu Cho Date: Tue, 30 Jul 2024 21:35:54 -0700 Subject: [PATCH] [CI] Create xgboost-cpu on Windows (#10653) --- doc/install.rst | 2 ++ tests/buildkite/build-win64-cpu.ps1 | 51 ++++++++++++++++++++++++++++ tests/buildkite/build-win64-gpu.ps1 | 2 ++ tests/buildkite/cpu_only_pypkg.patch | 29 ++++++++-------- tests/buildkite/pipeline-win64.yml | 5 +++ 5 files changed, 75 insertions(+), 14 deletions(-) create mode 100644 tests/buildkite/build-win64-cpu.ps1 diff --git a/doc/install.rst b/doc/install.rst index 79082a7ed581..7871763e6f25 100644 --- a/doc/install.rst +++ b/doc/install.rst @@ -89,6 +89,8 @@ You may choose to reduce the size of the installed package and save the disk spa The ``xgboost-cpu`` variant will have drastically smaller disk footprint, but does not provide some features, such as the GPU algorithms and federated learning. +Currently, ``xgboost-cpu`` package is provided for x86_64 (amd64) Linux and Windows platforms. + Conda ***** diff --git a/tests/buildkite/build-win64-cpu.ps1 b/tests/buildkite/build-win64-cpu.ps1 new file mode 100644 index 000000000000..f237ba163011 --- /dev/null +++ b/tests/buildkite/build-win64-cpu.ps1 @@ -0,0 +1,51 @@ +## Build Python package xgboost-cpu (minimal install) + +$ErrorActionPreference = "Stop" + +. tests/buildkite/conftest.ps1 + +Write-Host "--- Build libxgboost on Windows (minimal)" + +mkdir build +cd build +cmake .. -G"Visual Studio 17 2022" -A x64 +if ($LASTEXITCODE -ne 0) { throw "Last command failed" } +cmake --build . --config Release -- /m /nodeReuse:false ` + "/consoleloggerparameters:ShowCommandLine;Verbosity=minimal" +if ($LASTEXITCODE -ne 0) { throw "Last command failed" } + +Write-Host "--- Build binary wheel" +cd .. +# Patch to rename pkg to xgboost-cpu +Get-Content tests/buildkite/remove_nccl_dep.patch | patch -p0 +Get-Content tests/buildkite/cpu_only_pypkg.patch | patch -p0 + +cd python-package +conda activate +& pip install --user -v "pip>=23" +& pip --version +& pip wheel --no-deps -v . --wheel-dir dist/ +Get-ChildItem . -Filter dist/*.whl | +Foreach-Object { + & python ../tests/ci_build/rename_whl.py ` + --wheel-path $_.FullName ` + --commit-hash $Env:BUILDKITE_COMMIT ` + --platform-tag win_amd64 + if ($LASTEXITCODE -ne 0) { throw "Last command failed" } +} + +Write-Host "--- Upload Python wheel" +cd .. +Get-ChildItem . -Filter python-package/dist/*.whl | +Foreach-Object { + & buildkite-agent artifact upload python-package/dist/$_ + if ($LASTEXITCODE -ne 0) { throw "Last command failed" } +} +if ( $is_release_branch -eq 1 ) { + Get-ChildItem . -Filter python-package/dist/*.whl | + Foreach-Object { + & aws s3 cp python-package/dist/$_ s3://xgboost-nightly-builds/$Env:BUILDKITE_BRANCH/ ` + --acl public-read --no-progress + if ($LASTEXITCODE -ne 0) { throw "Last command failed" } + } +} diff --git a/tests/buildkite/build-win64-gpu.ps1 b/tests/buildkite/build-win64-gpu.ps1 index 9114d3237751..75ffd3a15c56 100644 --- a/tests/buildkite/build-win64-gpu.ps1 +++ b/tests/buildkite/build-win64-gpu.ps1 @@ -1,3 +1,5 @@ +## Build Python package and gtest with GPU enabled + $ErrorActionPreference = "Stop" . tests/buildkite/conftest.ps1 diff --git a/tests/buildkite/cpu_only_pypkg.patch b/tests/buildkite/cpu_only_pypkg.patch index 765ac5c098d0..62789a25aefe 100644 --- a/tests/buildkite/cpu_only_pypkg.patch +++ b/tests/buildkite/cpu_only_pypkg.patch @@ -1,8 +1,8 @@ diff --git python-package/README.rst python-package/README.rst -index 1fc0bb5a0..f1c68470b 100644 +index 1fc0bb5a0..4475dbb26 100644 --- python-package/README.rst +++ python-package/README.rst -@@ -1,20 +1,15 @@ +@@ -1,20 +1,18 @@ -====================== -XGBoost Python Package -====================== @@ -14,27 +14,28 @@ index 1fc0bb5a0..f1c68470b 100644 -Installation -============ -+The ``xgboost-cpu`` package provides for a minimal installation, with no support for the GPU algorithms -+or federated learning. It is provided to allow XGBoost to be installed in a space-constrained -+environments. - +- -From `PyPI `_ ---------------------------------------------------- -+Note. ``xgboost-cpu`` package is only provided for x86_64 (amd64) Linux and Windows platforms. -+For other platforms, please install ``xgboost`` from https://pypi.org/project/xgboost/. - +- -For a stable version, install using ``pip``:: - - pip install xgboost -- --.. |PyPI version| image:: https://badge.fury.io/py/xgboost.svg -- :target: http://badge.fury.io/py/xgboost -- ++The ``xgboost-cpu`` package provides for a minimal installation, with no support for the GPU algorithms ++or federated learning. It is provided to allow XGBoost to be installed in a space-constrained ++environments. + + .. |PyPI version| image:: https://badge.fury.io/py/xgboost.svg + :target: http://badge.fury.io/py/xgboost + -For building from source, see `build `_. ++Note. ``xgboost-cpu`` package is only provided for x86_64 (amd64) Linux and Windows platforms. ++For other platforms, please install ``xgboost`` from https://pypi.org/project/xgboost/. ++ +Note. ``xgboost-cpu`` does not provide an sdist (source distribution). You may install sdist +from https://pypi.org/project/xgboost/. diff --git python-package/pyproject.toml python-package/pyproject.toml -index 46c1451c2..c5dc908d9 100644 +index 05bbe998c..50e10bf26 100644 --- python-package/pyproject.toml +++ python-package/pyproject.toml @@ -6,7 +6,7 @@ backend-path = ["."] diff --git a/tests/buildkite/pipeline-win64.yml b/tests/buildkite/pipeline-win64.yml index 83a61981e716..2333226bd538 100644 --- a/tests/buildkite/pipeline-win64.yml +++ b/tests/buildkite/pipeline-win64.yml @@ -13,6 +13,11 @@ steps: key: build-win64-gpu agents: queue: windows-cpu + - label: ":windows: Build XGBoost for Windows (minimal)" + command: "tests/buildkite/build-win64-cpu.ps1" + key: build-win64-cpu + agents: + queue: windows-cpu - wait