Skip to content

Latest commit

 

History

History
68 lines (55 loc) · 3.25 KB

03-nvidia-docker-compose-setup.org

File metadata and controls

68 lines (55 loc) · 3.25 KB

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

Please make sure that you’ve installed docker-compose before continuing. As per the official documentation on gpu support, you’ll have to install Docker Compose v1.28.0 or higher for the device structure specification in your compose files. Read more at https://docs.docker.com/compose/gpu-support/

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

Check the version before you proceed.

> docker-compose --version
Docker Compose version 2.23.1

Test using a sample docker-compose.yml

services:
  test:
    image: nvidia/cuda:12.1.0-base-ubuntu22.04
    command: nvidia-smi
    deploy:
      resources:
        reservations:
          devices:
          - driver: nvidia
            capabilities: [gpu]

Test the docker-compose against the above service specification.

❯ docker-compose up
[+] Building 0.0s (0/0)
[+] Running 2/0
 ✔ Network 03-files_default   Created
 ✔ Container 03-files-test-1  Created
Attaching to test-1
test-1  | Fri Jan 19 00:50:37 2024
test-1  | +---------------------------------------------------------------------------------------+
test-1  | | NVIDIA-SMI 545.29.02              Driver Version: 545.29.02    CUDA Version: 12.3     |
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  On |                  N/A |
test-1  | |  0%   49C    P8              41W / 370W |    465MiB / 24576MiB |     14%      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
[+] Running 2/2
 ✔ Container 03-files-test-1  Removed
 ✔ Network 03-files_default   Removed

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.