Orchestrate containers

Open in ClaudeOpen in ChatGPT

You are free to choose any orchestrator to manage the containers running the ZED SDK.

Below are examples for two popular orchestrators: Docker Compose and Kubernetes.

Docker Compose

Docker Compose is quick to set up. You just need to make sure that every Docker runtime parameter mentioned in the rest of this documentation is also present in your docker-compose.yaml file:

  • The privileged mode.
  • The nvidia runtime.
  • The NVIDIA_DRIVER_CAPABILITIES environment variable.
  • The shared volumes.

The runtime: nvidia key requires the Compose file format 2.3 (or 2.4), which is why the examples below use that version.

Once you have completed the setup, you are ready to go. You can try it out with the example service we provide.

USB camera example
version: '2.3'
services:
your_app:
image: <your-image>
runtime: nvidia
environment:
- NVIDIA_DRIVER_CAPABILITIES=all
privileged: true
volumes:
- /usr/local/zed/resources:/usr/local/zed/resources
- /usr/local/zed/settings:/usr/local/zed/settings
- /dev:/dev
GMSL2 camera example (ZED X, ZED X One)
version: '2.3'
services:
your_app:
image: <your-image>
runtime: nvidia
environment:
- NVIDIA_DRIVER_CAPABILITIES=all
privileged: true
volumes:
- /usr/local/zed/resources:/usr/local/zed/resources
- /usr/local/zed/settings:/usr/local/zed/settings
- /var/nvidia/nvcam/settings/:/var/nvidia/nvcam/settings/
- /etc/systemd/system/zed_x_daemon.service:/etc/systemd/system/zed_x_daemon.service
- /tmp/:/tmp/
- /dev:/dev

Kubernetes

To use Kubernetes, we recommend setting up a cluster with k3s. Adding NVIDIA® Container Runtime support to k3s takes a few steps, described here.

  • Make sure the NVIDIA container runtime is properly installed. You can check it in the /etc/docker/daemon.json file:
{
"default-runtime": "nvidia",
"runtimes": {
"nvidia": {
"args": [],
"path": "nvidia-container-runtime"
}
}
}
  • Add a RuntimeClass to your Kubernetes configuration:
apiVersion: node.k8s.io/v1
kind: RuntimeClass
metadata:
name: nvidia
handler: nvidia
  • Reference the runtime class in the target pod:
spec:
runtimeClassName: nvidia
  • You may also need to install the NVIDIA device plugin in your cluster (check the k8s-device-plugin repository for the latest release): sudo k3s kubectl create -f https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/v0.14.1/nvidia-device-plugin.yml

Once you have completed the setup, you are ready to go. You can try it out with the example pod we provide.

Example pod configuration file for USB cameras
apiVersion: apps/v1
kind: Deployment
metadata:
name: zed-sample
spec:
replicas: 1
selector:
matchLabels:
app: your-app
template:
metadata:
labels:
app: your-app
spec:
containers:
- name: your-container
image: <your_image>
securityContext:
privileged: true
env:
- name: NVIDIA_DRIVER_CAPABILITIES
value: "all"
volumeMounts:
- name: dev
mountPath: dev
command: ["tail", "-f", "/dev/null"]
resources:
limits:
nvidia.com/gpu: 1 # Assuming you want to allocate one GPU
requests:
nvidia.com/gpu: '1'
volumes:
- name: dev
hostPath:
path: /dev

For GMSL2 cameras, add the same additional shared volumes as before.