Skip to content

Commit 072bda8

Browse files
committed
[build] Update CUDA build
1 parent f9144e7 commit 072bda8

File tree

3 files changed

+17
-35
lines changed

3 files changed

+17
-35
lines changed

.github/workflows/build-windows-cuda.yml

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: 🐍 Set up Python
3333
uses: actions/setup-python@v5
3434
with:
35-
python-version: '3.11'
35+
python-version: '3.13'
3636

3737
- name: 📦 Install Python Build Requirements
3838
run: |
@@ -46,13 +46,13 @@ jobs:
4646
# Use the runner's temp directory, which is guaranteed to exist.
4747
$installer_path = Join-Path $env:RUNNER_TEMP "cuda_installer.exe"
4848
curl -L -o $installer_path $cuda_installer_url
49-
49+
5050
echo "Installing CUDA Toolkit silently..."
5151
# Use Start-Process for robust execution in PowerShell.
5252
# The arguments must be passed as a single string.
5353
$arguments = "-s nvcc_12.1 cudart_12.1"
5454
Start-Process -FilePath $installer_path -ArgumentList $arguments -Wait -NoNewWindow
55-
55+
5656
echo "Adding CUDA to PATH..."
5757
$cuda_path = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1"
5858
echo "CUDA_PATH=$cuda_path" | Out-File -FilePath $env:GITHUB_ENV -Append
@@ -63,38 +63,20 @@ jobs:
6363
- name: Clone opencv-python repository
6464
run: |
6565
git clone --depth 1 --recursive https://github.com/opencv/opencv-python.git
66+
pip install numpy packaging scikit-build
6667
68+
# - CUDA_ARCH_BIN: Specifies the CUDA architectures to build for.
69+
# - CUDA_ARCH_PTX: Specifies the virtual architecture for forward compatibility.
70+
# TODO: Set correct PTX versions below.
71+
# TODO: Validate the built wheel can be installed and run.
6772
- name: 🛠️ Build opencv-python with CUDA
6873
run: |
6974
cd opencv-python
70-
71-
# Set environment variables to configure the build.
72-
# This is the core of the customization.
73-
# - WITH_CUDA=ON: Enables CUDA support.
74-
# - CUDA_ARCH_BIN: Specifies the CUDA architectures to build for.
75-
# - CUDA_ARCH_PTX: Specifies the virtual architecture for forward compatibility.
76-
# - BUILD_TESTS=OFF: Speeds up the build by not compiling tests.
77-
# Use single quotes to avoid PowerShell parsing issues with nested quotes.
78-
$env:CMAKE_ARGS = '-D CMAKE_BUILD_TYPE=RELEASE -D WITH_CUDA=ON -D CUDA_ARCH_BIN="6.0;6.1;7.0;7.5" -D CUDA_ARCH_PTX=7.5 -D OPENCV_ENABLE_NONFREE=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF'
79-
80-
# Set this to force a build from source instead of downloading a pre-built wheel.
81-
$env:PIP_NO_BINARY = ":all:"
82-
83-
# Run the build process. This will compile OpenCV and create a wheel.
84-
# The output wheel will be placed in the 'wheelhouse' directory.
85-
pip wheel . --wheel-dir ../wheelhouse
86-
87-
- name: 🧪 Verify Build
88-
run: |
89-
# Install the wheel we just built
90-
pip install ../wheelhouse/opencv_python*.whl
91-
92-
# Print OpenCV build information. We expect to see the "CUDA" section.
93-
echo "Verifying OpenCV build..."
94-
python -c "import cv2; print(cv2.getBuildInformation())"
75+
$CMAKE_ARGS = '-D CMAKE_BUILD_TYPE=RELEASE -D WITH_CUDA=ON -D CUDA_ARCH_BIN="6.0;6.1;7.0;7.5" -D CUDA_ARCH_PTX=7.5 -D OPENCV_ENABLE_NONFREE=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF'
76+
pip wheel . --verbose
9577
9678
- name: 📤 Upload Artifact
97-
uses: actions/upload-artifact@v4
79+
uses: actions/upload-artifact@v4.6.0
9880
with:
99-
name: opencv-python-cuda-wheel
100-
path: wheelhouse/
81+
name: opencv-python-cuda
82+
path: opencv-python/opencv_python*.whl

.github/workflows/publish-pypi.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ jobs:
116116
mv dist/*.whl pkg/
117117
118118
- name: Upload Package
119-
uses: actions/upload-artifact@v4
119+
uses: actions/upload-artifact@v4.6.0
120120
with:
121121
name: dvr-scan-dist
122122
path: |

.github/workflows/screenshot.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
shell: powershell
7676

7777
- name: Upload Screenshot
78-
uses: actions/upload-artifact@v4
78+
uses: actions/upload-artifact@v4.6.0
7979
with:
8080
name: dvr-scan-screenshot-windows
8181
path: dvr-scan-screenshot-windows.png
@@ -135,7 +135,7 @@ jobs:
135135
scrot -d 0 "dvr-scan-screenshot-linux-${{ matrix.resolution.width }}x${{ matrix.resolution.height }}.png"
136136
137137
- name: Upload Screenshot
138-
uses: actions/upload-artifact@v4
138+
uses: actions/upload-artifact@v4.6.0
139139
with:
140140
name: dvr-scan-screenshot-linux-${{ matrix.resolution.width }}x${{ matrix.resolution.height }}
141141
path: "dvr-scan-screenshot-linux-${{ matrix.resolution.width }}x${{ matrix.resolution.height }}.png"
@@ -181,7 +181,7 @@ jobs:
181181
screencapture "dvr-scan-screenshot-macos.png"
182182
183183
- name: Upload Screenshot
184-
uses: actions/upload-artifact@v4
184+
uses: actions/upload-artifact@v4.6.0
185185
with:
186186
name: dvr-scan-screenshot-macos
187187
path: "dvr-scan-screenshot-macos.png"

0 commit comments

Comments
 (0)