Procedure
- Set Up NGC Account
- 1.1 Go to the NGC Catalog and create an account if you do not already have one.
- 1.2 Generate an API Key:
- Log in to your NGC account
- Go to Setup → API Key → Generate Key.
- 1.3 Authenticate Docker with NGC:
- Open a terminal (Command Prompt, PowerShell, or WSL) and run: docker login nvcr.io
- Use the following credentials:
- Username: $oauthtoken
- Password: (your-api-key-that-you-just-generated)
- Browse NGC Catalog for Specific Packages
- 2.1 Visit the NGC Catalog
- 2.2 Search for the specific package as per your need (e.g., PyTorch, TensorFlow, CUDA, etc.).
- 2.3 Click on the container to view details, including the pull command and tags.
- Pull Specific NGC Packages
- 3.1 Pull a Container:
- Use the docker pull command with the container’s path and tag.
- Example (PyTorch container, can also specify version): docker pull nvcr.io/nvidia/pytorch:23.05-py3
- Example (TensorFlow container, can also specify version): docker pull nvcr.io/nvidia/tensorflow:23.05-tf2-py3
- Example (CUDA container): docker pull nvcr.io/nvidia/cuda:12.1.0-base
- 3.2 Verify the Pull:
- After pulling, verify the image is available locally: docker images
- You should see the pulled image listed. Try using “docker image ls” in command prompt (make sure that docker desktop is running)
- Run the Pulled Container
- 4.1 Run with GPU Support:
- Use the docker run command to start the container with GPU access:
- docker run --gpus all -it --rm \
- -v /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 docker run command to start the container with GPU access:
- 4.2 Access the Container:
- Open a shell inside the container: docker exec -it (container-id0) /bin/bash
- Run scripts or commands directly: docker run --gpus all nvcr.io/nvidia/pytorch:23.05-py3 python train.py
- Pulling Specific Versions
- NGC containers often have multiple tags for different versions.
- For example:
- nvcr.io/nvidia/pytorch:23.05-py3 (specific version)
- nvcr.io/nvidia/pytorch:latest (latest stable version)