Failed to initialize NVML: Unknown Error

在k8s启动的pod内执行nvidia-smi,报错Failed to initialize NVML: Unknown Error,但直接用docker run –rm nvidia/cuda:9.0-base nvidia-smi 却不会报错。 找到这里的文章提示 https://www.hwchiu.com/gpu-gke.html 可以用strace来查看系统调用, 能看到有这句 open(“/dev/nvidiactl”, O_RDWR) = -1 EPERM (Operation not permitted)
open(“/dev/nvidiactl”, O_RDONLY) = -1 EPERM (Operation not permitted) 没有权限去读取/dev/nvidiactl,按上面文章提示,加上

    securityContext:
      privileged: true

但加上privileged会导致/dev下所有显卡暴露,不能加特权。
最终发现是/etc/systemd/system/kubelet.service  加了--feature-gates CPUManager=true  ,具体原因不明为什么有影响。

updatedupdated2024-11-302024-11-30