无法 select 具有功能的设备驱动程序“”:[[gpu]]

could not select device driver "" with capabilities: [[gpu]]

我正在尝试在 WSL 2 上安装 Cuda。我正在按照 this.

等说明进行操作

执行每一步后,我尝试通过执行 docker run --gpus all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark(如上述说明所建议的那样)来检查 gpu 在 Linux 环境中是否可用。

但是我收到以下错误: docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]]. ERRO[0000] error waiting for container: context canceled.

知道这可能是什么原因吗?

我遇到了同样的问题。您是否为 Windows 使用 Docker 桌面?因为我是,而且我发现 WSL2 + CUDA 不适用于 Docker Desktop for Windows:

https://forums.developer.nvidia.com/t/hiccups-setting-up-wsl2-cuda/128641

相反,在 WSL2 中手动安装 Docker(按照您链接的教程中的建议):

sudo apt update && sudo apt install -y nvidia-docker2

然后确保启动 docker 服务:

sudo service docker start

之后,您可以通过以下方式验证 CUDA/Docker/WSL2 设置:

 docker run --gpus all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark

你应该在哪里看到这样的输出:

NOTE: The CUDA Samples are not meant for performance measurements. Results may vary when GPU Boost is enabled.

Windowed mode Simulation data stored in video memory Single precision floating point simulation 1 Devices used for simulation MapSMtoCores for SM 7.5 is undefined. Default to use 64 Cores/SM GPU Device 0: "GeForce RTX 2060" with compute capability 7.5

Compute 7.5 CUDA device: [GeForce RTX 2060] 30720 bodies, total time for 10 iterations: 52.181 ms = 180.854 billion interactions per second = 3617.077 single-precision GFLOP/s at 20 flops per interaction

这个问题“无法 select 具有功能的设备驱动程序:[[gpu]] 发生在我身上是出于一个愚蠢的原因:NVIDIA 驱动程序不断更新新的 Insider 版本。

我已经养成了 运行ning ./deviceQuery 来自 NVIDIA_CUDA-11.0_Samples 的习惯,以确保 WSL 上的 CUDA 一切正常,然后检查我的 NVIDIA驱动程序版本,如果 returns 没有找到设备(然后重新安装正确的驱动程序)。

这可能不是最佳答案,但如果您 运行 参与其中,也许会节省一些时间。