Skip to content

Instantly share code, notes, and snippets.

@Halliax
Last active February 24, 2020 21:59
Show Gist options
  • Select an option

  • Save Halliax/1f6e24009432d889545aa87b74420bb8 to your computer and use it in GitHub Desktop.

Select an option

Save Halliax/1f6e24009432d889545aa87b74420bb8 to your computer and use it in GitHub Desktop.
Simple working example of a k8s Deployment configured to run on the GPU nodes
apiVersion: apps/v1
kind: Deployment
metadata:
name: cuda-vector-add
labels:
app: cuda-vector-add
spec:
replicas: 3
selector:
matchLabels:
app: cuda-vector-add
template:
metadata:
labels:
app: cuda-vector-add
spec:
# requires pods to be run on an nvidia.com/gpu labeled node
nodeSelector:
nvidia.com/gpu: "true"
# allows pods to be run on an nvidia.com/gpu tainted node
tolerations:
- key: "nvidia.com/gpu"
operator: "Exists"
effect: "NoSchedule"
containers:
- name: cuda-vector-add
# https://github.com/kubernetes/kubernetes/blob/v1.7.11/test/images/nvidia-cuda/Dockerfile
image: "k8s.gcr.io/cuda-vector-add:v0.1"
resources:
# don't use requests for GPUs: https://kubernetes.io/docs/tasks/manage-gpus/scheduling-gpus/
limits:
nvidia.com/gpu: 1 # requesting 1 GPU
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment