Installing OpenCV on Volta P3 instance

I understand that we can pull the docker containers for deep learning frameworks. What do I need to do to install OpenCV on the running CUDA container?
Thanks.

You can install anything into a container the same way you normally would install - with apt-get, from source, etc. Most of the framework containers include a file called /workspace/docker-examples/Dockerfile.addpackages that illustrates this.

That said, several of the frameworks already ship with OpenCV. Which one specifically are you interested in?

I’m using the ‘docker pull nvcr.io/nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04’ command to pull the CUDA container. Then I use ‘nvidia-docker run -ti nvcr.io/nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04’ to run the container.
Once I’m running the container and I try to install OpenCV using apt-get, I’m unable to proceed further because all the dependency packages are unable to be located.
Also, I can’t locate the /workspace/ folder.

The base CUDA image doesn’t have a /workspace directory, that’s true. Almost all of the framework images do, though. Beyond the OpenCV library (and its dependencies), what actual application are you trying to containerize?

PS: You have to do apt-get update before you can use apt-get install in any of these containers.

I need to run a CUDA application on the Volta cloud that doesn’t use any specialized framework, so I decided to use the base CUDA container. However, if OpenCV is already installed on other containers, I can just use those instead to run the baseline CUDA application.
I’m able to install OpenCV after running apt-get.

I see.

Well, my best advice will be for you to write a Dockerfile that describes the build process of your application, building “FROM” the NGC CUDA image.

This will allow you to easily and reproducibly rebuild your application on top of the updated base CUDA images we release each month as well as picking up any updated builds of other dependencies you might need to install.

You can take a look at https://docs.docker.com/engine/reference/builder/ for an explanation of Dockerfile syntax to get started.

Yes, I looked into it. It sounds optimal. Thanks!

See also the SO post “Installing OpenCV in a Docker Container” here:

https://stackoverflow.com/questions/36862589/install-opencv-in-a-docker-container

This is a perennial topic so lots of content is available on SO and elsewhere. Should be straightforward via Dockerfile build.

Thanks!