Skip to content

Commit 98ee95e

Browse files
committed
fix(ci): use ninja for Windows CUDA wheels
1 parent bcf02ce commit 98ee95e

1 file changed

Lines changed: 10 additions & 43 deletions

File tree

‎.github/workflows/build-wheels-cuda.yaml‎

Lines changed: 10 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ jobs:
111111
AVXVER: ${{ matrix.releasetag }}
112112

113113
steps:
114-
- name: Add MSBuild to PATH
114+
- name: Set up MSVC
115115
if: runner.os == 'Windows'
116-
uses: microsoft/setup-msbuild@v2
116+
uses: ilammy/msvc-dev-cmd@v1
117117
with:
118-
vs-version: '[17.0,18.0)'
118+
arch: x64
119119

120120
- uses: actions/checkout@v4
121121
with:
@@ -135,45 +135,6 @@ jobs:
135135
add-pip-as-python-dependency: true
136136
auto-activate-base: false
137137

138-
- name: VS Integration Cache
139-
id: vs-integration-cache
140-
if: runner.os == 'Windows'
141-
uses: actions/cache@v4
142-
with:
143-
path: ./MSBuildExtensions
144-
key: cuda-${{ matrix.cuda }}-vs2022-integration
145-
146-
- name: Get Visual Studio Integration
147-
if: runner.os == 'Windows' && steps.vs-integration-cache.outputs.cache-hit != 'true'
148-
run: |
149-
if ($env:CUDAVER -eq '12.1.1') {$x = '12.1.0'} else {$x = $env:CUDAVER}
150-
$links = (Invoke-RestMethod 'https://raw.githubusercontent.com/Jimver/cuda-toolkit/master/src/links/windows-links.ts').Trim().split().where({$_ -ne ''})
151-
for ($i=$q=0;$i -lt $links.count -and $q -lt 2;$i++) {if ($links[$i] -eq "'$x',") {$q++}}
152-
Invoke-RestMethod $links[$i].Trim("'") -OutFile 'cudainstaller.zip'
153-
& 'C:\Program Files\7-Zip\7z.exe' e cudainstaller.zip -oMSBuildExtensions -r *\MSBuildExtensions\* > $null
154-
Remove-Item 'cudainstaller.zip'
155-
156-
- name: Install Visual Studio Integration
157-
if: runner.os == 'Windows'
158-
run: |
159-
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
160-
$vsInstallPath = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
161-
if (-not $vsInstallPath) {
162-
throw 'Failed to find a Visual Studio installation with VC tools'
163-
}
164-
165-
$source = (gi '.\MSBuildExtensions').FullName + '\*'
166-
$vcMsbuildPath = Join-Path $vsInstallPath 'MSBuild\Microsoft\VC'
167-
$buildCustomizationDirs = Get-ChildItem -Path $vcMsbuildPath -Directory -Filter BuildCustomizations -Recurse
168-
if (-not $buildCustomizationDirs) {
169-
throw "Failed to find Visual Studio BuildCustomizations under $vcMsbuildPath"
170-
}
171-
$buildCustomizationDirs.FullName.ForEach({ Copy-Item $source $_ -Force })
172-
173-
$cupath = 'CUDA_PATH_V' + $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','_')
174-
$cudaRoot = Join-Path $env:CONDA_PREFIX 'Library'
175-
echo "$cupath=$cudaRoot" >> $env:GITHUB_ENV
176-
177138
- name: Install Dependencies
178139
env:
179140
MAMBA_DOWNLOAD_FAILFAST: "0"
@@ -194,7 +155,7 @@ jobs:
194155
if ($LASTEXITCODE -ne 0) {
195156
exit $LASTEXITCODE
196157
}
197-
python -m pip install build wheel
158+
python -m pip install build wheel ninja
198159
199160
- name: Show CUDA diagnostics
200161
run: |
@@ -235,6 +196,9 @@ jobs:
235196
$env:LIBRARY_PATH = "$cudaRoot/lib$pathSeparator$env:CONDA_PREFIX/lib$pathSeparator$env:LIBRARY_PATH"
236197
$env:LD_LIBRARY_PATH = "$cudaRoot/lib$pathSeparator$env:CONDA_PREFIX/lib$pathSeparator$env:LD_LIBRARY_PATH"
237198
} elseif ($IsWindows) {
199+
$ninjaPath = (Get-Command ninja -ErrorAction Stop).Source
200+
$env:CMAKE_GENERATOR = 'Ninja'
201+
$env:CMAKE_MAKE_PROGRAM = $ninjaPath
238202
$env:PATH = "$(Join-Path $cudaRoot 'bin')$pathSeparator$env:PATH"
239203
}
240204
@@ -256,6 +220,9 @@ jobs:
256220
}
257221
$env:CUDACXX = $nvccPath
258222
$env:PATH = "$(Split-Path $nvccPath)$pathSeparator$env:PATH"
223+
if ($IsWindows) {
224+
$env:CMAKE_ARGS = "-DCMAKE_CUDA_COMPILER=$nvccPath -DCMAKE_MAKE_PROGRAM=$env:CMAKE_MAKE_PROGRAM $env:CMAKE_ARGS"
225+
}
259226
$nvccVersion = ((& $nvccPath --version) | Select-String 'release ([0-9]+\.[0-9]+)').Matches[0].Groups[1].Value
260227
if (-not $nvccVersion) {
261228
throw 'Failed to detect the installed CUDA toolkit version'

0 commit comments

Comments
 (0)