Last active
February 23, 2024 11:08
-
-
Save MoshiurRahmanFaisal/9d63b74eb08cea7fc877c3f417ea4200 to your computer and use it in GitHub Desktop.
A simple guide to install Docker and Nvidia Docker to get CUDA Support on Docker Images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
### Step 1: Install Docker ### | |
curl -fsSL https://get.docker.com -o get-docker.sh | |
sudo sh get-docker.sh | |
### Step 2: Restart the Docker ### | |
sudo systemctl restart docker | |
### Step 3: Add the package repositories for Nvidia-Docker ### | |
distribution=ubuntu20.04 | |
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - | |
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list | |
### Step 4: Install Nvidia-Docker ### | |
sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit | |
sudo systemctl restart docker | |
### Step 5: Get CUDA 11.3 for Nvidia-Docker ### | |
docker pull nvidia/cuda:11.3.0-base-ubuntu20.04 | |
### Step 6: Run Nvidia Docker with CUDA ### | |
docker run --rm --gpus all nvidia/cuda:11.3.0-base-ubuntu20.04 nvidia-smi | |
### Step 7: Add host machine local storage to docker container ### | |
docker container run -v /home/faisal/workspace/:/home/ --gpus all -it <IMAGE_ID> bin/bash | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment