Skip to main content
App Icon
Get our Android App
Read articles faster, offline, and more
Install

Set Up NVIDIA GPU Driver & Container Toolkit for ML Workloads

Introduction

Optimizing your machine learning (ML) infrastructure hinges on effectively leveraging your NVIDIA GPUs. Without proper setup, your expensive hardware remains underutilized, leading to prolonged training times and increased operational costs. This guide details the essential steps to install the NVIDIA GPU driver and the NVIDIA Container Toolkit, ensuring your ML workloads can seamlessly access and utilize GPU resources within containerized environments. Properly configuring this setup can significantly reduce compute bottlenecks and improve the return on investment for your GPU hardware.

Tech–Finance Matrix

Prerequisite (Hardware/Software/Account)Cost (Buy or Lease/Finance)Lifespan or RenewalTax / Deduction NoteOperational Limit or Throughput
NVIDIA GPU (e.g., A100, RTX 4090)$1,000 - $15,000+ (CapEx)3-5 yearsSection 179 / Bonus Depreciation (US); Capital Allowance (MY/UK)Varies by GPU model (e.g., TFLOPS, VRAM)
Linux Distribution (e.g., Ubuntu, RHEL)Free (Open Source)N/A (Ongoing updates)N/ASystem stability, compatibility
NVIDIA GPU DriverFree (Included with GPU)N/A (Update as needed)N/AEnables GPU functionality, performance tuning
NVIDIA Container ToolkitFree (Open Source)N/A (Update as needed)N/AAllows containerized applications to access GPUs
Container Runtime (Docker, containerd)Free (Open Source)N/A (Update as needed)N/AManages container lifecycle, GPU access configuration

Step-by-Step Setup

Step 1: Install NVIDIA GPU Driver

The first critical step is to install the correct NVIDIA GPU driver for your specific Linux distribution. NVIDIA recommends using your distribution’s package manager for the most stable installation. Alternatively, you can download a .run installer from the NVIDIA website. Ensuring the driver is correctly installed is fundamental for any subsequent GPU acceleration.

Financial Impact: A correctly installed driver ensures your GPU hardware performs as expected, directly impacting the speed of ML model training and inference. Incorrect installation can lead to performance degradation or complete failure, wasting valuable compute time and increasing operational expenses.

Step 2: Configure Production Repository

Before installing the Container Toolkit, you need to add NVIDIA’s official repository to your system’s package sources. This allows your package manager to find and install the latest stable version of the toolkit. For Debian/Ubuntu systems, this involves adding a GPG key and a .list file. For RPM-based systems like RHEL/Fedora, you’ll add a .repo file.

Financial Impact: Using the official repository ensures you get the most stable and compatible version of the toolkit, minimizing potential conflicts that could lead to downtime or costly troubleshooting. Accessing experimental packages can offer newer features but may introduce instability, requiring careful risk assessment.

Step 3: Install NVIDIA Container Toolkit

With the repository configured, you can now install the NVIDIA Container Toolkit packages. This typically involves a command like sudo apt-get install -y nvidia-container-toolkit for Debian-based systems or sudo dnf install -y nvidia-container-toolkit for RPM-based systems. The toolkit includes necessary libraries and tools to bridge container runtimes with the NVIDIA driver.

Financial Impact: This step is crucial for enabling GPU access within containers. Without it, your containerized ML applications will not see or be able to use the GPUs, rendering your hardware investment ineffective for these workloads and potentially requiring costly workarounds.

Step 4: Configure Container Runtime

Once the toolkit is installed, you must configure your container runtime to use the NVIDIA Container Runtime. For Docker, this is typically done via the nvidia-ctk runtime configure --runtime=docker command, which modifies /etc/docker/daemon.json. For containerd, it involves creating a drop-in configuration file.

Financial Impact: This configuration step directly enables GPU passthrough. Incorrect configuration can lead to containers failing to start or losing GPU access mid-execution, resulting in failed training jobs and wasted compute resources. The nvidia-ctk command simplifies this, reducing the risk of manual configuration errors.

Step 5: Restart Container Daemon

Finally, restart your container runtime’s daemon for the changes to take effect. For Docker, this is sudo systemctl restart docker. For containerd, it’s sudo systemctl restart containerd. This ensures the runtime is using the updated configuration that includes NVIDIA GPU support.

Financial Impact: A successful restart confirms that the GPU access is enabled. If the daemon fails to restart or the configuration is incorrect, containers will not have GPU access, leading to delays and potential cost overruns on cloud instances if you’re paying for unused GPU capacity.

  • Verify NVIDIA GPU driver installation.
  • Add NVIDIA Container Toolkit repository.
  • Install NVIDIA Container Toolkit packages.
  • Configure your container runtime (Docker, containerd, CRI-O).
  • Restart the container runtime daemon.

