Windows+WSL2+CUDA+Docker

    科技2022-07-11  113

    参考:

    CUDA on WSL User GuideNVIDIA CUDA Installation Guide for LinuxWSL2 CUDA 工具包 11.1 下载

    1.操作系统

    我采用的版本是windows10 教育版 2004(20262)。Ensure that you install Build version 20145 or higher.

    系统必须安装有nvidia的卡,同时安装对应wsl2的驱动。

    2.安装WSL2

    参考:将WSL2作为生产力工具

    3.安装Docker

    在wsl2中: curl https://get.docker.com | sh 关于Docker Desktop: 截止到2020.11.27,不支持Docker Desktop 参考:https://docs.nvidia.com/cuda/wsl-user-guide/index.html#known-limitations

    4.安装cuda

    从https://developer.nvidia.com/cuda-downloads下载相应的安装程序

    在WSL2中: 注意:我使用的是Ubuntu18.04的镜像,如果是其他版本,请修改命令中的版本号 cd apt-get install -y gcc g++ make ./cuda_11.1.0_455.23.05_linux.run

    cd ./NVIDIA_CUDA-11.1_Samples/1_Utilities/deviceQuery make ./deviceQuery

    5.nvidia-docker toolkit

    distribution=$(. /etc/os-release;echo $ID$VERSION_ID) curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list # To get access to experimental features such as CUDA on WSL or the new MIG capability on A100, you may want to add the experimental branch to the repository listing curl -s -L https://nvidia.github.io/libnvidia-container/experimental/$distribution/libnvidia-container-experimental.list | sudo tee /etc/apt/sources.list.d/libnvidia-container-experimental.list apt-get update apt-get install -y nvidia-docker2 service docker stop service docker start

    6.验证

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

    报错:

    docker: Error response from daemon: cgroups: cannot find cgroup mount destination: unknown.

    参考:https://blog.csdn.net/ren7wei/article/details/80855779

    mkdir /sys/fs/cgroup/systemd mount -t cgroup -o none,name=systemd cgroup /sys/fs/cgroup/systemd

    再次运行验证命令,通过

    安装脚本可以参考:https://blog.csdn.net/fleaxin/article/details/110310874

    Processed: 0.026, SQL: 8