Skip to content

Commit d5057fa

Browse files
committed
[build] Only bundle CUDA DLLs that cv2.pyd actually needs
PE import analysis shows ~1.3 GB of CUDA toolkit DLLs bundled in the wheel are never referenced by cv2.pyd or its transitive dependencies. Switch from copying all CUDA bin/*.dll to an allowlist of only the DLLs that are actually linked: cublas, cublasLt, cudart, cufft, and the npp libraries.
1 parent 0faece6 commit d5057fa

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

.github/workflows/build_wheels_windows.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,16 @@ jobs:
124124
echo "Adding CUDA to PATH..."
125125
$CUDA_PATH = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\${{ matrix.cuda-path-version }}"
126126
echo "CUDA_PATH=$CUDA_PATH" | Out-File -FilePath $env:GITHUB_ENV -Append
127-
Copy-Item -Path "$CUDA_PATH/bin/*" -Destination . -Include "*.dll"
127+
# Only copy CUDA DLLs that cv2.pyd actually needs (determined via PE import analysis).
128+
# This excludes ~1.3 GB of unused libraries (cusparse, cusolver, curand, nvrtc, etc.)
129+
$needed_dlls = @(
130+
"cublas64_*", "cublasLt64_*", "cudart64_*", "cufft64_*",
131+
"nppc64_*", "nppial64_*", "nppicc64_*", "nppidei64_*", "nppif64_*",
132+
"nppig64_*", "nppim64_*", "nppist64_*", "nppitc64_*"
133+
)
134+
foreach ($pattern in $needed_dlls) {
135+
Copy-Item -Path "$CUDA_PATH\bin\$pattern.dll" -Destination .
136+
}
128137
shell: pwsh
129138
- name: 🔧 Install NVIDIA CuDNN
130139
run: |

0 commit comments

Comments
 (0)