OpenCV pip wheels do NOT include CUDA support. To use GPU acceleration you must build OpenCV from source with CUDA enabled, or use the pre-built CUDA build from opencv.org.
Requirements
CUDA + OpenCV compatibility on Windows
| Component | Required version | Notes |
|---|---|---|
| GPU | NVIDIA only (CUDA) | GTX 900+ or RTX series recommended |
| CUDA Toolkit | 11.8, 12.0, 12.3+ | Match with cuDNN version |
| cuDNN | 8.x or 9.x | Required for DNN module GPU support |
| NVIDIA driver | 520+ (for CUDA 12) | Latest Game Ready or Studio driver |
| Visual Studio | 2019 or 2022 | Required to compile CUDA code |
Check GPU first
Verify CUDA is available before building
# Check NVIDIA driver and CUDA version:
C:\> nvidia-smi
Driver Version: 546.01 | CUDA Version: 12.3
# Check CUDA Toolkit is installed:
C:\> nvcc --version
Cuda compilation tools, release 12.3, V12.3.107
If
nvcc is not found, download CUDA Toolkit from developer.nvidia.com/cuda-downloads.Build from source
Build OpenCV with CUDA on Windows
- 1
Install prerequisites
Install: Visual Studio 2022, CMake, CUDA Toolkit, cuDNN. Install Python if you want Python bindings. Clone or download OpenCV source and opencv_contrib source.
- 2
Configure with CMake
PS> cmake -B build -S . `-DWITH_CUDA=ON `-DCUDA_ARCH_BIN="8.6" `# 8.6 = RTX 30xx, 8.9 = RTX 40xx, 7.5 = RTX 20xx-DWITH_CUDNN=ON `-DOPENCV_DNN_CUDA=ON `-DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules `-DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF - 3
Build and install
PS> cmake --build build --config Release --parallel 8# Takes 30-90 minutes depending on hardwarePS> cmake --install build --config Release - 4
Verify CUDA is active
import cv2print(cv2.cuda.getCudaEnabledDeviceCount())1# 0 means CUDA not available or build failedprint(cv2.cuda.printCudaDeviceInfo(0))Device 0: "NVIDIA GeForce RTX 3080"
FAQ
CUDA questions
cv2.cuda.getCudaEnabledDeviceCount() returns 0
Either the OpenCV build was not compiled with CUDA, or your GPU driver/CUDA version mismatch. Run
cv2.getBuildInformation() and check if CUDA shows YES. If not, the pip-installed OpenCV has no CUDA — you must build from source.Which CUDA_ARCH_BIN value should I use?
Use the compute capability of your GPU: RTX 40xx = 8.9, RTX 30xx = 8.6, RTX 20xx = 7.5, GTX 16xx = 7.5, GTX 10xx = 6.1. You can build for multiple architectures:
-DCUDA_ARCH_BIN="7.5;8.6;8.9".Can AMD GPUs use CUDA acceleration?
No. CUDA is NVIDIA-only. AMD GPUs can use OpenCL acceleration in OpenCV: build with
-DWITH_OPENCL=ON. Performance is generally lower than CUDA. There is also experimental ROCm support on Linux.