Skip to main content

API Reference - GPU

This reference details how to use GPUs on Hikube, whether with virtual machines (VMInstance) or managed Kubernetes clusters (Kubernetes).


๐ŸŽฎ Available GPUsโ€‹

GPUs are attached by their resource name (nvidia.com/<model>). The models available on Hikube:

GPUResource nameArchitectureMemoryTypical usage
L40Snvidia.com/AD102GL_L40SAda Lovelace48 GB GDDR6Inference, dev, rendering
A100 PCIe 80 GBnvidia.com/GA100_A100_PCIE_80GBAmpere80 GB HBM2eML training
A100 SXM4 80 GBnvidia.com/GA100_A100_SXM4_80GBAmpere80 GB HBM2eML training (multi-GPU NVLink)
RTX PRO 6000 Blackwellnvidia.com/GB202GL_RTX_PRO_6000_BLACKWELL_SERVER_EDITIONBlackwell96 GB GDDR7LLM, intensive computing
Availability

The available GPU hardware varies by zone. Check the allocatable resources on the platform side before planning a workload. The NVIDIA driver requires at least 4 GiB of RAM on the VM or worker.


๐Ÿ–ฅ๏ธ GPU with Virtual Machinesโ€‹

On a VM, the GPU is attached in PCI passthrough (exclusive allocation) via the gpus field of a VMInstance resource. The disk is defined separately by a VMDisk resource.

vm-gpu.yaml
apiVersion: apps.cozystack.io/v1alpha1
kind: VMInstance
metadata:
name: vm-gpu
spec:
runStrategy: Always
instanceProfile: ubuntu
instanceType: u1.xlarge
gpus:
- name: "nvidia.com/AD102GL_L40S"
disks:
- name: vm-gpu-disk
Common pitfalls
  • The resource is named VMInstance (not VirtualMachine).
  • The state is driven via runStrategy: Always (not running: true).
  • The disk is not a built-in systemDisk field: create a VMDisk resource and reference it in disks (a list of {name} objects).

GPU parameters for VMโ€‹

ParameterTypeDescriptionRequired
gpus[]objectList of GPUs to attachno
gpus[].namestringGPU resource name (nvidia.com/...)yes (if gpus is set)

Complete GPU VM exampleโ€‹

ai-workstation.yaml
apiVersion: apps.cozystack.io/v1alpha1
kind: VMDisk
metadata:
name: ai-workstation-disk
spec:
source:
image:
name: ubuntu-2404
storage: 200Gi
storageClass: replicated
---
apiVersion: apps.cozystack.io/v1alpha1
kind: VMInstance
metadata:
name: ai-workstation
spec:
runStrategy: Always
instanceProfile: ubuntu
instanceType: u1.2xlarge # 8 vCPU, 32 GB RAM
gpus:
- name: "nvidia.com/GA100_A100_PCIE_80GB"
disks:
- name: ai-workstation-disk
external: true
externalMethod: PortList
externalPorts:
- 22
- 8888 # Jupyter
cloudInit: |
#cloud-config
users:
- name: ubuntu
sudo: ALL=(ALL) NOPASSWD:ALL
packages:
- python3-pip
- build-essential
runcmd:
# NVIDIA drivers + CUDA (see the dedicated guide for the exact version)
- wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb
- dpkg -i cuda-keyring_1.1-1_all.deb
- apt-get update
- apt-get install -y cuda-toolkit nvidia-driver-570
# PyTorch with CUDA
- pip3 install torch torchvision

Multi-GPU on VMโ€‹

spec:
instanceType: u1.8xlarge # 32 vCPU, 128 GB RAM
gpus:
- name: "nvidia.com/GA100_A100_SXM4_80GB"
- name: "nvidia.com/GA100_A100_SXM4_80GB"
- name: "nvidia.com/GA100_A100_SXM4_80GB"
- name: "nvidia.com/GA100_A100_SXM4_80GB"

โ˜ธ๏ธ GPU with Kubernetesโ€‹

