4. Create Pod and use IPU
You can access the IPU through the Kubernetes resource types, such as Deployment or Pod.
Create a configuration file: test.yaml:
- Kubernetes Pod example - apiVersion: v1 kind: Pod metadata: name: ipu-test-1 spec: containers: - name: demo-ipu-test image: graphcore/pytorch:latest command: ["/bin/bash", "-c", "--"] args: ["sleep infinity & wait"] resources: limits: c600.graphcore.ai/ipu: "1" # Number of IPUs allocated to the Pod - pod-test.yaml(rename to- test.yaml)
- Deployment example - apiVersion: apps/v1 kind: Deployment metadata: name: ipu-test namespace: default labels: app: app-test spec: replicas: 1 selector: matchLabels: app: app-test template: metadata: labels: app: app-test spec: containers: - name: demo-ipu-test image: graphcore/pytorch:latest command: ["/bin/bash", "-c", "--"] args: ["sleep infinity & wait"] resources: limits: c600.graphcore.ai/ipu: "1" - deployment-test.yaml(rename to- test.yaml)
The replica scaling and rollback functions of deployment are supported. Run the following command to create a Deployment or Pod:
$ kubectl apply -f test.yaml
The following command checks whether the Pod runs successfully. The expected output is shown:
$ kubectl get pod
NAME READY STATUS RESTARTS AGE
ipu-test-1 1/1 Running 0 4d
Run the following command again:
$ kubectl describe nodes
You will find that the number of allocated IPUs has changed from 0 to 1.
Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.)
  Resource Requests Limits
  -------- -------- ------
  cpu 1 (2%) 0 (0%)
  memory 140Mi (0%) 340Mi (0%)
  ephemeral-storage 0 (0%) 0 (0%)
  hugepages-1Gi 0 (0%) 0 (0%)
  hugepages-2Mi 0 (0%) 0 (0%)
  c600.graphcore.ai/ipu 1 1
 ...
This indicates that the Kubernetes cluster can schedule and use IPU devices with the Kubernetes IPU device plugin.