For CentOS 7.9, the approach to installing NVIDIA Docker support involves a few different commands due to differences in package management and system initialization. Here's how you can install the NVIDIA drivers, the NVIDIA Docker Toolkit, and configure Docker to use the NVIDIA runtime on CentOS 7.9:
1. Install NVIDIA Drivers
Before installing the NVIDIA Docker Toolkit, you must ensure the NVIDIA drivers are installed. NVIDIA provides a repository for CentOS that can be used to install the drivers:
Add the NVIDIA repository:
sudo rpm --import https://www.nvidia.com/object/nvidia-drv.repo
Install the NVIDIA driver:
sudo yum install nvidia-driver-latest-dkms
Reboot the system to ensure the drivers are correctly loaded:
sudo reboot
2. Install NVIDIA Container Toolkit
Add the NVIDIA Docker repository:
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.repo | sudo tee /etc/yum.repos.d/nvidia-docker.repo
Install the NVIDIA Docker package:
sudo yum install -y nvidia-container-toolkit
Restart the Docker service:
sudo systemctl restart docker
3. Configure Docker to Use the NVIDIA Runtime
You might need to manually configure Docker to use the NVIDIA runtime by editing the /etc/docker/daemon.json
file. If this file does not exist, you will need to create it with the following content:
{
"default-runtime": "nvidia",
"runtimes": {
"nvidia": {
"path": "nvidia-container-runtime",
"runtimeArgs": []
}
}
}
After modifying or creating the file, restart Docker to apply the changes:
sudo systemctl restart docker
4. Verify NVIDIA Docker Installation
To verify that Docker can now utilize the NVIDIA GPU, run a test container:
docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi
This command will run a temporary container that uses a CUDA base image to execute nvidia-smi
, which should display your GPU's details, indicating that Docker is properly configured to use the GPU.
These steps should address the error and allow you to run Docker containers with GPU support on CentOS 7.9. If you encounter any errors, double-check each step for typos or missed steps, and ensure your system's BIOS settings have not disabled the GPU.