OpenCV with CUDA docker image build settings based on CUDA containers.
Feel free to quote and modify as needed.
- Ubuntu 22.04
- NVIDIA GPU driver version 535.104.05 or later.
- Docker engine.
- NVIDIA container runtime.
- NVIDIA Video Codec SDK. Recommended version 12.1.14.
Modify the video_codec_sdk
zip file path in dockerfile and execute build_image.sh
.
If necessary, you can use ARG to adjust the version number in dockerfile.
docker tag opencv-cuda:{opencv_version}-cuda{cuda_version}-ubuntu{ubuntu_version} {your-docker-hub}/opencv-cuda:{opencv_version}-cuda{cuda_version}-ubuntu{ubuntu_version}
docker push {your-docker-hub}/opencv-cuda:{opencv_version}-cuda{cuda_version}-ubuntu{ubuntu_version}
docker run --rm -it --gpus=all opencv-cuda:{opencv_version}-cuda{cuda_version}-ubuntu{ubuntu_version}
python3
import cv2
cv2.cuda.getCudaEnableDeviceCount()
cv2.cuda.printCudaDeviceInfo(0)
video_reader = cv2.cudacodec.createVideoReader("your_video_source")