Integrating a GPU into a Kubernetes platform with AI use cases
- GPUs, designed for 3D graphics, excel in the parallel computations of AI.
- Principle of supporting a GPU under Kubernetes.
- Test environment and practical implementation on a node equipped with a GPU.
- Deploying an AI application using the GPU from a pod.
Introduction
After the cryptocurrency mining hype of 2021, GPUs (Graphical Processing Units), which are associated with graphics cards, now have another reason to be sold in batches of a thousand: AI.
Originally, GPUs were designed to bring life to the 3D universes of our video games, but they are now used for many other purposes.
Their architecture, optimized for massively parallel computations, is particularly effective for processing matrix and vector operations.
This type of mathematical manipulation is used in some AI algorithms, particularly the well-known Large Language Models (LLMs), which are behind the success of current ChatGPT-like systems.
GPUs are far superior to our CPUs (Central Processing Units) when it comes to performing the same kind of simple calculation simultaneously on a large dataset of the same type.
Click the image to enlarge.
This is very convenient, because for LLM models, we have this kind of need, and it happens in two phases:
- Training phase: This is the most resource-intensive phase, requiring a lot of computation as the algorithm creates a model from a huge amount of data.
- Query or inference phase: based on the model created in the previous phase, the goal is to generate predictions (or answers) when the user makes a request.
For the first phase, it can be complex to design a model with traditional hardware.
Everything will depend on the type of data used and the objective of the model, but for cases like ChatGPT, which aims to be a general-purpose model, the necessary computing power is enormous.
Thousands of GPUs will be required, and not just any GPUs. Not all GPUs have the same performance, and for models like chatGPT, the training phase requires very high-end, specialized GPUs optimized for AI… with very high acquisition costs and significant energy consumption.
For the second phase, it becomes possible to make this more accessible. The required power will be related to the models used, but also to the number of requests it needs to handle. Of course, for ChatGPT, we are still talking about industrial proportions, as millions of users around the world are constantly using the model.
In the case of offline use, where the model is present locally and only a few people are using it at the same time, it becomes possible to use much more reasonable hardware.
In a previous article, I described the use of open-source products Ollama and OpenWebUI to benefit from a private chatGPT-like system, capable of using different pre-trained models that are available for free.
Click the image to enlarge.
The results were positive with a deployment under Kubernetes on a physical node. However, performance is not great, because my server relies only on a CPU and has a very modest configuration.
I decided to move up a gear and take advantage of this use case to detail the installation and support for a GPU by Kubernetes.
Since version 1.26 of K8S, it is possible to expose one or more GPUs from your server to the pods running on the cluster.
But as usual, the integration of GPUs by Kubernetes is done in a modular way and relies on third-party components.
Principles of using a GPU under K8S
Click the image to enlarge.
To use a GPU in a pod, it is necessary to meet the following criteria:
- Have a version of Kubernetes that is greater than or equal to 1.26. Ideally, prefer a release that is at least v1.29, as many improvements have been made. If you don't know how to upgrade K8S, feel free to take a look here.
- Having a compatible graphics card is essential. This list is constantly evolving, but forget about GPUs integrated into the CPU. You need a dedicated GPU and, most importantly, one with at least 8GB of VRAM (Video RAM, the memory on the card dedicated to the GPU) if you want to experiment with LLMs. Supported manufacturers are AMD, INTEL and NVIDIA. The latter is currently the market leader, so I would recommend a model from that brand, at least of the RTX 20 series. However, the other listed manufacturers also work.
- Install the driver for your graphics card on the operating system hosting the K8S node.
- Install the graphics card driver related to the runtime you are using to run your containers. If you want to learn more about the concept of a runtime, you can find out more here.
- Deploy the Kubernetes operator associated with your graphics card.
In summary, your graphics card must be recognized by your system (your OS), and then by your container engine so that it can expose your GPU. This will allow the operator (this concept is explained in more detail later in this article) deployed on Kubernetes to authorize its declaration and detection within the pods.
Your GPU or GPUs will be treated within Kubernetes as a simple resource, just like the CPU and memory that you can assign to your pods.
Test environment
In my case, my setup is as follows:
A physical server named prdk8sctp001, running Rocky Linux 9.5, with a Ryzen AMD Ryzen 9 7900X CPU, 96 GB of RAM, and an NVIDIA 3060 graphics card with 12 GB of VRAM.
Click the image to enlarge.
This server constitutes a single Kubernetes platform that is separate from my classic multi-node cluster, the installation of which I describe here.
This allows me to test a specific K8S configuration without impacting my main cluster.
The version of K8S is v1.31.3.
Click the image to enlarge.
This server serves as both the control plane and a worker node. This sometimes requires me to use the following toleration to allow components to run on the server.
spec:
tolerations:
- key: "node-role.kubernetes.io/control-plane"
operator: "Exists"
effect: "NoSchedule"
- key: "node-role.kubernetes.io/master"
operator: "Exists"
effect: "NoSchedule"
By default, Kubernetes places a taint on a control plane to prevent application containers from running on it, because in a production environment, the control plane is reserved for cluster administration and control.
Click the image to enlarge.
However, for testing environments, it's not uncommon to have only one server that needs to perform multiple roles.
In this case, I don't recommend removing the taint from the control plane, but rather using the toleration mentioned above to explicitly allow your resources to run on the control plane.
Regarding the CNI (Container Network Interface), I am still using Cilium. I won't go into detail here; you can find more information here. I simply had to adapt its deployment to a single-node configuration.
For those interested in installing Cilium on a K8S platform with only one server acting as both the control plane and worker, here is the cilium-values.yaml Helm chart used:
kubeProxyReplacement: true
k8sServiceHost: 192.168.10.160
k8sServicePort: 6443
ipam:
mode: "cluster-pool"
operator:
clusterPoolIPv4PodCIDRList:
- "10.13.0.0/16"
hubble:
relay:
enabled: true
ui:
enabled: true
frontend:
server:
ipv6:
enabled: false
tls:
auto:
enabled: true
method: helm
certValidityDuration: 1095
operator:
replicas: 1
The installation via Helm uses the following command:
helm install --version X.XX.X \
--namespace=kube-system cilium cilium/cilium \
--values=./cilium-values.yaml \
--set hubble.relay.tolerations[0].key="node-role.kubernetes.io/control-plane" \
--set hubble.relay.tolerations[0].operator="Exists" \
--set hubble.relay.tolerations[0].effect="NoSchedule" \
--set hubble.relay.tolerations[1].key="node-role.kubernetes.io/master" \
--set hubble.relay.tolerations[1].operator="Exists" \
--set hubble.relay.tolerations[1].effect="NoSchedule" \
--set hubble.ui.tolerations[0].key="node-role.kubernetes.io/control-plane" \
--set hubble.ui.tolerations[0].operator="Exists" \
--set hubble.ui.tolerations[0].effect="NoSchedule" \
--set hubble.ui.tolerations[1].key="node-role.kubernetes.io/master" \
--set hubble.ui.tolerations[1].operator="Exists" \
--set hubble.ui.tolerations[1].effect="NoSchedule"
This is off-topic, but it might still be useful.
For the CSI (Container Storage Interface), since I'm not using a virtual vSphere platform like my main cluster, I haven't used anything other than the NFS CSI. Again, I encourage you to find out more here.
However, I created three local Storage Class (sc)s to take advantage of the SSDs that I have installed on the server, which are an NVME SSD and two SATA SSDs, each associated with a storage class.
I detail the use of a local sc in the article where I add a physical node to my production cluster in the case of the first Ollama test. Feel free to read it.
Practical implementation
Now that the setup is complete, we can get started. Since I'm working with an NVIDIA graphics card, the deployment will inevitably be associated with the brand's ecosystem.
For those who have a GPU from another manufacturer, you can use the overall logic of this article as inspiration, but you will need to follow the instructions specific to your graphics card model provided by your manufacturer.
Installing the driver on the OS
To get started, we install the NVIDIA driver on Rocky Linux 9. You can act as root directly or use the sudo command, but you need the associated permissions. We begin by enabling the EPEL (Extra Packages for Enterprise Linux) repositories.
Simply run the following commands:
dnf config-manager --set-enabled crb
Click the image to enlarge.
dnf install \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm \
https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-9.noarch.rpm
Click the image to enlarge.
Next, we will also add the NVIDIA repositories. Use the following command:
dnf config-manager --add-repo http://developer.download.nvidia.com/compute/cuda/repos/rhel9/$(uname -i)/cuda-rhel9.repo
Click the image to enlarge.
It is necessary to compile some sources, so you need to retrieve all the associated dependencies for compilation. You can use the following commands:
dnf install kernel-headers-$(uname -r) kernel-devel-$(uname -r) tar bzip2 make automake gcc gcc-c++ pciutils elfutils-libelf-devel libglvnd-opengl libglvnd-glx libglvnd-devel acpid pkgconfig dkms
Click the image to enlarge.
Finally, you can install the NVIDIA driver with the following command:
dnf module install nvidia-driver:latest-dkms
Click the image to enlarge.
Once the operation is complete, you must restart the server.
If everything is OK, you should now be able to use the nvidia-smi command. This provides information about the GPU status and its instantaneous power consumption.
Click the image to enlarge.
Since the card is recognized by the operating system, we can proceed with integration into the container runtime.
Configuring containerd
As with my main cluster, I use containerd. Be aware that, as of the time of writing this article, you cannot use branch 2 because it is not compatible with NVIDIA. Therefore, I have deployed version 1.7.24. For more information about containerd, feel free to visit this page.
NVIDIA provides a fairly comprehensive guide for integrating its components into a K8S cluster.
We will therefore follow this guide and start by adding an additional repository.
This repository will allow you to install the nvidia-container-toolkit dependency using the following commands:
curl -s -L https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo | \
sudo tee /etc/yum.repos.d/nvidia-container-toolkit.repo
dnf install -y nvidia-container-toolkit
Click the image to enlarge.
Click the image to enlarge.
Once installed, you can run the command nvidia-ctk runtime configure --runtime=containerd (still as root).
Click the image to enlarge.
This will modify the containerd configuration to include settings specific to NVIDIA card support.
You can identify these in the configuration file /etc/containerd/config.toml.
Click the image to enlarge.
For it to take effect, you must restart the containerd service (systemctl restart containerd).
Installing the NVIDIA Operator for Kubernetes
Next, we deploy the gpu-operator on the cluster. An operator combines Custom Resource Definitions (CRDs), which are extensions of the default K8S API, and a controller that manages the resources generated from these Custom Resource Definitions.
This automates the management of new objects that extend the capabilities of the cluster.
On the NVIDIA side, you will also hear about the Device Plugin For Kubernetes. This is the minimum requirement for K8S to recognize NVIDIA GPUs, but it is recommended to use the operator, which integrates the deployment of the Device Plugin and simplifies the configuration of the entire system.
To install the gpu-operator, you can use helm (as a reminder, helm is a package manager for K8S; I discuss it in this article).
Add the helm repository:
helm repo add nvidia https://helm.ngc.nvidia.com/nvidia && helm repo update
Click the image to enlarge.
Create the namespace that will host the controller and other associated pods:
kubectl create ns gpu-operator
Click the image to enlarge.
Then, run the deployment command.
helm install --wait --generate-name \
-n gpu-operator \
nvidia/gpu-operator \
--version=v24.9.1 \
--values=./gpu-values.yaml

