@@ -24,32 +24,59 @@ 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.12 '
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 : 🏗️ Setup Visual Studio Developer Command Prompt
49+ run : |
50+ $vcvars_path = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
51+ $lines = Invoke-Expression "& `"$vcvars_path`" && set"
52+ $lines | ForEach-Object {
53+ if ($_ -match "=") {
54+ $name, $value = $_.Split("=", 2)
55+ echo "$name=$value" | Out-File -FilePath $env:GITHUB_ENV -Append
56+ }
57+ }
58+ shell : pwsh
59+
60+ - name : Cache CUDA Toolkit Installer
61+ id : cache-cuda-installer
62+ uses : actions/cache@v3
63+ with :
64+ path : ./.cache/cuda_installer.exe
65+ key : cuda-installer-12.1.1
66+
4267 - name : 🔧 Install NVIDIA CUDA Toolkit
4368 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
69+ $installer_path = "./.cache/cuda_installer.exe"
70+ if (-not (Test-Path $installer_path)) {
71+ echo "Downloading CUDA Toolkit..."
72+ $cuda_installer_url = "https://developer.download.nvidia.com/compute/cuda/12.1.1/network_installers/cuda_12.1.1_windows_network.exe"
73+ New-Item -Path (Split-Path $installer_path) -ItemType Directory -Force
74+ curl -L -o $installer_path $cuda_installer_url
75+ } else {
76+ echo "CUDA Toolkit installer found in cache."
77+ }
4978
5079 echo "Installing CUDA Toolkit silently..."
51- # Use Start-Process for robust execution in PowerShell.
52- # The arguments must be passed as a single string.
5380 $arguments = "-s nvcc_12.1 cudart_12.1"
5481 Start-Process -FilePath $installer_path -ArgumentList $arguments -Wait -NoNewWindow
5582
@@ -60,20 +87,36 @@ jobs:
6087 echo "$cuda_path\lib\x64" | Out-File -FilePath $env:GITHUB_PATH -Append
6188 shell : pwsh
6289
90+ - name : Cache opencv-python repository
91+ id : cache-opencv-python
92+ uses : actions/cache@v3
93+ # TODO: Need to pin this to a version.
94+ with :
95+ path : opencv-python
96+ key : opencv-python-master
97+
6398 - name : Clone opencv-python repository
99+ if : steps.cache-opencv-python.outputs.cache-hit != 'true'
64100 run : |
65101 git clone --depth 1 --recursive https://github.com/opencv/opencv-python.git
66- pip install numpy packaging scikit-build
102+
103+ - name : Install opencv-python dependencies
104+ run : |
105+ pip install numpy packaging scikit-build cmake==3.24.2
67106
68107 # - CUDA_ARCH_BIN: Specifies the CUDA architectures to build for.
69108 # - CUDA_ARCH_PTX: Specifies the virtual architecture for forward compatibility.
70109 # TODO: Set correct PTX versions below.
71110 # TODO: Validate the built wheel can be installed and run.
111+ # TODO: Slim down the modules we build to only the ones that DVR-Scan needs to run:
112+ # https://docs.opencv.org/4.x/db/d05/tutorial_config_reference.html#tutorial_config_reference_general_modules
72113 - name : 🛠️ Build opencv-python with CUDA
73114 run : |
74115 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'
116+ $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'
117+ $ENABLE_CONTRIB = 1
76118 pip wheel . --verbose
119+ shell : pwsh
77120
78121 - name : 📤 Upload Artifact
79122 uses : actions/upload-artifact@v4.6.0
0 commit comments