Problem with the import of cv2 in the docker container

Hello.I installed dokcer container [ ].

I followed these intructions [How to Commit Changes to a Docker Image (With Example)] and as a result i created a new container with 1 additional package (tqdm).
Sequnce fo my actions: home/atlas/jetson-inference
3.apt-get install python3-pip
4.pip install tqdm
7.(sudo docker ps -a) sudo docker commit [CONTAINER_ID] [new_image_name]
8.sudo docker run -it —rm -v /home/atlas/Desktop/Jupiter1:/home/atlas/jetson-inference modified

Now i have a problem with an import of the module cv2 in my new modified container:

Also i have the same problem with an original container if i launch it by the command:
"sudo docker run -it —rm -v /home/atlas/Desktop/Jupiter1:/home/atlas/jetson-inference dustynv/jetson-inference "
instead of the command:
“docker/ --volume /my/host/path:/my/container/path (/my/host/path is atlas/desktop/Jupiter1)”

Besides this, i ahve the same problem in the main env.(I get the same error if i try to:

  1. python3
  2. import cv2

I tried to install open-cv in the modified docker container to solve this porblem, but i couldnt.

Full log of the installation is here:
log.txt (219.5 KB)

How can I solve the problem with an import of the module cv2 and launch modified container without this problem ?

Hi @A98, do you still get the error if you include --runtime nvidia in your 'sudo docker run` command?

sudo docker run -it --rm --runtime nvidia -v /home/atlas/Desktop/Jupiter1:/home/atlas/jetson-inference modified

Or you can use the -c option to docker/ to specify a different container to run, and this automatically adds --runtime nvidia and mounts the jetson-inference data/models dir, ect:

docker/ -c modified  # where modified is the new name/tag of the container you saved

If --runtime nvidia doesn’t fix it - are you able to run python3 -c 'import torch' in the container, or does it make similar error?

Thanks for you reply.No, i dont have error anymore.
sudo docker run -it --rm --runtime nvidia -v /home/atlas/Desktop/Jupiter1:/home/atlas/jetson-inference modified
(This is solution)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.