Skip to content

Mount nvidia.icd file needed by OpenCL#1893

Open
cdesiniotis wants to merge 1 commit into
NVIDIA:mainfrom
cdesiniotis:add-opencl-icd-file
Open

Mount nvidia.icd file needed by OpenCL#1893
cdesiniotis wants to merge 1 commit into
NVIDIA:mainfrom
cdesiniotis:add-opencl-icd-file

Conversation

@cdesiniotis

Copy link
Copy Markdown
Contributor

This change ensures the NVIDIA ICD file needed by
OpenCL ICD loaders gets injected into containers.
The NVIDIA ICD file tells the OpenCL runtime where
to find NVIDIA's OpenCL implementation.

fixes: #682

Testing

$ cat Dockerfile
FROM ubuntu:24.04
RUN apt-get update && apt-get install -y \
    clinfo \
    && rm -rf /var/lib/apt/lists/*
    
$ docker build -t opencl-sample .

$ docker run --rm -it --gpus all opencl-sample:latest bash
root@9e05c7e8c23f:/# clinfo
Number of platforms                               0

ICD loader properties
  ICD loader Name                                 OpenCL ICD Loader
  ICD loader Vendor                               OCL Icd free software
  ICD loader Version                              2.3.2
  ICD loader Profile                              OpenCL 3.0
root@9e05c7e8c23f:/# ldconfig -p | grep libnvidia-opencl
	libnvidia-opencl.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libnvidia-opencl.so.1
	
$ docker run --rm -it --gpus all -v /etc/OpenCL/vendors/nvidia.icd:/etc/OpenCL/vendors/nvidia.icd opencl-sample:latest bash
root@083eb14fcb76:/# clinfo
Number of platforms                               1
  Platform Name                                   NVIDIA CUDA
  Platform Vendor                                 NVIDIA Corporation
  Platform Version                                OpenCL 3.0 CUDA 13.1.112

. . . snip . . .

ICD loader properties
  ICD loader Name                                 OpenCL ICD Loader
  ICD loader Vendor                               OCL Icd free software
  ICD loader Version                              2.3.2
  ICD loader Profile                              OpenCL 3.0
  
// generate CDI spec using nvidia-ctk binary built from this PR
$ sudo ./nvidia-ctk cdi generate --output /var/run/cdi/nvidia.yaml 2>/dev/null

$ grep -A6 "nvidia\.icd" /var/run/cdi/nvidia.yaml
        - hostPath: /etc/OpenCL/vendors/nvidia.icd
          containerPath: /etc/OpenCL/vendors/nvidia.icd
          options:
            - ro
            - nosuid
            - nodev
            - rbind
            - rprivate
 
$ docker run --rm -it --gpus all opencl-sample:latest /bin/bash -c 'clinfo | grep "Number of platforms"'
Number of platforms                               1

This change ensures the NVIDIA ICD file needed by
OpenCL ICD loaders gets injected into containers.
The NVIDIA ICD file tells the OpenCL runtime where
to find NVIDIA's OpenCL implementation.

fixes: NVIDIA#682

Signed-off-by: Christopher Desiniotis <cdesiniotis@nvidia.com>
@cdesiniotis cdesiniotis added this to the v1.20.0 milestone Jun 18, 2026
@cdesiniotis cdesiniotis requested a review from tariq1890 June 18, 2026 06:38
@cdesiniotis cdesiniotis self-assigned this Jun 18, 2026
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 27741561129

Coverage decreased (-0.003%) to 43.538%

Details

  • Coverage decreased (-0.003%) from the base build.
  • Patch coverage: 1 uncovered change across 1 file (0 of 1 lines covered, 0.0%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
internal/discover/graphics.go 1 0 0.0%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 15010
Covered Lines: 6535
Line Coverage: 43.54%
Coverage Strength: 0.48 hits per line

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenCL no /etc/OpenCL/vendors/nvidia.icd

2 participants