当前位置:   article > 正文

docker compose建立容器使用gpu本地驱动_docker-compose gpu

docker-compose gpu


前言

本文用来记录如何下载使用docker compose v2版本并配置使用gpu host.
v2 版本使用插件方式安装, 与v1版本可共存, 只是引导方式有不同
v2 使用命令docker compose version而不是docker-compose version

Enabling GPU access with Compose

Install the Compose plugin


一、下载V2版本

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

二、使用步骤

编写docker-compose

docker pull nvidia/cuda:11.3.1-base-ubuntu20.04
# 下载cuda用作基础镜像
  • 1
  • 2
# 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'
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

检测输出

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      |
|=============================================================================|
+-----------------------------------------------------------------------------+

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

总结

简单记录如何使用docker compose创建容器, 使用gpu支持.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/849417
推荐阅读
相关标签
  

闽ICP备14008679号