安裝Docker-Desktop
安裝Docker-Desktop
Docker-Desktop下載地址 :https://www.docker.com/products/docker-desktop/
接著就一路無(wú)腦安裝即可。
下載完成之后,Docker Desktop會(huì)放在開(kāi)機(jī)自動(dòng)啟動(dòng)的文件目錄下,因此每次開(kāi)機(jī)都會(huì)自動(dòng)開(kāi)啟。
可以觀察到:左下角圖標(biāo)顯示綠色就表示服務(wù)都正常運(yùn)行。
簡(jiǎn)單配置docker
這里簡(jiǎn)單設(shè)置一下鏡像加速器
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn/",
"http://hub-mirror.c.163.com"
]
2.啟動(dòng)Docker Desktop for Windows,點(diǎn)擊“設(shè)置”按鈕,啟用基于WSL2的引擎復(fù)選框(Use the WSL 2 based engine)
在 Resources 的WSL Integration中設(shè)置要從哪個(gè) WSL2 發(fā)行版中訪(fǎng)問(wèn) Docker,如下圖使用的是 Ubuntu。
進(jìn)入到ubuntu命令窗口,輸入以下命令。就可以在WSL2中使用docker了
docker --version
win10安裝支持WSL2的nvidia驅(qū)動(dòng)
.在win10安裝支持WSL2的nvidia驅(qū)動(dòng)
驅(qū)動(dòng)下載地址CUDA on Windows Subsystem for Linux (WSL):https://developer.nvidia.com/cuda/wsl
下載完成后直接默認(rèn)安裝就行
ubuntu配置 CUDA Toolkit
在安裝CUDA Toolkit 需要先安裝gcc,g++,否則會(huì)出現(xiàn)以下錯(cuò)誤
因此,輸入以下命令安裝gcc,g++。
sudo apt install gcc g++ make
在NIVDIA官方的CUDA Toolkit安裝界面選擇合適版本,這里選擇11.7安裝。
根據(jù)官網(wǎng)給出的命令進(jìn)行安裝
wget https://developer.download.nvidia.com/compute/cuda/11.7.0/local_installers/cuda_11.7.0_515.43.04_linux.run
sudo sh cuda_11.7.0_515.43.04_linux.run
接下來(lái)就出現(xiàn)這樣的界面
這里我們鍵入accept
按回車(chē)
之后就出現(xiàn)這樣的界面了
由于已經(jīng)在windows系統(tǒng)中安裝了NVIDIA顯卡驅(qū)動(dòng),所以這里不需要在子系統(tǒng)中安裝CUDA 11.7中附帶的驅(qū)動(dòng),移動(dòng)到Driver選項(xiàng)上,按空格鍵將該項(xiàng)取消,然后再移動(dòng)到Install選項(xiàng),回車(chē),等待安裝。
安裝完成之后就會(huì)出現(xiàn)這樣的界面
===========
= Summary =
===========
Driver: Not Selected
Toolkit: Installed in /usr/local/cuda-11.7/
Please make sure that
- PATH includes /usr/local/cuda-11.7/bin
- LD_LIBRARY_PATH includes /usr/local/cuda-11.7/lib64, or, add /usr/local/cuda-11.7/lib64 to /etc/ld.so.conf and run ldconfig as root
To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-11.7/bin
***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 515.00 is required for
CUDA 11.7 functionality to work.
To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
sudo <CudaInstaller>.run --silent --driver
Logfile is /var/log/cuda-installer.log
設(shè)置環(huán)境變量
(nano或者用vim也行·)
sudo nano .bashrc
添加以下內(nèi)容:
export PATH=/usr/local/cuda-11.7/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.7/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
執(zhí)行以下命令
source .bashrc
輸入nvcc -V
查看cuda。
nvcc -V
GPU測(cè)試及問(wèn)題處理
測(cè)試在WSL2中是否可以使用GPU
docker run --gpus all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark
出現(xiàn)Bug了
解決方案:win10 Docker Desktop使用GPU
檢測(cè)windows更新,重啟一下就好了
再次執(zhí)行上面那條語(yǔ)句
最后,分別在linux命令行中輸入nvcc -V
和nvidia-smi
查看驅(qū)動(dòng)
★,°:.☆( ̄▽?zhuān)?/$:.°★ 。
參考資料:文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-418325.html
重點(diǎn)推薦:win10 Docker Desktop使用GPU
https://blog.csdn.net/xyl192960/article/details/120246820
https://blog.csdn.net/Rayone_/article/details/124410685
https://zhuanlan.zhihu.com/p/434239083
2021年 Windows10 環(huán)境下使用WSL和Docker 配置深度學(xué)習(xí)環(huán)境- 可使用任意版本的 Ubuntu+CUDA image 以及踩坑記錄
Win10/Win11子系統(tǒng)(二)——深度學(xué)習(xí)環(huán)境搭建:WSL2+Ubuntu20.04+CUDA10.1+pytorch1.8.1+pycharm
ubuntu18.04配置deepo深度學(xué)習(xí)環(huán)境(cuda + cudnn + nvidia-docker + deepo)–超級(jí)細(xì)致,并把遇到的錯(cuò)誤和所有解決方案都列出來(lái)了
基于 WSL2+Docker 的一種深度學(xué)習(xí)環(huán)境解決方案
WSL Ubuntu + Docker Desktop搭建python環(huán)境
WSL 2 上的 Docker 遠(yuǎn)程容器入門(mén)
一篇文章搞定 Docker 入門(mén)
文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-418325.html
到了這里,關(guān)于WSL2和Docker使用GPU的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!