L4T container with Docker Compose

Hi,

I am trying to build my custom docker image based on the l4t-base image provided by NGC. I am able to run cuda_sample with my Jeton AGX Xavier on a single container by specifying the –runtime nvidia flag in CLI. However, when I tied to use docker-compose to create a service based on the same l4t-base image, I was not able to run the application with the runtime flag added in my docker-compose.

docker-compose.yaml

version: ‘3’
services:
cuda:
image: hikariai/l4t-base:ssh
ports:
- ‘5554:22’
networks:
- tegra
logging:
driver: json-file
deploy:
replicas: 2
placement:
constraints:
- node.hostname == k3s-node-xavier
runtime: nvidia
environment:
- NVIDIA_VISIBLE_DEVICES=all
networks:
tegra:

CLI:

$ docker stack deploy -c docker-compose.yaml --resolve-image never tegra

Logs:

kev@k3s-node-xavier:tegra$ docker stack deploy -c docker-compose.yaml --resolve-image never tegra
runtime Additional property runtime is not allowed

I also find some useful information from https://devblogs.nvidia.com/gpu-containers-runtime/. It is using the docker-compose version: ‘2.3’. I wonder if it also supports docker-compose version: ‘3’ or above

Any idea of how to solve the issue?

Hi @kevinyu211, I’m not familiar with Docker Compose, but what if you set the default runtime to nvidia in your /etc/docker/daemon.conf file so that you didn’t need to set the --runtime command line argument?

See here: https://github.com/dusty-nv/jetson-containers#docker-default-runtime

I did. It worked fine when I used “docker run --runtime nvidia …”. However, it did not work in docker-compose.

Hi @kevinyu211, sorry for the delay - after "default-runtime": "nvidia" is added to your /etc/docker/daemon.conf file (and the docker service has been restarted or the system has been rebooted), then all containers should automatically use the nvidia runtime.

Does it work if you remove the runtime setting from your docker-compose.yaml file?