(9条消息) WSL2 安装教程 CUDA 配置 自测已成功

JichaoZhao2020-07-28 17:59:18
分类专栏:Linux文章标签:cudatensorflowaptgpu深度学习
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
版权

Install Windows 10 Insiders Dev Channel

Windows Insider

Consult the Windows Insider documentation for more information on registering as an Insider, enrolling your device, and upgrading your machine to the Dev Channel.

Enable WSL 2

In future updates to Windows you will simply need to use the following to enable WSL:

wsl --install

For now, open PowerShell as Administrator.

First enable WSL 1:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Then enable WSL 2:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Restart Windows 10:

Restart-Computer

This step will become redundant in the future after WSL 2 becomes the default, but for now return to PowerShell and make WSL 2 your default before installing Ubuntu:

wsl.exe --set-default-version 2

To read more about Ubuntu on WSL, visit ubuntu.com/wsl. For a more detailed look at enabling WSL on Windows, check out our tutorial. To convert existing WSL 1 installs to WSL 2, see my blog on the general availability of WSL 2.

Install Ubuntu on WSL

Install Ubuntu from the Microsoft Store:

For other ways to install Ubuntu on WSL, see our WSL wiki.

Install Windows Terminal

Optionally, you may install the new Windows Terminal from the Microsoft Store. It is has many features, such as GPU acceleration and customizability, that improves the Ubuntu experience on WSL over the traditional Windows console.

Windows Terminal can also be installed from the project’s GitHub page.

Setup Ubuntu on WSL

Open Ubuntu from the Windows Start Menu and configure your WSL user. This user is separate from your Windows user:

If you downloaded Windows Terminal you can then close the old console and re-open Ubuntu from the drop-down options in the new Terminal:

Now check to make sure you are running the correct WSL 2 Linux kernel.

In Ubuntu:

uname -r

You will need kernel 4.19.121 or higher. If you do not have kernel 4.19.121, first try:

wsl.exe --update

If that does not work, make sure you have 'Receive updates for other Microsoft products when you update Windows’ checked:

And then re-run Windows updates:

Install Nvidia Drivers on Windows 10

Next, download the appropriate driver for your GeForce or Quadro Nvidia card.

In the next few months, the NVIDIA driver will be distributed via Windows Update, which will manually downloading and installing the driver unnecessary.

You will need to join the Nvidia Developer Program for early access to the driver for now. You can read more about CUDA on WSL on the Nvidia Developer blog.

Install Docker in WSL

# sudo apt -y install docker.iocurl https://get.docker.com | sh

Install Nvidia Container Toolkit

Set the distribution variable, import the Nvidia repository GPG key, and then add the Nvidia repositories to the Ubuntu apt package manager:

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.listcurl -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

Refresh the Ubuntu apt repositories and then install the Nvidia runtime:

sudo apt update && sudo apt install -y nvidia-docker2

Close all open terminals of Ubuntu, open a PowerShell terminal, and manually shutdown Ubuntu:

wsl.exe --shutdown Ubuntu

Test GPU Compute

Open a new Ubuntu terminal and start Docker:

sudo service docker stopsudo service docker start

And then run:

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

If everything is configured correctly, the output should resemble:

Start A TensorFlow Container

Open a new Ubuntu terminal and run:

docker run -u $(id -u):$(id -g) -it --gpus all -p 8888:8888 tensorflow/tensorflow:latest-gpu-py3-jupyter

Open a second Ubuntu terminal, type wslview, copy and paste the notebook URL, but then edit the URL from 127.0.0.1 to localhost:

wslview http://localhost:8888/?token=a83a1ad288a7bf1bd1deb694c8a7f19223c8d0baa7d5fb3c

Your default browser on Windows will launch with a GPU-accelerated Jupyter notebook:

You are now all set to begin using TensorFlow with CUDA on Ubuntu WSL.

Test PyTorch CUDA

(0)

