wsl + cuda + nvdocker

wsl2 + cuda + nvgpu

基本环境

  1. wsl安装:https://docs.nvidia.com/cuda/wsl-user-guide/index.html#installing-wsl2
  2. wsl手册https://docs.microsoft.com/zh-cn/windows/wsl/reference
  3. (桌面显卡驱动)需要先安装支持wsl的显卡 https://developer.nvidia.com/cuda/wsl 

进入ubuntu以后

查看内核版本

cat /etc/lsb-release

  1. 阿里源 https://www.cnblogs.com/07yml/p/11701139.html
  2. 工具 https://tecadmin.net/install-development-tools-on-ubuntu/
  3. (alternative)systemctl https://blog.csdn.net/w851685279/article/details/108825893
  4. cuda 
    1. repo更新(较慢) https://blog.csdn.net/gzroy/article/details/111190131 -> repo版本最好改为wsl-ubuntu
    2. runfile安装 https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=WSLUbuntu&target_version=20&target_type=runfilelocal 选择wsl2
    3. 查看显卡(wsl2的cudatool包不带ns工具,可以根据系统提示安装)

      nvidia-smi

  5. (可选)anaconda https://blog.csdn.net/a475952074/article/details/79521567
  6. (可选)pytorch https://pytorch.org/get-started/locally/ 使用docker则无需配置本地python

docker

安装 https://www.cnblogs.com/jimchen1218/p/14186262.html 

(此处猜测安装desktop的docker以后wsl内可以不用再安装)

运行 https://docs.nvidia.com/cuda/wsl-user-guide/index.html#running-containers

1算力检测

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

2矩阵模板

$ docker run --gpus all --shm-size=1g --ulimit memlock=-1 --ulimit stack=67108864 -v "${PWD}:/mnt/c" nvcr.io/nvidia/tensorflow:20.03-tf2-py3 python /mnt/c/matmul.py gpu 20000

其中1可以显示当前桌面环境中的显卡,2可以看到调用gpu和cpu有明显时间区别

问题

在wsl内运行python文件可能无法正确识别显卡,同时nvcr.io/nvidia/tensorflow:20.03-tf2-py3也无法正确调用显卡

wsl2内的systemd有冲突,导致systemctl与docker可能无法正常使用

wsl-user-guide末注明了现阶段cuda on wsl2的部分已知问题

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值