Docker flag "–gpu" does not work without sudo command

  docker, gpu, linux, ubuntu

I’m ubuntu user. I use the following docker image, tensorflow/tensorflow:nightly-gpu

If I try to run this command

$ docker run -it --rm --gpus all tensorflow/tensorflow:nightly-gpu bash

There’s permission denied error.

docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: Running hook #0:: error running hook: exit status 1, stdout: , stderr: nvidia-container-cli: mount error: open failed: /sys/fs/cgroup/devices/user.slice/devices.allow: permission denied: unknown.

Of course, I can run this command if I am using sudo, but I want to use gpu without sudo.

Is there any good solution? Any leads, please?

Source: Docker Questions