Skip to content

Commit 1a03334

Browse files
committed
[dist] Add build variants: full, minimal, legacy
* full: SASS for all architectures, PTX for 10.0 * minimal: SASS/PTX for 5.0 only * legacy: SASS/PTX for 3.5 only
1 parent 1235241 commit 1a03334

File tree

2 files changed

+43
-25
lines changed

2 files changed

+43
-25
lines changed

.github/workflows/build_wheels_windows.yml

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,35 +40,54 @@ jobs:
4040
matrix:
4141
python-version: ['3.13']
4242
platform: [x64]
43-
cuda-version: ['12']
43+
# Build variants control binary size vs JIT compilation tradeoff:
44+
# - full: CUDA 12, native SASS for all GPUs (5.0-10.0), largest binary, no JIT needed
45+
# - minimal: CUDA 12, only PTX/SASS 5.0, smallest binary, JIT required for non-Maxwell GPUs
46+
# - legacy: CUDA 11, PTX/SASS 3.5, for older GPUs (Kepler+) and systems with older drivers
47+
build-variant: ['full', 'minimal', 'legacy']
4448
include:
45-
# CUDA 12: Supports Maxwell (5.0) through Blackwell (10.0)
46-
# TODO(@Breakthrough): Expand PTX legacy support back to 5.0, it doesn't make the final
47-
# distribution that much larger and may help users with older GPUs.
49+
# CUDA 12 - Full variant: All SASS targets for maximum performance
4850
- cuda-version: '12'
51+
build-variant: 'full'
4952
runs-on: 'windows-2025'
5053
cuda-installer: 'cuda_12.9.1_windows_network.exe'
5154
cuda-path-version: 'v12.9'
5255
cudnn-archive: 'cudnn-windows-x86_64-9.18.1.3_cuda12-archive.zip'
5356
cudnn-folder: 'cudnn-windows-x86_64-9.18.1.3_cuda12-archive'
57+
cudnn-dll-path: 'bin/x64'
5458
video-codec-sdk-archive: 'Video_Codec_SDK_13.0.37.zip'
5559
video-codec-sdk-folder: 'Video_Codec_SDK_13.0.37'
5660
cuda-arch-bin: '5.0;5.2;6.0;6.1;7.0;7.5;8.0;8.6;8.9;9.0;10.0'
5761
cuda-arch-ptx: '10.0'
5862
cache-key: 'nvidia-deps-cuda-12.9.1-cudnn-9.18.1.3'
59-
# TODO: Re-enable CUDA 13 after updating to OpenCV 4.13+
60-
# CUDA 13: Supports Turing (7.5) through Blackwell (12.0)
61-
# - cuda-version: '13'
62-
# runs-on: 'windows-2025'
63-
# cuda-installer: 'cuda_13.1.1_windows_network.exe'
64-
# cuda-path-version: 'v13.1'
65-
# cudnn-archive: 'cudnn-windows-x86_64-9.18.1.3_cuda13-archive.zip'
66-
# cudnn-folder: 'cudnn-windows-x86_64-9.18.1.3_cuda13-archive'
67-
# video-codec-sdk-archive: 'Video_Codec_SDK_13.0.37.zip'
68-
# video-codec-sdk-folder: 'Video_Codec_SDK_13.0.37'
69-
# cuda-arch-bin: '7.5;8.0;8.6;8.9;9.0;10.0;12.0'
70-
# cuda-arch-ptx: '12.0'
71-
# cache-key: 'nvidia-deps-cuda-13.1.1-cudnn-9.18.1.3'
63+
# CUDA 12 - Minimal variant: PTX only for smallest binary size
64+
- cuda-version: '12'
65+
build-variant: 'minimal'
66+
runs-on: 'windows-2025'
67+
cuda-installer: 'cuda_12.9.1_windows_network.exe'
68+
cuda-path-version: 'v12.9'
69+
cudnn-archive: 'cudnn-windows-x86_64-9.18.1.3_cuda12-archive.zip'
70+
cudnn-folder: 'cudnn-windows-x86_64-9.18.1.3_cuda12-archive'
71+
cudnn-dll-path: 'bin/x64'
72+
video-codec-sdk-archive: 'Video_Codec_SDK_13.0.37.zip'
73+
video-codec-sdk-folder: 'Video_Codec_SDK_13.0.37'
74+
cuda-arch-bin: '5.0'
75+
cuda-arch-ptx: '5.0'
76+
cache-key: 'nvidia-deps-cuda-12.9.1-cudnn-9.18.1.3'
77+
# CUDA 11 - Legacy variant: For older GPUs (Kepler+) and systems with older drivers
78+
- cuda-version: '11'
79+
build-variant: 'legacy'
80+
runs-on: 'windows-2025'
81+
cuda-installer: 'cuda_11.8.0_windows_network.exe'
82+
cuda-path-version: 'v11.8'
83+
cudnn-archive: 'cudnn-windows-x86_64-8.9.7.29_cuda11-archive.zip'
84+
cudnn-folder: 'cudnn-windows-x86_64-8.9.7.29_cuda11-archive'
85+
cudnn-dll-path: 'bin'
86+
video-codec-sdk-archive: 'Video_Codec_SDK_13.0.37.zip'
87+
video-codec-sdk-folder: 'Video_Codec_SDK_13.0.37'
88+
cuda-arch-bin: '3.5'
89+
cuda-arch-ptx: '3.5'
90+
cache-key: 'nvidia-deps-cuda-11.8.0-cudnn-8.9.7.29'
7291
env:
7392
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
7493
SDIST: 0
@@ -139,7 +158,7 @@ jobs:
139158
$CUDNN_PATH = "D:/a/opencv-python-cuda/opencv-python-cuda/${{ matrix.cudnn-folder }}"
140159
echo "CUDNN_LIBRARY=$CUDNN_PATH/lib/x64/cudnn.lib" | Out-File -FilePath $env:GITHUB_ENV -Append
141160
echo "CUDNN_INCLUDE_DIR=$CUDNN_PATH/include" | Out-File -FilePath $env:GITHUB_ENV -Append
142-
Copy-Item -Path "$CUDNN_PATH/bin/x64/*" -Destination . -Include "*.dll"
161+
Copy-Item -Path "$CUDNN_PATH/${{ matrix.cudnn-dll-path }}/*" -Destination . -Include "*.dll"
143162
shell: pwsh
144163
- name: 🔧 Install NVIDIA Video Codec SDK
145164
run: |
@@ -160,9 +179,9 @@ jobs:
160179
if: ${{ inputs.restore_build_cache && !inputs.rolling_build }}
161180
with:
162181
path: _skbuild
163-
key: ${{ runner.os }}-${{ matrix.python-version }}-cuda${{ matrix.cuda-version }}-${{ hashFiles('**/CMakeLists.txt') }}
182+
key: ${{ runner.os }}-${{ matrix.python-version }}-cuda${{ matrix.cuda-version }}-${{ matrix.build-variant }}-${{ hashFiles('**/CMakeLists.txt') }}
164183
restore-keys: |
165-
${{ runner.os }}-${{ matrix.python-version }}-cuda${{ matrix.cuda-version }}-
184+
${{ runner.os }}-${{ matrix.python-version }}-cuda${{ matrix.cuda-version }}-${{ matrix.build-variant }}-
166185
167186
- name: Build a package
168187
# CMake 3.25 regression fix. See https://stackoverflow.com/questions/74162633/problem-compiling-from-source-opencv-with-mvsc2019-in-64-bit-version
@@ -184,11 +203,11 @@ jobs:
184203
if: ${{ inputs.save_build_cache && !inputs.rolling_build }}
185204
with:
186205
path: _skbuild
187-
key: ${{ runner.os }}-${{ matrix.python-version }}-cuda${{ matrix.cuda-version }}-${{ hashFiles('**/CMakeLists.txt') }}
206+
key: ${{ runner.os }}-${{ matrix.python-version }}-cuda${{ matrix.cuda-version }}-${{ matrix.build-variant }}-${{ hashFiles('**/CMakeLists.txt') }}
188207
- name: Saving all wheels
189208
uses: actions/upload-artifact@v4
190209
with:
191-
name: wheel-cuda${{ matrix.cuda-version }}-${{ matrix.platform }}
210+
name: opencv-python-cuda-${{ matrix.build-variant }}-${{ matrix.platform }}
192211
path: wheelhouse/opencv*
193212

