Skip to content

Commit 5c0ba85

Browse files
Merge pull request #1011 from akx/tweak-cmake-build-1
Optimize Cmake build slightly
2 parents 3ba076d + 6ec2520 commit 5c0ba85

File tree

2 files changed

+22
-35
lines changed

2 files changed

+22
-35
lines changed

.github/workflows/build_pr_documentation.yml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ concurrency:
99

1010
jobs:
1111
build:
12+
if: github.repository == 'TimDettmers/bitsandbytes'
1213
uses: huggingface/doc-builder/.github/workflows/build_pr_documentation.yml@main
1314
with:
1415
commit_sha: ${{ github.event.pull_request.head.sha }}

.github/workflows/cmake.yml

+21-35
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
pull_request:
77
branches: [ "main" ]
88

9+
concurrency:
10+
group: cmake-${{ github.ref }}
11+
cancel-in-progress: true
12+
913
jobs:
1014
build:
1115
runs-on: ${{ matrix.os }}
@@ -16,29 +20,11 @@ jobs:
1620

1721
matrix:
1822
os: [ubuntu-latest, windows-latest]
19-
python-version: ['3.10', '3.11']
2023
cuda-version: ['11.8', '12.1']
2124
build_type: [Release]
22-
c_compiler: [gcc, cl]
23-
include:
24-
- os: windows-latest
25-
c_compiler: cl
26-
cpp_compiler: cl
27-
- os: ubuntu-latest
28-
c_compiler: gcc
29-
cpp_compiler: g++
30-
exclude:
31-
- os: ubuntu-latest
32-
c_compiler: cl
33-
- os: windows-latest
34-
c_compiler: gcc
3525

3626
steps:
3727
- uses: actions/checkout@v4
38-
- name: Set up Python ${{ matrix.python-version }}
39-
uses: actions/setup-python@v5
40-
with:
41-
python-version: ${{ matrix.python-version }}
4228

4329
- name: Set up MSVC
4430
if: matrix.os == 'windows-latest'
@@ -61,7 +47,7 @@ jobs:
6147
environment-file: environment-bnb.yml
6248
use-only-tar-bz2: false
6349
auto-activate-base: true
64-
python-version: ${{ matrix.python-version }}
50+
python-version: "3.10"
6551
mamba-version: "*"
6652

6753
- name: Set reusable strings
@@ -97,8 +83,13 @@ jobs:
9783
echo CUDA_PATH=$CUDA_HOME >> "$GITHUB_ENV"
9884
9985
if [ "${{ matrix.os }}" = "windows-latest" ]; then
86+
echo CXX_COMPILER=cl >> "$GITHUB_ENV"
87+
echo C_COMPILER=cl >> "$GITHUB_ENV"
10088
# without -DCMAKE_CUDA_COMPILER=nvcc, cmake config always fail for cuda-11.8
10189
echo DCMAKE_CUDA_COMPILER=-DCMAKE_CUDA_COMPILER=nvcc >> "$GITHUB_ENV"
90+
else
91+
echo CXX_COMPILER=g++ >> "$GITHUB_ENV"
92+
echo C_COMPILER=gcc >> "$GITHUB_ENV"
10293
fi
10394
10495
nvcc --version
@@ -109,26 +100,27 @@ jobs:
109100
- name: Prep build
110101
run: python -m pip install cmake==3.27.9 ninja setuptools wheel
111102

112-
- name: Configure CMake
103+
# TODO: the following steps (CUDA, NOBLASLT, CPU) could be moved to the matrix, so they're built in parallel
104+
105+
- name: Configure CUDA
113106
run: >
114107
cmake -B ${{ steps.strings.outputs.build-output-dir }}
115108
-G Ninja ${{ env.DCMAKE_CUDA_COMPILER }}
116-
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
117-
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
109+
-DCMAKE_CXX_COMPILER=${{ env.CXX_COMPILER }}
110+
-DCMAKE_C_COMPILER=${{ env.C_COMPILER }}
118111
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
119112
-DCOMPUTE_CAPABILITY="50;52;60;61;62;70;72;75;80;86;87;89;90"
120113
-S ${{ github.workspace }}
121114
122-
- name: Build
123-
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
115+
- name: Build CUDA
124116
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
125117

126118
- name: Configure NOBLASLT
127119
run: >
128120
cmake -B ${{ steps.strings.outputs.build-output-dir }}
129121
-G Ninja ${{ env.DCMAKE_CUDA_COMPILER }}
130-
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
131-
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
122+
-DCMAKE_CXX_COMPILER=${{ env.CXX_COMPILER }}
123+
-DCMAKE_C_COMPILER=${{ env.C_COMPILER }}
132124
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
133125
-DCOMPUTE_CAPABILITY="50;52;60;61;62;70;72;75;80;86;87;89;90"
134126
-DNO_CUBLASLT=ON
@@ -141,8 +133,8 @@ jobs:
141133
run: >
142134
cmake -B ${{ steps.strings.outputs.build-output-dir }}
143135
-G Ninja ${{ env.DCMAKE_CUDA_COMPILER }}
144-
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
145-
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
136+
-DCMAKE_CXX_COMPILER=${{ env.CXX_COMPILER }}
137+
-DCMAKE_C_COMPILER=${{ env.C_COMPILER }}
146138
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
147139
-DNO_CUBLASLT=ON
148140
-DBUILD_CUDA=OFF
@@ -151,12 +143,6 @@ jobs:
151143
- name: Build CPU
152144
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
153145

154-
- name: Test
155-
working-directory: ${{ steps.strings.outputs.build-output-dir }}
156-
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
157-
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
158-
run: ctest --build-config ${{ matrix.build_type }}
159-
160146
- name: Build dist
161147
shell: bash -el {0}
162148
run: |
@@ -168,6 +154,6 @@ jobs:
168154
- name: Upload Build Artifacts
169155
uses: actions/[email protected]
170156
with:
171-
name: bitsandbytes-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.cuda-version }}
157+
name: bitsandbytes-${{ matrix.os }}-${{ matrix.cuda-version }}
172158
path: |
173159
${{ github.workspace }}/dist/

0 commit comments

Comments
 (0)