@@ -24,32 +24,47 @@ jobs:
2424 - name : 📥 Checkout code
2525 uses : actions/checkout@v4
2626
27- - name : 🏗️ Install Build Dependencies
28- run : |
29- echo "Installing CMake and Ninja for building..."
30- choco install -y cmake ninja
27+ # - name: 🏗️ Install Build Dependencies
28+ # run: |
29+ # echo "Installing CMake and Ninja for building..."
30+ # choco install -y cmake ninja
3131
3232 - name : 🐍 Set up Python
3333 uses : actions/setup-python@v5
3434 with :
35- python-version : ' 3.13 '
35+ python-version : ' 3.9 '
3636
3737 - name : 📦 Install Python Build Requirements
3838 run : |
3939 python -m pip install --upgrade pip
4040 pip install numpy wheel
4141
42+ - name : Setup MSBuild.exe
43+ uses : microsoft/setup-msbuild@v1.1
44+
45+ - name : Setup NASM
46+ uses : ilammy/setup-nasm@v1
47+
48+ - name : Cache CUDA Toolkit Installer
49+ id : cache-cuda-installer
50+ uses : actions/cache@v3
51+ with :
52+ path : ./.cache/cuda_installer.exe
53+ key : cuda-installer-12.1.1
54+
4255 - name : 🔧 Install NVIDIA CUDA Toolkit
4356 run : |
44- echo "Downloading CUDA Toolkit..."
45- $cuda_installer_url = "https://developer.download.nvidia.com/compute/cuda/12.1.1/network_installers/cuda_12.1.1_windows_network.exe"
46- # Use the runner's temp directory, which is guaranteed to exist.
47- $installer_path = Join-Path $env:RUNNER_TEMP "cuda_installer.exe"
48- curl -L -o $installer_path $cuda_installer_url
57+ $installer_path = "./.cache/cuda_installer.exe"
58+ if (-not (Test-Path $installer_path)) {
59+ echo "Downloading CUDA Toolkit..."
60+ $cuda_installer_url = "https://developer.download.nvidia.com/compute/cuda/12.1.1/network_installers/cuda_12.1.1_windows_network.exe"
61+ New-Item -Path (Split-Path $installer_path) -ItemType Directory -Force
62+ curl -L -o $installer_path $cuda_installer_url
63+ } else {
64+ echo "CUDA Toolkit installer found in cache."
65+ }
4966
5067 echo "Installing CUDA Toolkit silently..."
51- # Use Start-Process for robust execution in PowerShell.
52- # The arguments must be passed as a single string.
5368 $arguments = "-s nvcc_12.1 cudart_12.1"
5469 Start-Process -FilePath $installer_path -ArgumentList $arguments -Wait -NoNewWindow
5570
@@ -60,20 +75,36 @@ jobs:
6075 echo "$cuda_path\lib\x64" | Out-File -FilePath $env:GITHUB_PATH -Append
6176 shell : pwsh
6277
78+ - name : Cache opencv-python repository
79+ id : cache-opencv-python
80+ uses : actions/cache@v3
81+ # TODO: Need to pin this to a version.
82+ with :
83+ path : opencv-python
84+ key : opencv-python-master
85+
6386 - name : Clone opencv-python repository
87+ if : steps.cache-opencv-python.outputs.cache-hit != 'true'
6488 run : |
6589 git clone --depth 1 --recursive https://github.com/opencv/opencv-python.git
66- pip install numpy packaging scikit-build
90+
91+ - name : Install opencv-python dependencies
92+ run : |
93+ pip install numpy packaging scikit-build cmake==3.24.2
6794
6895 # - CUDA_ARCH_BIN: Specifies the CUDA architectures to build for.
6996 # - CUDA_ARCH_PTX: Specifies the virtual architecture for forward compatibility.
7097 # TODO: Set correct PTX versions below.
7198 # TODO: Validate the built wheel can be installed and run.
99+ # TODO: Slim down the modules we build to only the ones that DVR-Scan needs to run:
100+ # https://docs.opencv.org/4.x/db/d05/tutorial_config_reference.html#tutorial_config_reference_general_modules
72101 - name : 🛠️ Build opencv-python with CUDA
73102 run : |
74103 cd opencv-python
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'
104+ $CMAKE_ARGS = '-D CMAKE_BUILD_TYPE=RELEASE -D BUILD_SHARED_LIBS=OFF -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 ENABLE_LTO=ON -D CPU_DISPATCH="AVX,AVX2" -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF -D OPENCV_EXTRA_MODULES_PATH=opencv_contrib/modules'
105+ $ENABLE_CONTRIB = 1
76106 pip wheel . --verbose
107+ shell : pwsh
77108
78109 - name : 📤 Upload Artifact
79110 uses : actions/upload-artifact@v4.6.0
0 commit comments