Tips & Best Practices

  • Use Package Managers: Always prefer your distribution’s package manager for driver and toolkit installation for better system integration and easier updates.
  • Check Compatibility: Ensure your chosen NVIDIA GPU driver version is compatible with your Linux distribution and the Container Toolkit version.
  • Rootless Docker: For enhanced security, consider configuring rootless Docker if your use case allows, following NVIDIA’s specific instructions.
  • Kubernetes Integration: If using Kubernetes, ensure your cluster’s container runtime (containerd or CRI-O) is correctly configured via nvidia-ctk runtime configure --runtime=containerd or --runtime=crio.
  • Monitor GPU Usage: Utilize tools like nvidia-smi within your containers to monitor GPU utilization and ensure your applications are effectively using the hardware.

Common Mistakes

Technical ErrorFinancial ConsequenceSafe Fix
Incorrect NVIDIA driver version installedML models fail to train or infer; GPU not detected in containersUninstall current driver, verify compatibility, and reinstall using package manager or official NVIDIA guide.
Container runtime not configured for NVIDIAContainers cannot access GPUs, leading to CPU-bound performance and longer job timesRun sudo nvidia-ctk runtime configure --runtime=<your-runtime> and restart the daemon. Verify with docker run --gpus all ... or nerdctl run --gpus all ....
Systemd cgroup driver issueContainers lose GPU access after systemctl daemon-reloadRefer to NVIDIA Container Toolkit troubleshooting documentation for specific workarounds related to systemd cgroup drivers.
Missing prerequisites for repository setupPackage installation fails with dependency errorsEnsure curl, gnupg2, ca-certificates (for apt) or curl (for dnf) are installed before adding the repository.

Summary / Key Takeaways

  • Proper NVIDIA GPU driver installation is paramount for ML workloads.
  • The NVIDIA Container Toolkit enables GPU access within containers.
  • Always use your distribution’s package manager for installations.
  • Configure your container runtime to recognize the NVIDIA Container Runtime.
  • Restarting the container daemon applies the new configuration.
  • Ensure compatibility between drivers, toolkit, and container runtime.

Conclusion

Successfully setting up your NVIDIA GPU driver and Container Toolkit is a foundational step for any serious ML or AI development. By following these steps, you ensure that your hardware investment is fully leveraged, leading to faster iteration cycles, more efficient model training, and ultimately, a better return on your technology CapEx. This configuration is essential for unlocking the full potential of modern AI development within a containerized ecosystem.


Note: This guide provides technical instructions for setting up NVIDIA GPU drivers and the Container Toolkit. It is not financial or investment advice. Consult with a qualified IT professional or financial advisor for specific hardware acquisition or tax deduction strategies relevant to your jurisdiction and business needs.

Source: Set up GPU infrastructure for ML workloads by NVIDIA Container Toolkit

Steps at a glance

  1. Step 1: Install NVIDIA GPU Driver

    Install the NVIDIA GPU driver for your Linux distribution using the package manager or a .run installer. This is the foundational step for enabling GPU acceleration.

  2. Step 2: Configure Production Repository

    Add the NVIDIA Container Toolkit repository to your system's package manager (apt, dnf, or zypper). This ensures you can install the correct toolkit version.

  3. Step 3: Install NVIDIA Container Toolkit

    Install the NVIDIA Container Toolkit packages using your distribution's package manager. This enables container runtimes to access NVIDIA GPUs.

  4. Step 4: Configure Container Runtime

    Configure your chosen container runtime (Docker, containerd, CRI-O) to use the NVIDIA Container Runtime. This step is critical for enabling GPU passthrough to containers.

  5. Step 5: Restart Container Daemon

    Restart the container daemon (e.g., Docker, containerd) to apply the new configuration. This ensures the runtime recognizes the NVIDIA Container Runtime.

Frequently Asked Questions

What is the NVIDIA Container Toolkit?

The NVIDIA Container Toolkit is a set of tools and libraries that allows container runtimes (like Docker, containerd, CRI-O) to access NVIDIA GPUs. It ensures that containerized applications can leverage GPU acceleration.

Why is installing the NVIDIA GPU driver important?

The NVIDIA GPU driver is the essential software layer that allows the operating system and applications to communicate with and control the NVIDIA GPU hardware. Without it, the GPU cannot be used for computation.

Can I install the NVIDIA Container Toolkit without root privileges?

Yes, for certain container runtimes like Docker in rootless mode or nerdctl, you can configure the NVIDIA Container Toolkit without root privileges by following specific instructions for those environments.

What are the financial benefits of setting up GPU access in containers?

Proper setup ensures your expensive GPU hardware is fully utilized, reducing ML model training times and inference latency. This translates to lower operational costs, faster time-to-market for AI products, and a better return on hardware investment.

What happens if I don't configure the container runtime correctly?

If the container runtime is not configured correctly, your containers will not be able to detect or use the NVIDIA GPUs. This leads to ML workloads running on the CPU, significantly increasing processing time and costs.

Which Linux distributions are supported by the NVIDIA Container Toolkit?

The NVIDIA Container Toolkit supports a wide range of popular Linux distributions, including Ubuntu, Debian, RHEL, CentOS, Fedora, OpenSUSE, and SLE. Specific installation instructions vary slightly by distribution.

Recommended Products

View All →

Affiliate Disclosure: This post contains affiliate links. We may earn a commission if you make a purchase.