docker-compose 版本 1.29.1 是否支持 --gpus 参数?

And*_*rew 1 docker-compose

docker-compose 版本 1.29.1 是否支持 --gpus 参数?如果没有,是否有其他参数支持在 docker-compose 1.29.1 中设置 GPU 的使用?

ane*_*yte 7

--gpus参数与命令一起使用docker。GPU 配置在以下docker-compose时间内完成docker-compose.yml

使用runtime选项(旧v2.3格式)

version: "2.3"
services:
  test:
    image: nvidia/cuda:10.2-base
    command: nvidia-smi
    runtime: nvidia # <- this option
Run Code Online (Sandbox Code Playgroud)

使用device结构(自 docker-compose v1.28.0 起)

version: "3.8"
services:
  test:
    image: nvidia/cuda:10.2-base
    command: nvidia-smi
    deploy:
      resources:
        reservations:
          devices:
          - driver: nvidia
            # that's the closest analogue to --gpus; provide
            # an integer amount of devices or 'all'
            count: 1
            # Devices are reserved using a list of capabilities, making
            # capabilities the only required field. A device MUST 
            # satisfy all the requested capabilities for a successful 
            # reservation.
            capabilities: [gpu]
Run Code Online (Sandbox Code Playgroud)

后者可能看起来有点复杂,但有一个指南解释了两者(使用 Compose 启用 GPU 访问 ),并且可以从Compose 规范中获取一些额外信息。