Docker image for OpenCV + Python

Hello,

I would like to create an Ubuntu Docker container that uses the following packages:

  • Python 3.6 or above
  • OpenCV
  • Python PIL module
  • Keras for inference
  • PyQt5
  • YOLO V3 for inference (Darknet used through OpenCV)

I would like the NVIDIA GPU to be used by these packages. So, I guess OpenCV must be compiled with the appropriate compile flags turned on.

I would appreciate suggestions - i.e. which NGC containers might be good starting points, if any? Or would I need to create the container from scratch?

Thanks.

I forgot to mention - I plan to run the container on a GCP cloud instance.

Thanks

Also, do I need to explicitly install CUDA in this container, for the GPU to be used? Or would the OpenCV automatically handle it, when compiled with GPU support?

I don’t know if this is still relevant to the original poster, but here’s what worked for me.

It is entirely possible for OpenCV itself to never need to use a GPU. But here are my suggestions for some great Base Images for your Docker file:

1.Nvidia CUDA Base Image
2. You can follow instructions from here to analyze the Dockerfiles so you can build one from scratch and how to download the necessary drivers.

Nvidia has a post regarding that here.

To help you leverage the plethora of building blocks available on NGC to build your AI, HPC and Visualization use-cases even faster, we partnered with Google Cloud to establish pathways for you to confidently deploy any asset on the NGC Catalog. These NVIDIA certified pathways ensure that you are always building your solutions in the most performant environment, with the latest drivers and libraries optimally configured for you by experts.

Simply put, we take care of all the underlying plumbing so you can focus on what you do best and build faster than ever.

If you use any of the above Base Images, then CUDA will be pre-installed, type RUN pip3 install opencv-python (use pip for python2). The documentation for opencv-python is here. If opencv itself does not need GPU support, then that should suffice, else refer to opencv-python docs for more info.