Search code examples
dockergpu

Error libnvidia-ml.so.1: cannot open shared object file raised when running docker image with gpu


The error:

nvidia-container-cli: initialization error: load library 
failed: libnvidia-ml.so.1: cannot open shared object file: no 
such file or directory: unknown

I am trying to use nvidia/cuda image in docker hub to use GPU. So I run the code below with --gpus all.

docker run -it --gpus all -v --name my-gpu nvidia/cuda:11.7.0-cudnn8-devel-ubuntu22.04

But this gives me error which is as below.

Unable to find image 'nvidia/cuda:11.7.0-cudnn8-devel-ubuntu22.04' locally

11.7.0-cudnn8-devel-ubuntu22.04: Pulling from nvidia/cuda
d19f32bd9e41: Already exists 
292e5e4dcc78: Already exists 
f027458ef473: Already exists 
ad9cd0a3350e: Already exists 
4c0e748dfb24: Already exists 
e40f2cbf6f5e: Pull complete 
3ac150f167fe: Pull complete 
dd80ebac36de: Pull complete 
fd2716719ab6: Pull complete 
e5ff1925518e: Pull complete 
Digest: sha256:1055a2fa47b063336f578f390131efa4bb02fbfe095608481fd32b6fca9b8b32
Status: Downloaded newer image for nvidia/cuda:11.7.0-cudnn8-devel-ubuntu22.04
docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error running hook #0: error running hook: exit status 1, stdout: , stderr: Auto-detected mode as 'legacy'
nvidia-container-cli: initialization error: load library failed: libnvidia-ml.so.1: cannot open shared object file: no such file or directory: unknown.
ERRO[0465] error waiting for container: context canceled 

But if I run the same code with sudo, it works completely fine.

sudo docker run -it --gpus all --name my-container-03  nvidia/cuda:11.7.0-cudnn8-devel-ubuntu22.04

How can I make it run without sudo? I must not run with sudo in my case now.


Solution

  • It was solved when I installed docker desktop.