Skip to content

Add GPUs support for services

What does this MR do?

This MR adds support for the Docker executor to expose GPUs to services. A new service_gpus string in the runner config allows configuring GPU exposure to services using the same syntax as the gpus string.

Based on our feature design discussion, I've decided to go ahead and propose an implementation according to variant 2.1.

I've tested this modification on a real test project and confirm that it's working.

Why was this MR needed?

Services that require GPUs have no access to these resources at the moment. See #38513 (closed) for more details.

What's the best way to test this MR?

  1. Compile the gitlab-runner executable from this MR.

  2. Register the runner using the Docker executor in a test project.

  3. Add the service_gpus setting in the config.toml file:

    [[runners]]
      (...)
    
      [runners.docker]
        (...)
        service_gpus = "all"
  4. Add a test CI config in .gitlab-ci.yml:

    variables:
      CI_DEBUG_SERVICES: "true"
    
    test:
      services:
        - name: debian:latest
          command: ["nvidia-smi"]
      image: debian:latest
      script:
        - nvidia-smi
      tags:
        - <RUNNER_TAG>

What are the relevant issue numbers?

Closes #38513 (closed).

/cc @avonbertoldi, as we have been discussing about this feature in #38513 (closed) and as you have reviewed !5343 (merged), which is similar.

Edited by Sigurd Spieckermann

Merge request reports

Loading