Skip to content

Instantly share code, notes, and snippets.

@lamhoangtung
Last active December 8, 2022 02:46
Show Gist options
  • Save lamhoangtung/d19bb72a99639a762b6d935fbd080c7c to your computer and use it in GitHub Desktop.
Save lamhoangtung/d19bb72a99639a762b6d935fbd080c7c to your computer and use it in GitHub Desktop.
How to install nvidia-docker offline for Ubuntu 18.04

How to install nvidia-docker offline for Ubuntu 18.04

Prerequisite

Before install nvidia-docker, you will need these first:

Then download these file:

Instruction

Install them one by one:

# Install nvidia
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo dpkg -i cuda-repo-ubuntu1804-11-2-local_11.2.0-460.27.04-1_amd64.deb
sudo apt-key add /var/cuda-repo-ubuntu1804-11-2-local/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda

# Install docker offline
sudo dpkg -i docker-ce-cli_18.09.9~3-0~ubuntu-xenial_arm64.deb

# Install nvidia docker
sudo dpkg -i libnvidia-container1_1.3.0-1_amd64.deb
sudo dpkg -i libnvidia-container-tools_1.3.0-1_amd64.deb
sudo dpkg -i nvidia-container-toolkit_1.3.0-1_amd64.deb
sudo dpkg -i nvidia-container-runtime_3.4.0-1_amd64.deb
sudo dpkg -i nvidia-docker2_2.5.0-1_all.deb

Then restart docker:

sudo systemctl restart docker

And this should work now ;)):

sudo docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi 
(Please note that you have to docker save ... | gzip > .tar.gz -> docker load -i .tar.gz -> copy locally -> run for the nvidia/cuda:11.0-base image)

Note

This same instruction can be apply for different Linux distribution and (or) arch. You just need to choose the suitable file.

I will update for RHEL7.7 later

Credit go to @vuonghoainam for adding offline docker installation

@hiro-v
Copy link

hiro-v commented Dec 22, 2020

Hey there please check it out for the link you provide should be in AMD64, but the LINK is for ARM64. Thanks

@lamhoangtung
Copy link
Author

My bad. Fixed it @vuonghoainam

@hiro-v
Copy link

hiro-v commented Dec 22, 2020

Please update the docker offline installation with deb as nvidia-docker2_2.5.0-1_all.deb requires it to install URL

@lamhoangtung
Copy link
Author

I thought you already got docker installed :3

@hiro-v
Copy link

hiro-v commented Dec 22, 2020 via email

@hiro-v
Copy link

hiro-v commented Dec 30, 2020

Hey @lam,

I think you should add the nvidia cuda installation instruction to this one, as it will come with multiple incompatible dependencies
LINK

@lamhoangtung
Copy link
Author

@vuonghoainam please update offline docker installation

@hiro-v
Copy link

hiro-v commented Jan 4, 2021

Note:

If you need to install docker compose offline, please use as below:

1. Download cli file from [link](https://github.com/docker/compose/releases/download/1.27.4/docker-compose-Linux-x86_64) then copy locally
2. Copy to /usr/local/bin/docker-compose the downloaded file
3. sudo chmod +x /usr/local/bin/docker-compose
4. Run as normal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment