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
0 commit comments