194213
Test:
@@ -202,7 +221,7 @@ jobs:
202221
matrix:
203222
python-version: ['3.12']
204223
platform: [x64]
205-
cuda-version: ['12'] # TODO: Re-enable '13' after updating to OpenCV 4.13+
224+
build-variant: ['full', 'minimal', 'legacy']
206225
env:
207226
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
208227
OPENCV_TEST_DATA_PATH: ${{ github.workspace }}\opencv_extra\testdata
@@ -227,7 +246,7 @@ jobs:
227246
- name: Download a wheel accordingly to matrix
228247
uses: actions/download-artifact@v4
229248
with:
230-
name: wheel-cuda${{ matrix.cuda-version }}-${{ matrix.platform }}
249+
name: opencv-python-cuda-${{ matrix.build-variant }}-${{ matrix.platform }}
231250
path: wheelhouse/
232251
- name: Package installation
233252
run: |

docs/cuda-compatibility.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
PTX is forward-compatible only (e.g. PTX 10.0 works on GPUs ≥10.0, not older). SASS is required for older GPUs that are lower than the PTX version. A GPU needs either matching SASS or older PTX which it can JIT compile.
3434

3535

36-
3736
## References
3837

3938
- [CUDA Toolkit Archive](https://developer.nvidia.com/cuda-toolkit-archive)

0 commit comments

Comments
 (0)