0

Docker newbie question here, so please be nice.

I know this might be asked before but I could not find anything related to nvidia-docker. I completed the installation instructions on the official guide.

When I wanted to test Nvidia-docker:

docker run --gpus all nvidia/cuda:10.0-base nvidia-smi

I got this error:

(base) user@adminme:~$ docker run --gpus all --rm nvidia/cuda nvidia-smi
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

I found this answer here, but it felt a bit different for my case. I am very new to docker and still learning. let me know what you think?

here is some information about my remote Linux machine:

(base) user@adminme:~$ lspci | grep -i nvidia
02:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1080] (rev a1)
02:00.1 Audio device: NVIDIA Corporation GP104 High Definition Audio Controller (rev a1)

nvidia-smi command:

(base) user@adminme:~$ nvidia-smi
Sun May 31 01:12:25 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.64.00    Driver Version: 440.64.00    CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 1080    Off  | 00000000:02:00.0 Off |                  N/A |
|  0%   33C    P8     9W / 215W |     17MiB /  8116MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      2545      G   /usr/lib/xorg/Xorg                            15MiB |
+-----------------------------------------------------------------------------+

docker-version :

(base) user@adminme:~$ docker --version
Docker version 19.03.10, build 9424aeaee9
smerllo
  • 3,117
  • 1
  • 22
  • 37

2 Answers2

3

The quick fix would be to run the container using sudo:

sudo docker run --gpus all nvidia/cuda:10.0-base nvidia-smi

If you want to run docker as non-root user then you need to add it to the docker group.

  1. Create the docker group if it does not exist
sudo groupadd docker
  1. Add your user to the docker group.
sudo usermod -aG docker $USER
  1. Run the following command or Logout and login again and run (that doesn't work you may need to reboot your machine first)
newgrp docker
  1. Check if docker can be run without root
docker run --gpus all nvidia/cuda:10.0-base nvidia-smi

Ref:- https://docs.docker.com/engine/install/linux-postinstall/

nischay goyal
  • 3,206
  • 12
  • 23
0

In addition to what nischay goyal answered, sometimes after adding the user to the docker group you have to do

su - ${USER}

in order to log out and log back.

KansaiRobot
  • 7,564
  • 11
  • 71
  • 150