Here's a README file structure for setting up Docker and running a Docker container, step-by-step:
-
Update Your System:
sudo apt update && sudo apt upgrade -y
-
Install Required Packages:
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
-
Add Docker's Official GPG Key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
-
Set Up the Stable Repository:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
-
Install Docker Engine:
sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io -y
-
Verify Installation:
sudo docker run hello-world
-
Navigate to the Project Directory:
cd path/to/your/dockerfile
-
Build the Docker Image:
docker build -t your-image-name .
-
Run the Docker Image:
docker run -it your-image-name
- Ubuntu machine with Docker installed
- NVIDIA GPU with appropriate drivers installed on the host system
-
Clone the Repository:
- Clone or download the repository containing the Dockerfile:
git clone https://github.com/UmairShah7677/Docker-Cuda-Installation cd Docker-Cuda-Installation
- Clone or download the repository containing the Dockerfile:
-
Build the Docker Image:
- Navigate to the directory containing the Dockerfile and build the image:
docker build -t cud-env .
- Navigate to the directory containing the Dockerfile and build the image:
-
Run the Docker Container:
- Start a Docker container using the built image:
docker run -it --gpus all cud-env
- Start a Docker container using the built image:
Here's a brief overview of what each command in the Dockerfile does:
- Wget: Downloads the CUDA repository pin and Debian package.
- mv: Moves the pin file to set priority for the CUDA packages.
- dpkg: Installs the CUDA repository Debian package.
- cp: Copies the keyring to the designated folder to validate packages.
- apt-get update: Updates the package list.
- apt-get install: Installs the CUDA toolkit and drivers.
- Environment Variables:
- Add CUDA to the
PATH
andLD_LIBRARY_PATH
environment variables:export PATH=/usr/local/cuda/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
- Add CUDA to the
- Tools:
- Install any additional tools like
vim
orscreenfetch
if needed:apt-get install -y vim screenfetch
- Install any additional tools like
- Docker Build Errors:
- Ensure there are no syntax errors in the Dockerfile, especially around command chaining (
&& \
). - Check that all URLs and file paths are correct and accessible.
- Ensure there are no syntax errors in the Dockerfile, especially around command chaining (
For more detailed information, check official NVIDIA and Docker documentation.
This README provides a clear step-by-step guide to setting up a Docker container for CUDA work, tailored to the specific commands and environment you are working with.