Skip to content

How to set GPU available Docker(Nvidia Docker) on Ubuntu

Notifications You must be signed in to change notification settings

ksr27/Docker-setting

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Official stable Docker setup on Ubuntu

https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-docker-ce-1

Nvidia-Docker setting

How to set GPU available Docker(Nvidia Docker) on Ubuntu

Set up your GPU driver before you go!

# If you have nvidia-docker 1.0 installed: we need to remove it and all existing GPU containers
docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
sudo apt-get purge -y nvidia-docker

# Add the package repositories
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
  sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \
  sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update


# Install nvidia-docker2 and reload the Docker daemon configuration
sudo apt-get install -y nvidia-docker2
sudo pkill -SIGHUP dockerd

# Test nvidia-smi with the latest official CUDA image
docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi

Lastly, if you want docker with out sudo command,

sudo groupadd docker
sudo usermod -aG docker $USER <-- change your user name here

log out & log in once

docker run hello-world

How to use Docker w/o sudo

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

About

How to set GPU available Docker(Nvidia Docker) on Ubuntu

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dockerfile 65.6%
  • Shell 34.4%