<p>There is this kubernetes cluster with n number of nodes where some of the nodes are fitted with multiple NVIDIA 1080Ti GPU cards on it. </p>

<p>I have two kind of pods
1. GPU enabled, these need to be scheduled on GPU fitted nodes where pod will only use one of the GPU cards present on that node.
2. CPU only, now these can be scheduled anywhere, preferably on CPU only nodes.</p>

<p>Scheduling problem is addressed clearly <a href="https://stackoverflow.com/questions/53859237/kubernetes-scheduling-for-expensive-resources">in this</a> answer.</p>

<p>Issue:
When scheduling a GPU-enabled pod on a GPU fitted node I want to be able decide on which GPU card among those multiple GPU cards my pod is going to use. Further, I was thinking of a loadbalancer sitting transparently b/w GPU hardware and pods that will decide the mapping.</p>

<p>Any help around this architecture would be deeply appreciated. Thank you!</p>

Schrodinger
<p>You have to use <a href="https://github.com/NVIDIA/k8s-device-plugin" rel="nofollow noreferrer">Official NVIDIA GPU device plugin</a> rather than suggested by GCE. There's possibility to schedule GPUs by attributes</p>

<p>Pods can specify device selectors based on the attributes that are advertised on the node. These can be specified at the container level. For example:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: gpu-pod
spec:
  containers:
    - name: cuda-container
      image: nvidia/cuda:9.0-base
      command: ["sleep"]
      args: ["100000"]
      computeResourceRequests: ["nvidia-gpu"]
  computeResources:
    - name: "nvidia-gpu"
      resources:
        limits:
          nvidia.com/gpu: 1
      affinity:
        required:
          - key: "nvidia.com/gpu-memory"
            operator: "Gt"
            values: ["8000"] # change value to appropriate mem for GPU
</code></pre>

<p>Check Kubernetes on NVIDIA GPUs <a href="https://docs.nvidia.com/datacenter/kubernetes/kubernetes-install-guide/index.html#abstract" rel="nofollow noreferrer">Installation Guide</a></p>

<p>Hope this will help</p>
