docker调用gpu

1、安装gpu驱动

2、安装docker

3、修改docker配置文件

cat /etc/docker/daemon.json
{
    "default-runtime": "nvidia",
       "runtimes": {
        "nvidia": {
            "path": "/usr/bin/nvidia-container-runtime",
            "runtimeArgs": []
        }
    },
    "exec-opts":["native.cgroupdriver=systemd"]

}

4、安装必要的依赖

yum -y install nvidia-container-runtime nvidia-container-toolkit

5、启动docker

6、启动需要gpu的容器

docker run -itd --name  omniparse --gpus all --entrypoint bash -e http_proxy=http://192.168.10.72:7890 -e https_proxy=http://192.168.10.72:7890 -p 8000:8000 savatar101/omniparse:0.1

成功标志

nvidia-smi 
Sun Sep 29 10:29:53 2024       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.120                Driver Version: 550.120        CUDA Version: 12.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  NVIDIA GeForce RTX 3090        Off |   00000000:1A:00.0 Off |                  N/A |
| 30%   30C    P8             22W /  350W |    4466MiB /  24576MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   1  NVIDIA GeForce RTX 3090        Off |   00000000:1B:00.0 Off |                  N/A |
| 30%   36C    P2            109W /  350W |   24049MiB /  24576MiB |     20%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   2  NVIDIA GeForce RTX 3090        Off |   00000000:1C:00.0 Off |                  N/A |
| 30%   39C    P2            104W /  350W |   15046MiB /  24576MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   3  NVIDIA GeForce RTX 3090        Off |   00000000:1D:00.0 Off |                  N/A |
| 31%   43C    P2            105W /  350W |   15046MiB /  24576MiB |      6%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   4  NVIDIA GeForce RTX 3090        Off |   00000000:1E:00.0 Off |                  N/A |
| 38%   65C    P2            340W /  350W |   23228MiB /  24576MiB |    100%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   5  NVIDIA GeForce RTX 3090        Off |   00000000:3D:00.0 Off |                  N/A |
| 35%   57C    P2            349W /  350W |   23270MiB /  24576MiB |    100%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   6  NVIDIA GeForce RTX 3090        Off |   00000000:3E:00.0 Off |                  N/A |
| 37%   61C    P2            332W /  350W |   23436MiB /  24576MiB |    100%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   7  NVIDIA GeForce RTX 3090        Off |   00000000:3F:00.0 Off |                  N/A |
| 37%   59C    P2            332W /  350W |   23354MiB /  24576MiB |    100%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   8  NVIDIA GeForce RTX 3090        Off |   00000000:40:00.0 Off |                  N/A |
| 38%   68C    P2            346W /  350W |   24146MiB /  24576MiB |    100%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   9  NVIDIA GeForce RTX 3090        Off |   00000000:41:00.0 Off |                  N/A |
| 36%   60C    P2            344W /  350W |   23038MiB /  24576MiB |    100%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A    108262      C   python                                       4460MiB |
+-----------------------------------------------------------------------------------------+

posted @ 2025-02-13 19:35  Tenderness、  阅读(48)  评论(0)    收藏  举报