Click the image to enlarge.
You will notice that I have provided a values file called gpu-values.yaml, in addition to the basic parameters.
The content is as follows:
daemonsets:
tolerations:
- key: "node-role.kubernetes.io/master"
operator: "Equal"
value: ""
effect: "NoSchedule"
- key: "node-role.kubernetes.io/control-plane"
operator: "Equal"
value: ""
effect: "NoSchedule"
- key: nvidia.com/gpu
operator: Exists
effect: NoSchedule
node-feature-discovery:
gc:
tolerations:
- key: "node-role.kubernetes.io/master"
operator: "Equal"
value: ""
effect: "NoSchedule"
- key: "node-role.kubernetes.io/control-plane"
operator: "Equal"
value: ""
effect: "NoSchedule"
- key: nvidia.com/gpu
operator: Exists
effect: NoSchedule
It is necessary because I am only using one node for this particular K8S cluster. As mentioned at the beginning of the article, I need to allow the execution of pods on the control plane.
Testing and deploying an application
Basic test
At this stage, you can check the deployment using the command kubectl get pod -n gpu-operator.
Now, we need to see if it works.
To do this, NVIDIA provides a small test pod called cuda-vectoradd, which is designed to execute a command on the GPU.
Here is the associated YAML file: cuda-vectoradd.yaml
apiVersion: v1
kind: Pod
metadata:
name: cuda-vectoradd
spec:
restartPolicy: OnFailure
tolerations:
- key: "node-role.kubernetes.io/control-plane"
operator: "Exists"
effect: "NoSchedule"
- key: "node-role.kubernetes.io/master"
operator: "Exists"
effect: "NoSchedule"
containers:
- name: cuda-vectoradd
image: "nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda11.7.1-ubuntu20.04"
resources:
limits:
nvidia.com/gpu: 1
Compared to what NVIDIA provides, I have simply added the toleration for execution on a control plane.
Otherwise, the most interesting part is the field:
resources:
limits:
nvidia.com/gpu: 1
This is where you map the GPU to the pod (in the case of an AMD GPU, the syntax is almost the same: amd.com/gpu: 1).
This indicates that we are allowing the pod to request 1 GPU (in this case, I don't have any more for the demo).
Run the pod with the command kubectl apply -f cuda-vectoradd.yaml.
Click the image to enlarge.
The pod finishes very quickly, but you can view its logs using the command kubectl logs cuda-vectoradd (the demo is run in the default namespace).
Good news, the test was successful.
Click the image to enlarge.
But let's see if we can do more tests.
Advanced test
To do this, I will use the tool gpu-burn. This is a simple benchmark that allows you to stress your GPU under Linux.
By integrating its retrieval, compilation, and execution into a pod, we should be able to observe a load on the graphics card.
Here is the content of the file demo-gpu.yaml that I am using (thank you ChatGPT):
apiVersion: v1
kind: Pod
metadata:
name: gpu-burn
spec:
restartPolicy: OnFailure
tolerations:
- key: "node-role.kubernetes.io/control-plane"
operator: "Exists"
effect: "NoSchedule"
- key: "node-role.kubernetes.io/master"
operator: "Exists"
effect: "NoSchedule"
containers:
- name: gpu-burn
image: "nvidia/cuda:11.7.1-devel-ubuntu20.04" # Image CUDA de développement
command: ["/bin/bash", "-c"]
args:
- |
# Mettre à jour le système et installer git, make et gcc
apt-get update && apt-get install -y git make gcc && \
# Cloner gpu-burn et compiler
git clone https://github.com/wilicc/gpu-burn.git && \
cd gpu-burn && make && \
# Exécuter gpu-burn pendant 60 secondes
./gpu_burn 60 && \
echo "GPU burn test completed successfully" && sleep 3600
resources:
limits:
nvidia.com/gpu: 1 # Alloue une GPU NVIDIA
As with the NVIDIA test, I use the instruction nvidia.com/gpu: 1.
Now that the NVIDIA pod is finished, it is once again possible to mount the GPU in this new pod (kubectl apply -f demo-gpu.yaml).
The last instruction in the pod's arguments launches gpu-burn for 60 seconds.
Click the image to enlarge.
This is sufficient so that once the pod is started, you can use the nvidia-smi command and see that the GPU is indeed being used by GPU Burn.
Click the image to enlarge.
If you want to know more, you can deploy the tool nvtop, (available in the EPEL repositories: dnf install nvtop).
This small tool allows you to see live usage of your GPUs.
When you run it while the pod gpu-burn is still active, you can see that the NVIDIA GPU is being used.
Click the image to enlarge.
Deployment of Ollama and OpenWebUI
Now it's time to perform the final test, with Ollama and OpenWebUI.
I will not go into detail about the deployment of these two tools; everything is presented and explained here.
I will reuse exactly the same playbooks as for my first experiment, on a salvaged physical server with no GPU. Only the namespace and a few storage-related parameters will change.
However, I will list the YAML files used.
Deployment of the PV dedicated to Ollama. It requires performance, so I am using my NVME disk with its storage class local sc-local-storage-prddtsnme001:
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-ollama-default
labels:
environment: prd
network: lan
application: mygpt
tier: ollama
spec:
capacity:
storage: 250Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: sc-local-storage-prddtsnme001
local:
path: /mnt/datastores/prddtsnme001/localpv/prd-mygptgpu-lan/pv-ollama-default
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- prdk8sctp001
We continue with the PVC:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-ollama-default
namespace: prd-mygptgpu-lan
labels:
environment: prd
network: lan
application: mygpt
tier: ollama
spec:
accessModes:
- ReadWriteOnce
storageClassName: sc-local-storage-prddtsnme001
resources:
requests:
storage: 250Gi
Then the deployment of Ollama:
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-ollama-default
namespace: prd-mygptgpu-lan
labels:
environment: prd
network: lan
application: mygpt
tier: ollama
spec:
replicas: 1
selector:
matchLabels:
environment: prd
network: lan
application: mygpt
tier: ollama
template:
metadata:
labels:
environment: prd
network: lan
application: mygpt
tier: ollama
spec:
tolerations:
- key: "node-role.kubernetes.io/control-plane"
operator: "Exists"
effect: "NoSchedule"
containers:
- name: ollama
image: ollama/ollama:0.5.1
resources:
limits:
nvidia.com/gpu: 1
ports:
- containerPort: 11434
volumeMounts:
- name: pv-ollama-default
mountPath: "/root"
volumes:
- name: pv-ollama-default
persistentVolumeClaim:
claimName: pvc-ollama-default
Here, we remember to include the toleration to allow execution on the control plane and, most importantly, declare the GPU usage.
Next, we have the service to expose Ollama within the cluster.
---
kind: Service
apiVersion: v1
metadata:
name: svc-ollama-default
namespace: prd-mygptgpu-lan
labels:
environment: prd
network: lan
application: mygpt
tier: ollama
spec:
ports:
- name: ollama
port: 11434
protocol: TCP
targetPort: 11434
selector:
environment: prd
network: lan
application: mygpt
tier: ollama
Then we declare the PV for OpenWebUI. In this case, a simple NFS volume via the associated CSI is sufficient.
---
apiVersion: v1
kind: PersistentVolume
metadata:
annotations:
pv.kubernetes.io/provisioned-by: nfs.csi.k8s.io
name: pv-openwebui-default
labels:
environment: prd
network: lan
application: mygpt
tier: openwebui
spec:
capacity:
storage: 30Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
csi:
driver: nfs.csi.k8s.io
volumeHandle: /Volume1/nfsshare/rubikub.coolcorp.priv/namespaces/prd-mygptgpu-lan/openwebui
volumeAttributes:
server: 192.168.10.152
share: /Volume1/nfsshare/rubikub.coolcorp.priv/namespaces/prd-mygptgpu-lan/openwebui
This PV is used by the PVC that follows.
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-openwebui-default
namespace: prd-mygptgpu-lan
labels:
environment: prd
network: lan
application: mygpt
tier: openwebui
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 30Gi
volumeName: pv-openwebui-default
Next, we have the OpenWebUI deployment, still with the appropriate toleration. No GPU is needed here since it's the web interface.
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-openwebui-default
namespace: prd-mygptgpu-lan
labels:
environment: prd
network: lan
application: mygpt
tier: openwebui
spec:
replicas: 1
selector:
matchLabels:
environment: prd
network: lan
application: mygpt
tier: openwebui
template:
metadata:
labels:
environment: prd
network: lan
application: mygpt
tier: openwebui
spec:
tolerations:
- key: "node-role.kubernetes.io/control-plane"
operator: "Exists"
effect: "NoSchedule"
containers:
- name: open-webui
image: ghcr.io/open-webui/open-webui:main
ports:
- containerPort: 8080
volumeMounts:
- name: pv-openwebui-default
mountPath: "/app/backend/data"
env:
- name: OLLAMA_BASE_URL
value: "http://svc-ollama-default:11434"
volumes:
- name: pv-openwebui-default
persistentVolumeClaim:
claimName: pvc-openwebui-default
We expose OpenWebUI internally using the following service:
---
kind: Service
apiVersion: v1
metadata:
name: svc-openwebui-default
namespace: prd-mygptgpu-lan
labels:
environment: prd
network: lan
application: mygpt
tier: openwebui
spec:
ports:
- name: openwebui
port: 8080
protocol: TCP
targetPort: 8080
selector:
environment: prd
network: lan
application: mygpt
tier: openwebui
This service will be opened to the outside via the ingress and the use of traefik, which will handle connections on the URL https://mygptgpu.coolcorp.priv/ (with a nice certificate that we have taken care to put in a secret).
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ing-openwebui-default
namespace: prd-mygptgpu-lan
labels:
environment: prd
network: lan
application: mygpt
tier: openwebui
annotations:
traefik.ingress.kubernetes.io/router.entrypoints: web,websecure
ingressClassName: traefik-lan
traefik.ingress.kubernetes.io/router.tls: "true"
spec:
ingressClassName: traefik-lan
tls:
- hosts:
- mygptgpu.coolcorp.priv
secretName: secret-certificate-mygptgpu
rules:
- host: mygptgpu.coolcorp.priv
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: svc-openwebui-default
port:
number: 8080
I will not go into further detail; again, feel free to browse my first article on the subject.
That first article allowed me to run Ollama and OpenWebUI on a server without a GPU, which I can still reach at the URL https://mygpu.coolcorp.priv.
I will therefore be able to compare the two instances.
To do this, I need to retrieve the same LLM model.
I will choose llama3.2.
This is a model based on 3 billion parameters. The higher this number, the more powerful the model normally is... but the more resources it requires for both training and inference.
For inference, the amount of VRAM in the graphics card is a very important factor. The model needs to store its parameters within the VRAM. Traditional RAM is too slow for this purpose.
The number of parameters is increasing rapidly as LLMs evolve. For example, the first GPT-1 model used 117 million parameters, GPT-3 used 175 billion... and GPT-4 reportedly uses trillions.
Click the image to enlarge.
The more parameters a model has, the more VRAM is required to achieve a correct response time during the inference phase. This determines the number of tokens (words) that can be processed simultaneously when querying the model.
There are charts available that show the amount of VRAM needed in relation to the LLM model used.
Feel free to visit this website https://unfoldai for more details and to learn how the VRAM requirement is calculated based on the chosen model.
Fortunately, a model's efficiency does not follow a linear relationship proportional to the number of parameters.
Certainly, the more parameters a model has, the more powerful it is, but as you increase these parameters, the gain becomes increasingly smaller... this is one of the current limitations of generative AI.
It turns out that while initially increasing the number of parameters led to enormous improvements in LLM models, we are starting to lose efficiency as the number of parameters increases.
Furthermore, some models do not necessarily aim to be the best and able to answer everything, but rather seek to be as optimized as possible, being able to handle the most common requests with a smaller digital footprint.
This is what made the MistralAI models so successful. They gained recognition by offering models with a lower number of parameters, but which are nonetheless just as performant for the majority of cases as larger models.
In my server, I have a graphics card with 12 GB of VRAM. Therefore, based on the information I've found, I can aim for a model with 3 billion parameters, such as Facebook Llama 3.2 (also available with 1 billion parameters).
I then go to each of my Ollama instances and enter the containers' execution context (kubectl exec -it nom_du_pod -n nom_namespace -- bash).
Click the image to enlarge.
In both cases, I run the command ollama pull llama3.2 to retrieve the model (more information here).
Click the image to enlarge.
This way, the model can be selected in the OpenWebUI interface.
Click the image to enlarge.
I will now be able to ask the same question on the instance with and without a GPU.
The difference is significant. The instance with the GPU responds much faster to requests for the model.
Click the image to enlarge.
When we look at the resources consumed during the tests, we see that on the server with the instance without a GPU, the CPU is working at full capacity, while on the instance with the GPU, the CPU is less stressed, whereas the GPU is being effectively utilized.
Click the image to enlarge.
We can also see the GPU utilization using the same tools as in our previous tests.
Click the image to enlarge.
If I disable the use of the GPU on my server prdk8sctp001, by removing the line nvidia.com/gpu: 1 from the pod.
When I restart the pod and request the model again, we see a degradation in performance. This is certainly less than on my instance without a GPU, because I have a more recent CPU on this new physical server, but we lose the smoothness observed during the initial requests with the GPU.
Click the image to enlarge.
If I try another model, such as llama3.3, even with the GPU active in the pod, the performance is catastrophic.
Click the image to enlarge.
This is due to the 70 billion parameters of this model, which are far too large for the VRAM and processing power of my poor NVIDIA 3060.
Another important point: since I only have one GPU (the GPU integrated into the CPU cannot be used), once it is assigned to a pod, it is no longer available to others. This is a problem today because even if the application hosted within the pod does not need the resources of the GPU at a given time, it is still unavailable to other pods.
However, there is the concept of MIG (Multi Instance GPU), which allows you to partition a GPU into "sub-GPUs" that can be declared in multiple pods. But this feature is reserved for professional cards such as the NVIDIA A100, which supports 7 "sub-GPUs", allowing you to parallelize the use of a card between multiple pods.
Conclusion
Thanks to its modular approach and constant evolution, Kubernetes has been able to adapt to market demands by integrating GPU management into its orchestration service. The main graphics card manufacturers have been able to offer their extensions and make their cards compatible with Kubernetes.
The downside is that, once again, achieving a result requires installing several components that you will need to maintain over time and update regularly.
This complexity will inevitably be reduced when using a managed service, where some offerings include GPU support by default, but you will still need to use the command-line interface (CLI) in certain cases.
I have only shown one example here for the use of LLMs (and following the current trend...), but GPUs can enable many other things.
In the context of LLMs, it is clear that a GPU offers an advantage over a CPU... provided you have hardware that is proportionally adapted to the complexity of the model being used.
In the coming months, we may see other components emerge, such as the famous NPUs for Neural Processing Units, which are already in use in some configurations. These dedicated processors should enable extremely interesting performance levels for inference at much lower energy costs than a GPU due to their specialization.
As with GPUs, NPUs can be used by K8S thanks to the Device Plugins, which ultimately serves as the basis for integrating all new hardware components into a cluster.
It will all depend on the manufacturers of these chips, who will need to provide dedicated operators and enable support for their product in Kubernetes.
Note that integration will first have to happen at the container runtime level, since Kubernetes remains an orchestrator.
It will be very interesting to watch this develop, and it will come with its share of challenges, particularly for monitoring, observability and resource management. We already had to track memory, CPU, disk and network bandwidth... now GPU and NPU graphs will have to be added to the monitoring dashboards 😊.