简体   繁体   中英

How can I run programs with OpenCL on AMD inside a gitlab-ci docker executor

I have a self-hosted gitlab for still private projects and a dedicated physical node for testing with an AMD GPU. On this node there is already a gitlab-ci runner with docker executor.

Is there a way to execute programms with OpenCL and access to the AMD GPU within the docker-containers, which are created by the gitlab-ci runner?

All I found until now, were Nvidia and CUDA related infos to solve this problem (for example this How can I get use cuda inside a gitlab-ci docker executor ), but I haven't found anything useful for the case with OpenCL and AMD.

Found the solution by myself in the meantime. It was easier then expected.

The docker-image for the gitlab-ci pipeline only need the amd gpu driver from the amd website ( https://www.amd.com/en/support ).

Example-Dockerfile to build the docker images:

from ubuntu:18.04

RUN apt-get update && apt-get upgrade -y

RUN apt-get install -y gcc g++ opencl-headers ocl-icd-opencl-dev curl apt-utils unzip tar curl xz-utils wget clinfo

RUN cd /tmp &&\
    curl --referer https://drivers.amd.com/drivers/linux -O https://drivers.amd.com/drivers/linux/amdgpu-pro-20.30-1109583-ubuntu-18.04.tar.xz &&\
    tar -Jxvf amdgpu-pro-20.30-1109583-ubuntu-18.04.tar.xz &&\
    cd amdgpu-pro-20.30-1109583-ubuntu-18.04/ &&\
    ./amdgpu-install -y  --headless  --opencl=legacy

Based on your used gpu and linux version you need potentially another file then the one in this example. Its also possible that the file doesn't exist anymore on the website and you have to checkout the newest file.

Beside this there is only a little modification in the gitlab-runner config ( /etc/gitlab-runner/config.toml ) necessary.

Add in the docker-runner: devices = ["/dev/dri"] :

[[runners]]
  ...
  [runners.docker]
    ...
    devices = ["/dev/dri"]

And restart the gitlab runner again with gitlab-runner restart .

After this its possible to execute opencl-code inside of the gitlab-ci docker runner.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM