Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot run non-root docker container with GPU

I made a fresh install of docker desktop from official docs docker desktop.

Then I installed NVIDIA Container Toolkit following official docs nvidia container toolkit.

When I run docker with non-root permission:

docker run --rm --gpus all nvidia/cuda:11.6.2-base-ubuntu20.04 nvidia-smi

It gave the following error:

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.

The error was not happened if I use sudo permission. Also, it is fine if I run a non-gpu container (without --gpu all option).

Some information about my PC:

  • Ubuntu 22.04
  • Nvida driver: 525, CUDA version: 12.0
  • Docker desktop: 23.0.5

I have tried several suggestions:

  • Add user to docker group, and video group
  • Install nvidia-docker2
  • Try changing ldconfig path: change ldconfig
  • Change GPU permissions:
sudo chmod 666 /dev/nvidia*
sudo chmod 666 /dev/nvidia-uvm*

  • Set permission for libnvidia-ml.so.1
sudo chown root:video /usr/local/nvidia/lib64/libnvidia-ml.so.1
sudo chmod 664 /usr/local/nvidia/lib64/libnvidia-ml.so.1
  • And some other methods which I will continue listing when I remember.

I am really desperate now. Does anyone have any suggestions? Any help will be highly appreciated.

like image 946
neji96 Avatar asked Feb 11 '26 12:02

neji96


1 Answers

I'm using Ubuntu/Linux and Docker Desktop. Have the same situation. Workaround is to use a docker default context docker context use default in your terminal.

like image 170
Edwin Hernandez Avatar answered Feb 14 '26 05:02

Edwin Hernandez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!