How to Install Nvidia GPU Drivers on K3s

If you’re running a K3s cluster and need to leverage Nvidia GPUs for AI or machine learning workloads, this guide will walk you through the installation and configuration process of Nvidia drivers for your Kubernetes environment.

1. Prerequisites

Ensure the following before proceeding:

  • A K3s cluster running on compatible nodes with Nvidia GPUs.
  • Access to the node’s terminal.

2. Installing Nvidia Drivers on the Node

sudo apt update
sudo apt install nvidia-driver-450 -y

3. Configuring K3s for GPU Access

To configure K3s to recognize GPUs, you need to install Nvidia’s device plugin:

kubectl apply -f https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/master/nvidia-device-plugin.yml

4. Verifying GPU Access

To verify that the GPU is accessible by K3s, run the following command:

kubectl get nodes -o json | jq '.items[] | {name:.metadata.name, gpus:.status.capacity.nvidia\.com/gpu}'