Skip to content

Latest commit

 

History

History
66 lines (54 loc) · 3.25 KB

03-nvidia-docker-compose-setup.org

File metadata and controls

66 lines (54 loc) · 3.25 KB

03. Setup Docker compose to make use of the NVIDIA gpu

Install docker compose via your preferred method(configuration, home-manager etc.)

Check the version before you proceed.

> docker-compose --version
Docker Compose version 2.30.3

Test using a sample docker-compose.yml

services:
  test:
    image: nvidia/cuda:12.6.3-base-ubuntu24.04
    command: nvidia-smi
    deploy:
      resources:
        reservations:
          devices:
          - driver: cdi
            capabilities:
              - gpu
            device_ids:
              - nvidia.com/gpu=all

Test the docker-compose against the above service specification.

> docker-compose up
Attaching to test-1
test-1  | Wed Mar 12 15:03:41 2025
test-1  | +-----------------------------------------------------------------------------------------+
test-1  | | NVIDIA-SMI 565.77                 Driver Version: 565.77         CUDA Version: 12.7     |
test-1  | |-----------------------------------------+------------------------+----------------------+
test-1  | | GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
test-1  | | Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
test-1  | |                                         |                        |               MIG M. |
test-1  | |=========================================+========================+======================|
test-1  | |   0  NVIDIA GeForce RTX 3090        Off |   00000000:01:00.0 Off |                  N/A |
test-1  | |  0%   45C    P8             24W /  370W |      15MiB /  24576MiB |      0%      Default |
test-1  | |                                         |                        |                  N/A |
test-1  | +-----------------------------------------+------------------------+----------------------+
test-1  | |   1  NVIDIA GeForce RTX 3090        Off |   00000000:02:00.0  On |                  N/A |
test-1  | |  0%   50C    P8             40W /  370W |     839MiB /  24576MiB |     18%      Default |
test-1  | |                                         |                        |                  N/A |
test-1  | +-----------------------------------------+------------------------+----------------------+
test-1  |
test-1  | +-----------------------------------------------------------------------------------------+
test-1  | | Processes:                                                                              |
test-1  | |  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
test-1  | |        ID   ID                                                               Usage      |
test-1  | |=========================================================================================|
test-1  | +-----------------------------------------------------------------------------------------+
test-1 exited with code 0

> docker-compose down

At this point, you now should be able to build your images with the libraries as needed. Make sure that you always match the CUDA versions for less surprises, both in the images as well as the libraries.