On a managed Kubernetes cluster, GPUs are attached to the node groups, and the gpuOperator addon must be enabled to expose the GPUs to pods.

cluster-gpu.yaml
apiVersion: apps.cozystack.io/v1alpha1
kind: Kubernetes
metadata:
name: cluster-gpu
spec:
controlPlane:
replicas: 2

nodeGroups:
gpu-workers:
minReplicas: 1
maxReplicas: 5
instanceType: "u1.xlarge"
ephemeralStorage: 100Gi
gpus:
- name: "nvidia.com/AD102GL_L40S"

addons:
# Required: installs the NVIDIA drivers and the device plugin
gpuOperator:
enabled: true
gpuOperator addon required

Without gpuOperator: enabled: true, the workers' GPUs are not exposed to pods (nvidia.com/gpu stays at 0).

GPU parameters for NodeGroupsโ€‹

ParameterTypeDescriptionRequired
nodeGroups.<name>.gpus[]objectGPUs attached to the group's workersno
gpus[].namestringGPU resource name (nvidia.com/...)yes (if gpus is set)
addons.gpuOperator.enabledbooleanEnables the NVIDIA GPU Operatoryes (to use the GPUs)

Multi-GPU configuration per workerโ€‹

nodeGroups:
gpu-intensive:
minReplicas: 1
maxReplicas: 2
instanceType: "u1.4xlarge" # 16 vCPU, 64 GB RAM
gpus:
- name: "nvidia.com/GA100_A100_SXM4_80GB"
- name: "nvidia.com/GA100_A100_SXM4_80GB"
- name: "nvidia.com/GA100_A100_SXM4_80GB"
- name: "nvidia.com/GA100_A100_SXM4_80GB"

Usage in Podsโ€‹

Once gpuOperator is active, pods reserve GPUs via the nvidia.com/gpu resource:

ml-training.yaml
apiVersion: v1
kind: Pod
metadata:
name: ml-training
spec:
containers:
- name: trainer
image: pytorch/pytorch:2.4.1-cuda12.4-cudnn9-runtime
resources:
limits:
nvidia.com/gpu: 1
requests:
nvidia.com/gpu: 1
command: ["python", "train.py"]

๐Ÿ“‹ VM GPU vs Kubernetes GPUโ€‹

AspectVM GPUKubernetes GPU
Allocation1 GPU = 1 VM (exclusive passthrough)1+ GPU per worker
IsolationComplete at VM levelNamespace / Pod
ScalingVertical (more GPUs)Horizontal + Vertical (autoscaling)
ManagementManual via VMInstanceOrchestrated by Kubernetes
SharingNoYes (between pods)
OverheadMinimalOrchestration overhead

VM GPU: non-containerized applications, direct GPU access, dev/prototyping, rendering/CAD.

Kubernetes GPU: containerized workloads, autoscaling, parallel/distributed jobs, ML/AI pipelines.


โœ… Verificationโ€‹

VM GPUโ€‹

virtctl ssh ubuntu@vm-gpu
nvidia-smi
nvidia-smi --query-gpu=name,memory.total,utilization.gpu --format=csv

Kubernetes GPUโ€‹

# GPUs exposed on the nodes (requires gpuOperator active)
kubectl get nodes -o custom-columns=NAME:.metadata.name,GPU:.status.allocatable.'nvidia\.com/gpu'

# Check from a pod
kubectl exec -it <pod-name> -- nvidia-smi

๐Ÿ’ก Best Practicesโ€‹

  • L40S for inference and development, A100 for ML training, RTX PRO 6000 (Blackwell) for the most demanding workloads.
  • Test with an L40S before reserving the most expensive GPUs.
  • Size CPU/RAM according to the GPU (โ‰ˆ 8โ€“16 vCPU per GPU) and plan for โ‰ฅ 4 GiB of RAM.
  • On VM: install the NVIDIA drivers via cloud-init (see Install CUDA drivers).
  • On Kubernetes: always enable the gpuOperator addon.
  • Use the replicated storageClass in production.