- 訂閱patreon即可看到更多文章 https://www.patreon.com/wade3c
- Youtube頻道 https://www.youtube.com/c/增廣建文
Linux下如果還沒裝過docker的話可以參考
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
WSL2
- > WSL2在多次更新後也適用和Linux一樣的安裝方式了
- > 21H2後也不用去安裝特殊版的Nvidia driver了
- > docker desktop在3.1版後內建支援WSL2上的nvidia-docker
WSL內的Docker也可以用Linux的裝法,但有時候可能會遇到小問題
Linux
要先把nvidia的package server給加進apt的source list
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
&& curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
然後就可以直接去裝nvidia-docker套件了
sudo apt-get update
sudo apt-get install -y nvidia-docker2
裝好後記得要去把舊有的docker服務給關掉
sudo service docker restart
用Ubuntu裝的話就不用去設定/etc/docker/daemon.json
"default-runtime":"nvidia","runtimes":{"nvidia":{"path":"nvidia-container-runtime","runtimeArgs":[]}}
Test
有多種image可以進行測試,挑一個自己喜歡的就行
最簡單的就是去看nvidia-smi能不能順利運作
sudo docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi
Reference
Installation Guide — NVIDIA Cloud Native Technologies documentation
WSL 2 GPU Support for Docker Desktop on NVIDIA GPUs - Docker
Top comments (0)