ubuntu 通过OpenCL链接Docker中的显卡

pbwdgjma  于 2022-11-02  发布在  Docker
关注(0)|答案(1)|浏览(425)

我使用Ubuntu 19.10,希望在docker中使用OpenCL。在docker容器中,我安装了opencl-headers、ocl-icd-opencl-dev和clinfo。当我在docker之外的机器上运行clinfo时,我得到以下响应:

Number of platforms                             1
  Platform Name                                   NVIDIA CUDA
  Platform Vendor                                 NVIDIA Corporation
  Platform Version                                OpenCL 1.2 CUDA 10.2.159
  ...

当在Docker中运行相同程序时:

Number of platforms                               0

我认为Docker container应该能够使用我的显卡,但不确定是否/如何允许它。感谢您的一些见解

bqf10yzr

bqf10yzr1#

您需要使用--gpus all选项启动docker,例如:

docker --rm --gpus all nvidia/opencl clinfo

您也可以只公开特定的gpu

docker run -it --rm --gpus "device=0" ubuntu nvidia-smi

点击此处阅读更多信息:https://docs.docker.com/config/containers/resource_constraints/

相关问题