Expose GPUs in CI services with Docker executor
Description
I'm working on testing open-access LLMs on GitLab via CI by running an LLM inference service as a CI service and the test suite in the main CI job. A (slightly simplified snippet) of .gitlab-ci.yml may look like this:
llm-tests:
stage: test
services:
# NOTE: This image is currently missing the `EXPOSE` instruction in the `Dockerfile`
# to advertise the open ports to the CI runner.
- name: ai/phi:3-mini-4k-instruct-cuda-12.6
alias: llm
image: python:3.13
variables:
LLM_BASE_URL: http://llm:8000/v1
before_script:
- pip install -r requirements.txt
script:
- pytest
When I was attempting to run this CI job on our corporate self-hosted GitLab instance on a GPU-capable runner, then the CI service log contains an error that the GPU device could not be found:
2025-01-22T18:31:37.796200161Z RuntimeError: Failed to infer device type
2025-01-22T18:31:39.615169011Z WARNING 01-22 18:31:39 _custom_ops.py:19] Failed to import from vllm._C with ImportError('libcuda.so.1: cannot open shared object file: No such file or directory')
It seems that the GPU is not exposed in the CI service. I've also looked into the Docker executor source code which supports my hypothesis as the job container's host config includes the devices and device requests whereas the CI service's container host config does not.
Proposal
I propose to expose devices and device requests (i.e., GPUs) to CI services as well, not only to the CI job container.
If my above analysis is correct, I think the CI service's host config should contain the devices and device requests configs similar to the CI job container's host config. If you agree, I'd be happy to contribute this feature.