Skip to content

Commit a0b242c

Browse files
committed
Prep for bitsandbytes 0.40.1
1 parent b740c35 commit a0b242c

File tree

1 file changed

+301
-0
lines changed

1 file changed

+301
-0
lines changed
Lines changed: 301 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,301 @@
1+
name: Build bitsandbytes Windows Wheel 0.40.0
2+
3+
on: workflow_dispatch
4+
5+
permissions:
6+
contents: write
7+
8+
jobs:
9+
compile_cuda_new:
10+
# Uses Windows-2022 and Cuda Toolkit >= 11.6 with full version spec as string: "11.6.2"
11+
# Uses 11.6 as CPU build target, version must be included to build CPU binaries
12+
# See https://github.com/Jimver/cuda-toolkit/blob/master/src/links/windows-links.ts for supported versions
13+
name: Compile Cuda Code 2022
14+
runs-on: windows-2022
15+
strategy:
16+
matrix:
17+
cuda: ["11.6.2", "11.7.1", "11.8.0", "12.0.1", "12.1.0", "12.2.0"]
18+
cublas: ["0", "1"]
19+
defaults:
20+
run:
21+
shell: pwsh
22+
env:
23+
CUDAVER: ${{ matrix.cuda }}
24+
25+
steps:
26+
- name: Get Visual Studio Integration
27+
if: matrix.cuda != '12.2.0'
28+
uses: Jimver/cuda-toolkit@v0.2.10
29+
with:
30+
cuda: ${{ matrix.cuda }}
31+
method: 'network'
32+
sub-packages: '["visual_studio_integration"]'
33+
34+
- name: Get Visual Studio Integration 12.2
35+
if: matrix.cuda == '12.2.0'
36+
run: |
37+
Invoke-RestMethod 'https://developer.download.nvidia.com/compute/cuda/12.2.0/network_installers/cuda_12.2.0_windows_network.exe' -OutFile "$env:RUNNER_TEMP\cudainstaller.exe"
38+
Start-Process "$env:RUNNER_TEMP\cudainstaller.exe" -wait -ArgumentList '-s visual_studio_integration_12.2'
39+
echo 'CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2' >> $env:GITHUB_ENV
40+
41+
- name: Install Visual Studio Integration
42+
run: |
43+
$x = (dir $env:CUDA_PATH -dir -recurse -depth 2).where({$_.name -eq 'visual_studio_integration'}).fullname
44+
$y = (dir $x -dir -recurse).where({$_.name -eq 'MSBuildExtensions'}).fullname + '\*'
45+
(gi 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\*\BuildCustomizations').fullname.foreach({cp $y $_})
46+
47+
- uses: actions/checkout@v3
48+
with:
49+
repository: 'jllllll/bitsandbytes'
50+
ref: 'cmake_windows_0.40.0'
51+
52+
- uses: actions/setup-python@v4
53+
with:
54+
python-version: "3.10"
55+
56+
- name: Setup Mamba
57+
uses: conda-incubator/setup-miniconda@v2.2.0
58+
with:
59+
activate-environment: "build"
60+
python-version: "3.10"
61+
miniforge-variant: Mambaforge
62+
miniforge-version: latest
63+
use-mamba: true
64+
add-pip-as-python-dependency: true
65+
auto-activate-base: false
66+
67+
- name: Install Dependencies
68+
run: |
69+
$cudaVersion = $env:CUDAVER
70+
$cudaChannels = ''
71+
$cudaNum = [int]$cudaVersion.substring($cudaVersion.LastIndexOf('.')+1)
72+
while ($cudaNum -ge 0) { $cudaChannels += '-c nvidia/label/cuda-' + $cudaVersion.Remove($cudaVersion.LastIndexOf('.')+1) + $cudaNum + ' '; $cudaNum-- }
73+
$cudaChannels = $cudaChannels.TrimEnd() + ' -c conda-forge -c defaults'
74+
mamba install -y 'cmake' 'ninja' 'cuda' $cudaChannels.Split()
75+
76+
- name: Compile Cuda Code
77+
if: matrix.cublas == '0'
78+
run: |
79+
$env:CUDA_PATH = $env:CONDA_PREFIX
80+
$cudaVersion = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.'))
81+
$x = 'CUDA_PATH_V' + $cudaVersion.Replace('.','_')
82+
[Environment]::SetEnvironmentVariable($x, $env:CUDA_PATH)
83+
if (!(Test-Path '.\BuildArtifacts\')) { mkdir '.\BuildArtifacts' }
84+
cmake -S . -B "./build_$cudaVersion_0" -G "Visual Studio 17 2022" -T "cuda=$cudaVersion" -D "NO_CUBLASLT=0" -D "CUDA_TARGET_ARCH_FEATURE_LEVEL=$cudaVersion" -D "CIBUILD=1"
85+
cmake --build "./build_$cudaVersion_0" --target libbitsandbytes_cuda --config Release
86+
if ($cudaVersion -eq '11.6') { cmake --build "./build_$cudaVersion_0" --target libbitsandbytes_cpu --config Release }
87+
88+
- name: Compile Cuda Code nocublaslt
89+
if: matrix.cublas == '1'
90+
run: |
91+
$env:CUDA_PATH = $env:CONDA_PREFIX
92+
$cudaVersion = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.'))
93+
$x = 'CUDA_PATH_V' + $cudaVersion.Replace('.','_')
94+
[Environment]::SetEnvironmentVariable($x, $env:CUDA_PATH)
95+
if (!(Test-Path '.\BuildArtifacts\')) { mkdir '.\BuildArtifacts' }
96+
cmake -S . -B "./build_$cudaVersion_1" -G "Visual Studio 17 2022" -T "cuda=$cudaVersion" -D "NO_CUBLASLT=1" -D "CUDA_TARGET_ARCH_FEATURE_LEVEL=$cudaVersion" -D "CIBUILD=1"
97+
cmake --build "./build_$cudaVersion_1" --target libbitsandbytes_cuda --config Release
98+
99+
- uses: actions/upload-artifact@v3
100+
with:
101+
name: compiled-binaries
102+
path: ./BuildArtifacts/*
103+
104+
compile_cuda_old_conda:
105+
# Uses Windows-2019 and Cuda Toolkit 11.3 - 11.5 with full version spec as string: "11.5.2"
106+
# See https://github.com/Jimver/cuda-toolkit/blob/master/src/links/windows-links.ts for supported versions
107+
name: Compile Cuda Code 2019-Conda
108+
runs-on: windows-2019
109+
strategy:
110+
matrix:
111+
cuda: ["11.3.1", "11.4.4", "11.5.2"]
112+
cublas: ["0", "1"]
113+
defaults:
114+
run:
115+
shell: pwsh
116+
env:
117+
CUDAVER: ${{ matrix.cuda }}
118+
119+
steps:
120+
- name: Get Visual Studio Integration
121+
uses: Jimver/cuda-toolkit@v0.2.10
122+
with:
123+
cuda: ${{ matrix.cuda }}
124+
method: 'network'
125+
sub-packages: '["visual_studio_integration"]'
126+
127+
- name: Install Visual Studio Integration
128+
run: |
129+
$x = (dir $env:CUDA_PATH -dir -recurse -depth 2).where({$_.name -eq 'visual_studio_integration'}).fullname
130+
$y = (dir $x -dir -recurse).where({$_.name -eq 'MSBuildExtensions'}).fullname + '\*'
131+
(gi 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\*\BuildCustomizations').fullname.foreach({cp $y $_})
132+
133+
- uses: actions/checkout@v3
134+
with:
135+
repository: 'jllllll/bitsandbytes'
136+
ref: 'cmake_windows_0.40.0'
137+
138+
- uses: actions/setup-python@v4
139+
with:
140+
python-version: "3.10"
141+
142+
- name: Setup Mamba
143+
uses: conda-incubator/setup-miniconda@v2.2.0
144+
with:
145+
activate-environment: "build"
146+
python-version: "3.10"
147+
miniforge-variant: Mambaforge
148+
miniforge-version: latest
149+
use-mamba: true
150+
add-pip-as-python-dependency: true
151+
auto-activate-base: false
152+
153+
- name: Install Dependencies
154+
run: |
155+
$cudaVersion = $env:CUDAVER
156+
$cudaChannels = ''
157+
$cudaNum = [int]$cudaVersion.substring($cudaVersion.LastIndexOf('.')+1)
158+
while ($cudaNum -ge 0) { $cudaChannels += '-c nvidia/label/cuda-' + $cudaVersion.Remove($cudaVersion.LastIndexOf('.')+1) + $cudaNum + ' '; $cudaNum-- }
159+
$cudaChannels = $cudaChannels.TrimEnd() + ' -c conda-forge -c defaults'
160+
mamba install -y 'cmake' 'ninja' 'cuda' $cudaChannels.Split()
161+
162+
- name: Compile Cuda Code
163+
if: matrix.cublas == '0'
164+
run: |
165+
$env:CUDA_PATH = $env:CONDA_PREFIX
166+
$cudaVersion = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.'))
167+
$x = 'CUDA_PATH_V' + $cudaVersion.Replace('.','_')
168+
[Environment]::SetEnvironmentVariable($x, $env:CUDA_PATH)
169+
if (!(Test-Path '.\BuildArtifacts\')) { mkdir '.\BuildArtifacts' }
170+
cmake -S . -B "./build_$cudaVersion_0" -G "Visual Studio 16 2019" -T "cuda=$cudaVersion" -D "NO_CUBLASLT=0" -D "CUDA_TARGET_ARCH_FEATURE_LEVEL=$cudaVersion" -D "CIBUILD=1"
171+
cmake --build "./build_$cudaVersion_0" --target libbitsandbytes_cuda --config Release
172+
173+
- name: Compile Cuda Code nocublaslt
174+
if: matrix.cublas == '1'
175+
run: |
176+
$env:CUDA_PATH = $env:CONDA_PREFIX
177+
$cudaVersion = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.'))
178+
$x = 'CUDA_PATH_V' + $cudaVersion.Replace('.','_')
179+
[Environment]::SetEnvironmentVariable($x, $env:CUDA_PATH)
180+
if (!(Test-Path '.\BuildArtifacts\')) { mkdir '.\BuildArtifacts' }
181+
cmake -S . -B "./build_$cudaVersion_1" -G "Visual Studio 16 2019" -T "cuda=$cudaVersion" -D "NO_CUBLASLT=1" -D "CUDA_TARGET_ARCH_FEATURE_LEVEL=$cudaVersion" -D "CIBUILD=1"
182+
cmake --build "./build_$cudaVersion_1" --target libbitsandbytes_cuda --config Release
183+
184+
- uses: actions/upload-artifact@v3
185+
with:
186+
name: compiled-binaries
187+
path: ./BuildArtifacts/*
188+
189+
compile_cuda_old:
190+
# Uses Windows-2019 and Cuda Toolkit <= 11.2 with full version spec as string: "11.2.2"
191+
# These versions of the Toolkit are not available through conda and must be installed through Jimver/cuda-toolkit (slower for newer versions, but these are fine)
192+
# See https://github.com/Jimver/cuda-toolkit/blob/master/src/links/windows-links.ts for supported versions
193+
name: Compile Cuda Code 2019
194+
runs-on: windows-2019
195+
strategy:
196+
matrix:
197+
cuda: ["11.1.1", "11.2.2"]
198+
cublas: ["0", "1"]
199+
defaults:
200+
run:
201+
shell: pwsh
202+
env:
203+
CUDAVER: ${{ matrix.cuda }}
204+
205+
steps:
206+
- name: Install Cuda Toolkit
207+
uses: Jimver/cuda-toolkit@v0.2.10
208+
with:
209+
cuda: ${{ matrix.cuda }}
210+
method: 'local'
211+
212+
- name: Install Visual Studio Integration
213+
run: |
214+
$x = (dir $env:CUDA_PATH -dir -recurse -depth 2).where({$_.name -eq 'visual_studio_integration'}).fullname
215+
$y = (dir $x -dir -recurse).where({$_.name -eq 'MSBuildExtensions'}).fullname + '\*'
216+
(gi 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\*\BuildCustomizations').fullname.foreach({cp $y $_})
217+
218+
- uses: actions/checkout@v3
219+
with:
220+
repository: 'jllllll/bitsandbytes'
221+
ref: 'cmake_windows_0.40.0'
222+
223+
- uses: actions/setup-python@v4
224+
with:
225+
python-version: "3.10"
226+
227+
- name: Setup Mamba
228+
uses: conda-incubator/setup-miniconda@v2.2.0
229+
with:
230+
activate-environment: "build"
231+
python-version: "3.10"
232+
miniforge-variant: Mambaforge
233+
miniforge-version: latest
234+
use-mamba: true
235+
add-pip-as-python-dependency: true
236+
auto-activate-base: false
237+
238+
- name: Install Dependencies
239+
run: mamba install -y 'cmake' 'ninja' -c 'conda-forge' -c 'defaults'
240+
241+
- name: Compile Cuda Code
242+
if: matrix.cublas == '0'
243+
run: |
244+
$cudaVersion = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.'))
245+
if (!(Test-Path '.\BuildArtifacts\')) { mkdir '.\BuildArtifacts' }
246+
cmake -S . -B "./build_$cudaVersion_0" -G "Visual Studio 16 2019" -T "cuda=$cudaVersion" -D "NO_CUBLASLT=0" -D "CUDA_TARGET_ARCH_FEATURE_LEVEL=$cudaVersion" -D "CIBUILD=1"
247+
cmake --build "./build_$cudaVersion_0" --target libbitsandbytes_cuda --config Release
248+
249+
- name: Compile Cuda Code nocublaslt
250+
if: matrix.cublas == '1'
251+
run: |
252+
$cudaVersion = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.'))
253+
if (!(Test-Path '.\BuildArtifacts\')) { mkdir '.\BuildArtifacts' }
254+
cmake -S . -B "./build_$cudaVersion_1" -G "Visual Studio 16 2019" -T "cuda=$cudaVersion" -D "NO_CUBLASLT=1" -D "CUDA_TARGET_ARCH_FEATURE_LEVEL=$cudaVersion" -D "CIBUILD=1"
255+
cmake --build "./build_$cudaVersion_1" --target libbitsandbytes_cuda --config Release
256+
257+
- uses: actions/upload-artifact@v3
258+
with:
259+
name: compiled-binaries
260+
path: ./BuildArtifacts/*
261+
262+
build_wheel:
263+
name: Build Wheel
264+
needs: [compile_cuda_new, compile_cuda_old_conda, compile_cuda_old]
265+
runs-on: windows-latest
266+
defaults:
267+
run:
268+
shell: pwsh
269+
270+
steps:
271+
- uses: actions/checkout@v3
272+
with:
273+
repository: 'jllllll/bitsandbytes'
274+
ref: 'cmake_windows_0.40.0'
275+
276+
- uses: actions/setup-python@v4
277+
with:
278+
python-version: "3.10"
279+
280+
- uses: actions/download-artifact@v3
281+
with:
282+
name: compiled-binaries
283+
path: ./bitsandbytes
284+
285+
- name: Build Wheel
286+
run: |
287+
python -m pip install build wheel
288+
python -m build -n --wheel -C--global-option=--plat-name=win_amd64
289+
290+
- uses: actions/upload-artifact@v3
291+
with:
292+
name: wheel
293+
path: ./dist/*.whl
294+
295+
- name: Upload files to a GitHub release
296+
uses: svenstaro/upload-release-action@2.6.1
297+
with:
298+
file: ./dist/*.whl
299+
tag: wheels
300+
file_glob: true
301+
overwrite: true

0 commit comments

Comments
 (0)