Procedure
- Install Docker Desktop on Windows
- 1.1 Go to Docker Desktop web page and download the installer.
- 1.2 Run the Installer:
- Double-click the installer and follow the prompts.
- Enable the option to use Windows containers if prompted (not required for NGC containers).
- 1.3 Enable WSL 2 (Windows Subsystem for Linux):
- Docker Desktop uses WSL 2 for better performance. Ensure WSL 2 is enabled.
- Go to Powershell and type the command: wsl --install
- Restart the computer.
- 1.4 Launch Docker Desktop.
- Install NVIDIA GPU Drivers
- 2.1 Download and install the Nvidia App
- 2.2 Make sure you have your gpu enabled before launching the app.
- 2.3 Once the Nvidia App is launched go to the drivers section on the left.
- 2.4 Select graphic driver preference to Game Ready Driver → Check for update → Click on download driver → Once downloaded Click on Install → Select Install preference to Express Install.
- 2.5 Verify GPU Installation (optional as successfully installed message will be displayed in nvidia app if all instructions followed correctly):
- Open a Command Prompt and run: nvidia-smi
- Ensure the GPU is detected and the driver version is displayed.
- Install NVIDIA Container Toolkit
- 3.1 Download the NVIDIA Container Toolkit
- Go to the NVIDIA Container Toolkit Installation Guide
- Download the installer
- 3.2 Run the Installer:
- Follow the prompts to install the toolkit.
- 3.3 Verify Installation:
- Open a Terminal and run: docker run --rm --gpus all nvidia/cuda:11.8.0-base nvidia-smi
- This should display the GPU information, confirming that Docker can access the GPU.
- Set Up Nvidia NGC Account
- 4.1 Go to Nvidia NGC Catalog and create an account.
- 4.2 Generate an API Key:
- Log in to your NGC account.
- Go to Setup → API Key → Generate Key.
- 4.3 Authenticate Docker with NGC:
- Open a Command Prompt and run: docker login nvcr.io
- Use the following credentials: Username: $oauthtoken Password: (your-api-key)
- Pull NGC Containers
- 5.1 Browse Nvidia NGC Catalog:
- Visit the Nvidia NGC Catalog to find pre-built containers (e.g., PyTorch, TensorFlow).
- 5.2 Pull a Container:
- Open a Command Prompt and run: docker pull nvcr.io/namespace/repo:tag
- Example (PyTorch container): docker pull nvcr.io/nvidia/pytorch:23.05-py3
- Run the Container
- 6.1 Run with GPU Support:
- Use the following command in command prompt to start the container with GPU access:
- docker run --gpus all -it --rm ^
- -v C:\path\to\local\data:/data ^ # Mount local data
- -p 8888:8888 ^ # Expose ports (e.g., Jupyter)
- nvcr.io/nvidia/pytorch:23.05-py3
- Flags:
- --gpus all: Enable GPU access.
- -it: Interactive terminal.
- --rm: Remove container after exit.
- v: Mount host directories into the container.
- -p: Expose ports for services like Jupyter Notebook.
- Use the following command in command prompt to start the container with GPU access:
- 6.2 Access the Container:
- Open a shell inside the container: docker exec -it (container-id) /bin/bash
- Run scripts or commands directly: docker run --gpus all nvcr.io/nvidia/pytorch:23.05-py3 python train.py