|
1 | 1 | #!/bin/bash |
2 | | -declare build_arch |
3 | | -declare build_os |
4 | | -declare cuda_version |
5 | | -declare cuda_targets |
6 | | - |
7 | 2 | set -xeuo pipefail |
8 | 3 |
|
9 | | -if [[ -v cuda_targets ]]; then |
10 | | - build_capability="${cuda_targets}" |
11 | | -elif [ "${build_arch}" = "aarch64" ]; then |
| 4 | +: "${RUNNER_OS:?RUNNER_OS must be set (Linux/Windows/macOS)}" |
| 5 | +: "${RUNNER_ARCH:?RUNNER_ARCH must be set (X64/ARM64)}" |
| 6 | +: "${CUDA_VERSION:?CUDA_VERSION must be set}" |
| 7 | + |
| 8 | +if [[ -v CUDA_TARGETS ]]; then |
| 9 | + build_capability="${CUDA_TARGETS}" |
| 10 | +elif [ "${RUNNER_ARCH}" = "ARM64" ]; then |
12 | 11 | build_capability="75;80;90" |
13 | 12 |
|
14 | 13 | # CUDA 12.8-12.9: Add sm100/sm120 |
15 | | - [[ "${cuda_version}" == 12.8.* || "${cuda_version}" == 12.9.* ]] && build_capability="75;80;90;100;120" |
| 14 | + [[ "${CUDA_VERSION}" == 12.8.* || "${CUDA_VERSION}" == 12.9.* ]] && build_capability="75;80;90;100;120" |
16 | 15 |
|
17 | 16 | # CUDA 13.0+: Add sm100/sm110/sm120 |
18 | | - [[ "${cuda_version}" == 13.*.* ]] && build_capability="75;80;90;100;110;120;121" |
| 17 | + [[ "${CUDA_VERSION}" == 13.*.* ]] && build_capability="75;80;90;100;110;120;121" |
19 | 18 | else |
20 | 19 | # By default, target Pascal through Hopper. |
21 | 20 | build_capability="60;70;75;80;86;89;90" |
22 | 21 |
|
23 | 22 | # CUDA 12.8+: Add sm100 and sm120; remove < sm70 to align with PyTorch 2.8+cu128 minimum |
24 | | - [[ "${cuda_version}" == 12.8.* || "${cuda_version}" == 12.9.* ]] && build_capability="70;75;80;86;89;90;100;120" |
| 23 | + [[ "${CUDA_VERSION}" == 12.8.* || "${CUDA_VERSION}" == 12.9.* ]] && build_capability="70;75;80;86;89;90;100;120" |
25 | 24 |
|
26 | 25 | # CUDA 13.0+: Remove < sm75 to align with PyTorch 2.9+cu130 minimum |
27 | | - [[ "${cuda_version}" == 13.*.* ]] && build_capability="75;80;86;89;90;100;120" |
| 26 | + [[ "${CUDA_VERSION}" == 13.*.* ]] && build_capability="75;80;86;89;90;100;120" |
28 | 27 | fi |
29 | 28 |
|
30 | | -[[ "${build_os}" = windows-* ]] && python3 -m pip install ninja |
31 | | - |
32 | | -if [ "${build_os:0:6}" == ubuntu ]; then |
| 29 | +if [ "${RUNNER_OS}" == "Linux" ]; then |
33 | 30 | # We'll use Rocky Linux 8 in order to maintain manylinux 2.24 compatibility. |
34 | | - image="nvidia/cuda:${cuda_version}-devel-rockylinux8" |
| 31 | + image="nvidia/cuda:${CUDA_VERSION}-devel-rockylinux8" |
35 | 32 | echo "Using image $image" |
36 | 33 |
|
37 | 34 | docker run -i -w /src -v "$PWD:/src" "$image" bash -c \ |
38 | 35 | "dnf -y --refresh update --security \ |
39 | | - && dnf -y install cmake gcc-toolset-11 --setopt=install_weak_deps=False --setopt=tsflags=nodocs \ |
| 36 | + && dnf -y install cmake gcc-toolset-11-toolchain --setopt=install_weak_deps=False --setopt=tsflags=nodocs \ |
40 | 37 | && source scl_source enable gcc-toolset-11 \ |
41 | 38 | && cmake -DCOMPUTE_BACKEND=cuda -DCOMPUTE_CAPABILITY=\"${build_capability}\" . \ |
42 | | - && cmake --build . --config Release" |
| 39 | + && cmake --build . --config Release --parallel" |
43 | 40 | else |
44 | | - pip install cmake==3.28.3 |
45 | 41 | cmake -G Ninja -DCOMPUTE_BACKEND=cuda -DCOMPUTE_CAPABILITY="${build_capability}" -DCMAKE_BUILD_TYPE=Release -S . |
46 | 42 | cmake --build . --config Release |
47 | 43 | fi |
48 | 44 |
|
49 | | - |
50 | | -output_dir="output/${build_os}/${build_arch}" |
| 45 | +output_dir="output/${RUNNER_OS}/${RUNNER_ARCH}" |
51 | 46 | mkdir -p "${output_dir}" |
52 | 47 | (shopt -s nullglob && cp bitsandbytes/*.{so,dylib,dll} "${output_dir}") |
0 commit comments