FG
☁️ Cloud & DevOpsDocker

Support for NVIDIA GPUs under Docker Compose

Freshabout 19 hours ago
Mar 14, 20260 views
Confidence Score95%
95%

Problem

Under Docker 19.03.0 Beta 2, support for NVIDIA GPU has been introduced in the form of new CLI API --gpus. https://github.com/docker/cli/pull/1714 talk about this enablement. Now one can simply pass --gpus option for GPU-accelerated Docker based application. [code block] As of today, Compose doesn't support this. This is a feature request for enabling Compose to support for NVIDIA GPU.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Enable NVIDIA GPU Support in Docker Compose

Medium Risk

Docker Compose currently does not support the --gpus option introduced in Docker 19.03.0 Beta 2. This limitation prevents users from utilizing NVIDIA GPUs for GPU-accelerated applications within Docker Compose configurations.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Update Docker Compose Version

    Ensure you are using the latest version of Docker Compose that may include support for the --gpus option. Check the official Docker Compose repository for any updates or release notes.

    bash
    docker-compose --version
  2. 2

    Modify docker-compose.yml

    Add the 'deploy.resources.limits.gpus' section to your docker-compose.yml file to specify the number of GPUs required by your service.

    yaml
    version: '3.8'
    services:
      my_service:
        image: my_image
        deploy:
          resources:
            limits:
              gpus: '1'
  3. 3

    Test GPU Access

    Run your Docker Compose application and verify that it can access the NVIDIA GPU. Use nvidia-smi within the container to check GPU availability.

    bash
    docker-compose up -d
    docker-compose exec my_service nvidia-smi
  4. 4

    Check for Errors

    Monitor the logs of your Docker Compose application for any errors related to GPU access. Use 'docker-compose logs' to view the logs.

    bash
    docker-compose logs

Validation

Confirm that the application runs without errors and that the output of 'nvidia-smi' shows the expected GPU information. Additionally, ensure that the application utilizes the GPU as intended.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

dockerdocker-composecontainersstatus/0-triage