Skip to content

Commit ece67ae

Browse files
committed
separate ubuntu docker jobs
* build-shared-libs-cuda-docker: cuda build using docker (ubuntu) * build-shared-libs-cuda: cuda build using conda+mamba (windows)
1 parent ea2dcdb commit ece67ae

File tree

1 file changed

+116
-17
lines changed

1 file changed

+116
-17
lines changed

.github/workflows/python-package.yml

Lines changed: 116 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,27 +109,21 @@ jobs:
109109
with:
110110
name: shared_library_${{ matrix.os }}_${{ matrix.arch }}
111111
path: output/*
112+
112113
##
113-
# This job matrix builds the CUDA versions of the libraries for platforms that support CUDA (Linux x64/aarch64 + Windows x64)
114+
# This job matrix builds the CUDA versions of the libraries for platforms that support CUDA (Windows)
114115
##
115116
build-shared-libs-cuda:
116117
strategy:
117118
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
118119
fail-fast: false
119120

120121
matrix:
121-
os: [ubuntu-latest, windows-latest]
122-
arch: [x86_64, aarch64]
122+
os: [windows-latest]
123+
arch: [x86_64]
123124
cuda-version: ['11.8.0', '12.1.1']
124125
build_type: [Release]
125-
exclude:
126-
- os: windows-latest # This probably requires arm64 Windows agents
127-
arch: aarch64
128126
runs-on: ${{ matrix.os }} # One day, we could run them on native agents. Azure supports this now but it's planned only for Q3 2023 for hosted agents
129-
container:
130-
image: ${{ matrix.os == 'windows-latest' && 'null' || format('nvidia/cuda:{0}-{1}', matrix.cuda-version, 'devel-ubuntu22.04') }}
131-
volumes:
132-
- /home/runner/work:/home/runner/work
133127
steps:
134128
# Check out code
135129
- uses: actions/checkout@v4
@@ -171,13 +165,6 @@ jobs:
171165
python-version: "3.10"
172166
mamba-version: "*"
173167

174-
- name: Setup Docker image
175-
if: startsWith(matrix.os, 'ubuntu')
176-
shell: bash
177-
run: |
178-
apt-get update
179-
DEBIAN_FRONTEND=noninteractive apt-get install -y sudo cmake
180-
181168
- name: Set reusable strings
182169
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
183170
id: strings
@@ -270,10 +257,122 @@ jobs:
270257
name: shared_library_cuda_${{ matrix.os }}_${{ matrix.arch }}_${{ matrix.cuda-version }}
271258
path: output/*
272259

260+
##
261+
# This job matrix builds the CUDA versions of the libraries for platforms that support CUDA (Linux x64/aarch64)
262+
##
263+
build-shared-libs-cuda-docker:
264+
strategy:
265+
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
266+
fail-fast: false
267+
268+
matrix:
269+
os: [ubuntu-latest]
270+
arch: [x86_64, aarch64]
271+
cuda-version: ['11.8.0', '12.1.1']
272+
build_type: [Release]
273+
exclude:
274+
- os: windows-latest # This probably requires arm64 Windows agents
275+
arch: aarch64
276+
runs-on: ${{ matrix.os }} # One day, we could run them on native agents. Azure supports this now but it's planned only for Q3 2023 for hosted agents
277+
container:
278+
image: ${{ matrix.os == 'windows-latest' && 'null' || format('nvidia/cuda:{0}-{1}', matrix.cuda-version, 'devel-ubuntu22.04') }}
279+
volumes:
280+
- /home/runner/work:/home/runner/work
281+
steps:
282+
# Check out code
283+
- uses: actions/checkout@v4
284+
# Linux: We use Docker to build cross platform Cuda (aarch64 is built in emulation)
285+
- name: Setup cmake
286+
uses: jwlawson/actions-setup-cmake@v1.14
287+
with:
288+
cmake-version: '3.26.x'
289+
- name: Set up Python 3.10
290+
uses: actions/setup-python@v5
291+
with:
292+
python-version: "3.10"
293+
294+
- name: Setup Docker image
295+
if: startsWith(matrix.os, 'ubuntu')
296+
shell: bash
297+
run: |
298+
apt-get update
299+
DEBIAN_FRONTEND=noninteractive apt-get install -y sudo cmake
300+
301+
- name: Set reusable strings
302+
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
303+
id: strings
304+
shell: bash
305+
run: |
306+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
307+
308+
- name: Allow cross-compile on aarch64
309+
if: ${{ matrix.os == 'ubuntu-latest' && matrix.arch == 'aarch64' }}
310+
run: |
311+
# Allow cross-compile on aarch64
312+
sudo apt-get install -y gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu
313+
314+
- name: CUDA Toolkit
315+
shell: bash -el {0}
316+
run: |
317+
cuda_version=${{ matrix.cuda-version }}
318+
[ "$cuda_version" = "11.8.0" ] && cuda__version="11.8"
319+
[ "$cuda_version" = "12.1.1" ] && cuda__version="12.1"
320+
321+
CUDA_HOME="${{ env.CONDA }}/envs/bnb-env"
322+
echo CUDA_HOME=$CUDA_HOME >> "$GITHUB_ENV"
323+
echo CUDA_PATH=$CUDA_HOME >> "$GITHUB_ENV"
324+
echo CXX_COMPILER=g++ >> "$GITHUB_ENV"
325+
326+
nvcc --version
327+
328+
- name: Prep build
329+
run: python -m pip install cmake==3.27.9 ninja
330+
331+
# TODO: the following steps (CUDA, NOBLASLT, CPU) could be moved to the matrix, so they're built in parallel
332+
333+
- name: Configure CUDA
334+
run: >
335+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
336+
-G Ninja ${{ env.DCMAKE_CUDA_COMPILER }}
337+
-DCMAKE_CXX_COMPILER=${{ env.CXX_COMPILER }}
338+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
339+
-DCOMPUTE_CAPABILITY="50;52;60;61;62;70;72;75;80;86;87;89;90"
340+
-DCOMPUTE_BACKEND=cuda
341+
-S ${{ github.workspace }}
342+
343+
- name: Build CUDA
344+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
345+
346+
- name: Configure NOBLASLT
347+
run: >
348+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
349+
-G Ninja ${{ env.DCMAKE_CUDA_COMPILER }}
350+
-DCMAKE_CXX_COMPILER=${{ env.CXX_COMPILER }}
351+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
352+
-DCOMPUTE_CAPABILITY="50;52;60;61;62;70;72;75;80;86;87;89;90"
353+
-DCOMPUTE_BACKEND=cuda
354+
-DNO_CUBLASLT=ON
355+
-S ${{ github.workspace }}
356+
357+
- name: Build NOBLASLT
358+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
359+
360+
- name: Copy libraries
361+
shell: bash
362+
run: |
363+
mkdir -p output/${{ matrix.os }}/${{ matrix.arch }}
364+
( shopt -s nullglob && cp bitsandbytes/*.{so,dylib,dll} output/${{ matrix.os }}/${{ matrix.arch }}/ )
365+
- name: Upload build artifact
366+
uses: actions/upload-artifact@v4
367+
with:
368+
name: shared_library_cuda_${{ matrix.os }}_${{ matrix.arch }}_${{ matrix.cuda-version }}
369+
path: output/*
370+
273371
build-wheels:
274372
needs:
275373
- build-shared-libs
276374
- build-shared-libs-cuda
375+
- build-shared-libs-cuda-docker
277376
strategy:
278377
matrix:
279378
os: [ubuntu-latest, macos-latest, windows-latest]

0 commit comments

Comments
 (0)