赞
踩
本文用来记录如何下载使用docker compose v2
版本并配置使用gpu host.
v2 版本使用插件方式安装, 与v1版本可共存, 只是引导方式有不同
v2 使用命令docker compose version
而不是docker-compose version
Enabling GPU access with Compose
https://github.com/docker/compose
# install
cd ~/Downloads
wget https://github.com/docker/compose/releases/download/v2.16.0/docker-compose-linux-x86_64
mv docker-compose-linux-x86_64 ~/.docker/cli-plugins/docker-compose
chomd +x ~/.docker/cli-plugins/docker-compose
# check version
docker compose version
Docker Compose version v2.16.0
docker pull nvidia/cuda:11.3.1-base-ubuntu20.04
# 下载cuda用作基础镜像
# docker-compose.yml
networks: {}
services:
core:
image: nvidia/cuda:11.3.1-base-ubuntu20.04
command: nvidia-smi
shm_size: "2g"
container_name: "test"
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
version: '3.0'
docker logs -f test
Mon Mar 13 02:35:24 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.161.03 Driver Version: 470.161.03 CUDA Version: 11.4 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 Quadro M2000 Off | 00000000:01:00.0 On | N/A |
| 56% 44C P0 23W / 75W | 770MiB / 4041MiB | 7% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
+-----------------------------------------------------------------------------+
简单记录如何使用docker compose
创建容器, 使用gpu支持.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。