I'm trying to write a playbook that runs a docker container with access to gpus. Basically, I want this command in Ansible:
docker run --rm --gpus all -d -p 9400:9400 --name dcgm-exporter nvidia/dcgm-exporter
What I've tried:
- name: Run DCGM Exporter Container
community.docker.docker_container:
name: dcgm-exporter
image: nvidia/dcgm-exporter
restart_policy: unless-stopped
gpus: all
published_ports:
- "9400:9400"
state: started
detach: yes
The error suggests that nvidia toolkit is not being used.
Unsupported parameters for (community.docker.docker_container) module: gpus.
What is the best way to mount gpus to the docker container? Is it possible to integrate Nvidia docker container toolkit?
As per U880D's comment, using device_requests
works.
Instead of gpus: all
I used:
- driver: nvidia
count: -1
capabilities:
- [ "gpu" ]