相关推荐

  • Ubuntu16.04下nvidia驱动+cuda+cudnn+nccl安装

    前言 如果出现装了驱动进不了桌面的情况(下面有解决方法),然后重装了两遍nvidia驱动还进不去,重装Ubuntu是最省时间的做法! 以下的安装流程从网上各个博客进行收集来的,试了一遍可以完全安装成功 ...

  • 5分钟搭建强大又好用的深度学习环境

    为深度学习项目建立一个良好的环境不是一件容易的任务.因为需要处理的事情太多了:库必须匹配特定的版本,整个环境需要可以复制到其他机器上,所有东西都需要能够机器中的所有驱动程序通信.这意味着你需要为你的N ...

  • 手把手教你搭建计算机视觉开发环境

    来源:Python数据之道 作者:来自读者投稿 整理:阳哥 本文将以 Linux 系统下安装 tensorflow 为例来讲解计算机视觉开发环境的搭建过程. 1.安装 nvidia 驱动 首先去 Nv ...

  • Ubuntu 18.04上安装cuda

    一.准备工作 参照官网上资料,进行准备工作 1. 验证自己的电脑是否有一个可以支持CUDA的GPU $ lspci | grep -i nvidia 我的显示为Tesla P800 if it is ...

  • 技术文档丨如何为Apollo安装低时延/实时内核

    本文档描述了在Ubuntu 18.04上安装低时延(Low-Latency) 或实时 (Realtime)内核及Nvidia驱动的步骤.   ENJOY THE FOLLOWING   仅在实车上运行 ...

  • Linux-Windows10双系统安装

    在Windows10系统上搭建完深度学习环境用于无人驾驶中的目标检测后,想在Linux系统上再尝试一下.由于VMware虚拟机安装的Linux系统不支持物理硬件,所以需要一步到位安装一个双系统.本文介 ...

  • (2条消息) Oracle19c安装教程及PLSQL配置常见错误解决办法

    本人电脑上也装了不少比较难以安装的程序,而且也亲身破解了一些软件,自己以前也安装过MySQL和DB2,原以为Oracle也差不多,直到我亲身经历了,我才知道什么是痛苦.帅帅本人在经历了长时间的折磨之后 ...

  • (9条消息) WSL2安装Ubuntu

    WSL2安装Ubuntu SilenceWzw 2020-08-12 14:18:20 1152 收藏 5 分类专栏: Linux 文章标签: ubuntu linux 版权声明:本文为博主原创文章, ...

  • (3条消息) RabbitMq安装教程(超详细)

    RabbitMq安装教程 RabbitMq简介 安装准备工具 安装步骤(图文) RabbitMq简介 1.1消息队列中间件简介 消息队列中间件是分布式系统中重要的组件,主要解决应用耦合,异步消息,流量 ...

  • (2条消息) pycharm安装教程

    pycharm是一款功能强大的python编辑器,具有跨平台性,鉴于目前最新版pycharm使用教程较少,为了节约大家摸索此IDE的时间,来介绍一下pycharm在windows下是如何安装的. 这是 ...

  • (5条消息) sublime text 3 + python配置,完整搭建及常用插件安装

    公众号:战渣渣 四年的时间,一直使用EmEditor编辑器进行Python开发,之前是做面向过程,只需要将一个单独的py文件维护好即可,用着也挺顺手,但是最近在做面向对象的开发,不同的py文件中相互关 ...

  • (55条消息) Linux安装(CentOS7)与最小化安装配置

    Linux安装(CentOS7)与最小化安装配置 一.CentOS7安装(最小化) 1.安装VMware(虚拟机软件) 这里安装的是VMware15.5(2019年10月份之前的版本无法开启重装了下) ...

  • (5条消息) WSL2 + Ubuntu18.04 + Docker

    Nonevx 2020-05-11 09:58:16 966  版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明. 本文链接:https://bl ...

  • (22条消息) CentOS8安装Mysql5.7,不是8.0

    CentOS8安装Mysql5.7,不是8.0 卸载原有的Mysql yum安装Mysql 之前使用过Ubantu,但是并没有深入使用,这次为了更加深入学习Mysql以及Linux系统,同时想试试Ce ...

  • (1条消息) RabbitMQ安装错误:libcrypto.so.10(OPENSSL

    Erlang rpm包安装过程出现的这个错误,出现这个错误的主要原因是没有libcrypto.so.10(OPENSSL_1.0.2)(64bit)依赖,我们去下载一个就可以了 下载地址:libcry ...