Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

OpenCV 4.13.0 CUDA Wheel — Installation Guide

Wheel built from source with full CUDA 13.2 support. Compiled for compute capability 8.6 (sm_86).


GPU compatibility

Works (sm_86)

GeForce RTX 30 series (desktop)

GPU VRAM
RTX 3090 Ti 24 GB
RTX 3090 24 GB
RTX 3080 Ti 12 GB
RTX 3080 12GB 12 GB
RTX 3080 10 GB
RTX 3070 Ti 8 GB
RTX 3070 8 GB
RTX 3060 Ti 8 GB
RTX 3060 12 GB
RTX 3050 8 GB

NVIDIA RTX / Quadro (workstation & professional)

GPU VRAM
RTX A6000 48 GB
RTX A5000 24 GB
RTX A4000 16 GB
RTX A3000 12 GB
RTX A2000 12GB 12 GB
RTX A2000 6 GB

Laptop GPUs (sm_86)

RTX 3080 Ti Laptop, RTX 3080 Laptop, RTX 3070 Ti Laptop, RTX 3070 Laptop, RTX 3060 Laptop, RTX 3050 Ti Laptop, RTX 3050 Laptop, RTX A5000 Laptop, RTX A4000 Laptop, RTX A3000 Laptop, RTX A2000 Laptop.


Does NOT work

Architecture Compute GPUs
Blackwell sm_100 RTX 5090, 5080, 5070, B100, B200, GB200
Hopper sm_90 H100, H200
Ada Lovelace sm_89 RTX 4090, 4080 Super, 4080, 4070 Ti Super, 4070 Ti, 4070 Super, 4070, 4060 Ti, 4060, RTX 6000 Ada, L4, L40
Ampere (data center) sm_80 A100, A30
Ampere (embedded) sm_87 Jetson AGX Orin
Turing sm_75 RTX 2080 Ti, 2080 Super, 2080, 2070 Super, 2070, 2060 Super, 2060, GTX 1660 Ti/Super/1650, T4, Quadro RTX 8000/6000/5000/4000
Volta sm_70 V100, Titan V
Pascal sm_61/60 GTX 1080 Ti, 1080, 1070, 1060, 1050, P100, Titan X

Note: A100 is sm_80, not sm_86 — despite also being Ampere architecture.


Planned future releases

In the near future we plan to publish additional wheels covering:

  • Python 3.10, 3.11 and 3.13 (cp310, cp311, cp313 ABI)
  • sm_75 — RTX 20xx / GTX 16xx (Turing)
  • sm_80 — A100 (Ampere data center)
  • sm_89 — RTX 40xx / Ada Lovelace
  • sm_90 — H100 (Hopper)
  • A combined multi-arch wheel with PTX fallback for forward compatibility

System requirements

Component Tested version Notes
OS Linux x86_64 Ubuntu 22.04 / Debian 13
Python 3.12 cp312 ABI — will not load on any other version (3.10, 3.11, 3.13+)
CUDA toolkit 13.2 (/usr/local/cuda-13.2) Must be on PATH / LD_LIBRARY_PATH
GPU driver ≥ 595 Tested with 595.71.05 (RTX 3090, compute 8.6)
PyTorch 2.12.0+cu132 Must match CUDA version
torchvision 0.27.0+cu132 See patch section below
NumPy 2.x Tested with 2.4.5

Why cp312 only?
Python extension modules embed the ABI tag at compile time. This wheel links against libpython3.12.so and cannot be loaded by any other Python version. To use a different Python version you must rebuild from source (see below).


Quick install

pip install opencv_contrib_python-4.13.0.92-cp312-cp312-linux_x86_64.whl --no-deps

# Verify
python -c "import cv2; print(cv2.__version__); print(cv2.cuda.getCudaEnabledDeviceCount(), 'CUDA device(s)')"

Expected output:

4.13.0
1 CUDA device(s)

Using with basicsr / Real-ESRGAN

basicsr 1.4.2 imports torchvision.transforms.functional_tensor, a module that existed in torchvision ≤ 0.14 and was removed in 0.15 (merged into torchvision.transforms.functional).

Option A — apply the shim (recommended, works with any torchvision ≥ 0.15)

Create one file in your Python environment:

SITE=$(python -c "import site; print(site.getsitepackages()[0])")

cat > "$SITE/torchvision/transforms/functional_tensor.py" << 'EOF'
# Compatibility shim: basicsr imports from the old functional_tensor location.
# torchvision >= 0.15 merged these into torchvision.transforms.functional.
from torchvision.transforms.functional import *  # noqa: F401,F403
from torchvision.transforms.functional import rgb_to_grayscale  # noqa: F401
EOF

Re-create this file after any pip install --upgrade torchvision.

Option B — patch basicsr itself

SITE=$(python -c "import site; print(site.getsitepackages()[0])")
grep -rn "functional_tensor" "$SITE/basicsr/"

Replace any line like:

from torchvision.transforms.functional_tensor import rgb_to_grayscale

with:

from torchvision.transforms.functional import rgb_to_grayscale

Gets overwritten on pip install --upgrade basicsr.


PyTorch + CUDA version matrix

PyTorch wheel tag CUDA runtime Compatible?
+cu132 13.2 Yes
+cu121 12.1 No
+cu118 11.8 No
CPU-only Partial — cv2.cuda.* calls will fail

Install matching PyTorch:

pip install torch==2.12.0+cu132 torchvision==0.27.0+cu132 \
    --index-url https://download.pytorch.org/whl/cu132

Rebuilding from source

Clone this repo and run the build script:

git clone https://github.com/tomasris/opencv-cuda-wheel
cd opencv-cuda-wheel
bash build_opencv_cuda.sh

The script:

  1. Clones opencv + opencv_contrib 4.13.0
  2. Patches cudev headers for CUDA 13.2 (_LIBCUDACXX_BEGIN_NAMESPACE_STD issue in zip.hpp)
  3. Builds the opencv-python scikit-build wrapper with -DWITH_CUDA=ON
  4. Produces a .whl in wheels/

To target a different GPU architecture, edit this line in the script:

-DCUDA_ARCH_BIN=8.6 \

For multi-arch (larger wheel, broader compatibility):

-DCUDA_ARCH_BIN="7.5;8.0;8.6;8.9;9.0" \
-DCUDA_ARCH_PTX="9.0" \

The cudev patch (CUDA 13.x only)

CUDA 13 changed internal libcu++ macros. Without the patch, the build fails with:

error: identifier "_LIBCUDACXX_BEGIN_NAMESPACE_STD" is undefined

File patched: opencv/modules/core/include/opencv2/core/cuda/detail/zip.hpp

// Before (broken with CUDA 13):
_LIBCUDACXX_BEGIN_NAMESPACE_STD
template<> struct tuple_size<...> { ... };
_LIBCUDACXX_END_NAMESPACE_STD

// After:
namespace std {
template<> struct tuple_size<...> { ... };
}

This patch is baked into the wheel — consumers do not need to apply it.


Build environment

Python      3.12.0  (Anaconda)
PyTorch     2.12.0+cu132
torchvision 0.27.0+cu132
NumPy       2.4.5
OpenCV      4.13.0  (opencv_contrib, CUDA 13.2, contrib modules enabled)
CUDA        13.2.78  (/usr/local/cuda-13.2)
GPU         NVIDIA RTX 3090  (compute 8.6)
Driver      595.71.05
OS          Debian 13 x86_64

About

OpenCV 4.13.0 with CUDA 13.2 built for Python 3.12 — prebuilt wheel for Linux x86_64 (RTX 3090 / Ampere)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages