一、wsl 下安裝 docker 會提示安裝 docekr 桌面版,所以直接安裝 docker 桌面版本即可
二、安裝 NVIDIA Container Toolkit
NVIDIA Container Toolkit倉庫
https://github.com/NVIDIA/nvidia-container-toolkit?github.com/NVIDIA/nvidia-container-toolkit
安裝文檔
Installing the NVIDIA Container Toolkit?docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#installation
安卓文檔里面的命令,參照標準流程安裝即可。也可以參考:Windows11下Docker使用記錄(五)_windows docker cuda-CSDN博客
三、docker 追加 NVIDIA runtime 配置
最新配置可以通過命令得到,會輸出配置到文件
Installing the NVIDIA Container Toolkit?docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#configuring-docker
// 最新生成配置命令需要參照鏈接文檔
sudo nvidia-ctk runtime configure --runtime=docker
然后將NVIDIA runtime 配置添加到 docker 的配置中
{
// ..."runtimes": {"nvidia": {"args": [],"path": "nvidia-container-runtime"}}
// ...
}
四、簡單測試一下
Running a Sample Workload?docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/sample-workload.html#running-a-sample-workload
// 最新測試命令需要參照鏈接文檔
sudo docker run --rm --runtime=nvidia --gpus all ubuntu nvidia-smi