Access Nvidia in docker-compose

Hi,
I successfully setup InfluxDB 2.0 with Telegraf inside a docker-compose and it’s working perfectly fine.
I already added a new Telegraf plugin inputs.temp, which is also working.

Now i’m kinda stuck with the inputs.nvidia_smi plugin.
My first error was, that the binary could not be found so I added it as volumes:

 telegraf:
    image: telegraf
    container_name: telegraf
    ports:
        - 8080:8080
        - 8094:8094/udp
    volumes:
      - ./telegraf.conf:/etc/telegraf/telegraf.conf
      - /usr/bin/nvidia-smi

But now im stuck at a permission denied exception.

2020-11-18T13:51:50Z E! [inputs.nvidia_smi] Error in plugin: fork/exec /usr/bin/nvidia-smi: permission denied

I already tried to add 777 permissions to the file.
nvidia-smi is working outside the docker and for testing I added and nvsmi docker, which also works:

  nvsmi:
    image: ubuntu:20.04
    runtime: nvidia
    environment:
      - NVIDIA_VISIBLE_DEVICES=all
    command: nvidia-smi

There are some open bug reports about this, but nothing which seems to be resolved. (and honestly I don’t think this is a bug)
What would be a proper way to call nvidia-smi , if i can’t mount it like that ?

Thanks in advance :slight_smile:

I’m not 100% sure, but it seems like docker compose doesn’t link the volume with the right permissions (defaults to read-write). You probably need to change the permissions of the file before executing it, or build a single docker image with both binaries.

Not exactly sure as this is more of a Docker question.

1 Like