<jupyter_start><jupyter_text>Fastai on WSL 2 with Cuda> "how to **NOT** get an operational corporate workstation with windows 10, cuda, wsl2, fastai, pytorch..."- show_tags: true- toc: true- branch: master- badges: false- comments: true- categories: [WSL, fastai, WSL2, cuda] This is based on what is explained inhttps://forums.fast.ai/t/fastai-on-wsl-2-ubuntu-0-7-0-or-any-version/76651  install update of nvidia drivers Based on [Deep Learning Course ForumsPlatform: Windows 10 using WSL2 w/GPUfastai users](https://forums.fast.ai/t/platform-windows-10-using-wsl2-w-gpu/73521) - create nvidia account- download quadro driver from https://developer.nvidia.com/cuda/wsl/download (460.15)- install ```bash(xgboost) guillaume@LL11LPC0PQARQ:~/git/guillaume_blog$ nvidia-smi.exeMon Sep 21 16:00:46 2020+-----------------------------------------------------------------------------+| NVIDIA-SMI 460.15       Driver Version: 460.15       CUDA Version: 11.1     ||-------------------------------+----------------------+----------------------+| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC || Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. ||===============================+======================+======================||   0  Quadro M1000M      WDDM  | 00000000:01:00.0  On |                  N/A || N/A   59C    P0    N/A /  N/A |    905MiB /  4096MiB |      0%      Default |+-------------------------------+----------------------+----------------------+```  install of WSL2 and convert existing images Open a PowerShell window as an AdministratorRun wsl --set-default-version 2  update KB{% include alert.html text="--set-default-version 2 is not a valid option. KB4566116 should be installed" %}This can be downloaded from [Catalog Microsoft Update](http://www.catalog.update.microsoft.com/Search.aspx?q=KB4566116)  update kernel version If you see this message after running the command: WSL 2 requires an update to its kernel component. For information please visit https://aka.ms/wsl2kernel. You still need to install the MSI Linux kernel update package. Download from https://docs.microsoft.com/en-us/windows/wsl/install-win10step-4---download-the-linux-kernel-update-package  set default WSL to be version 2 ```PS C:\WINDOWS\system32> wsl --set-default-version 2```  convert existing images ```PS C:\WINDOWS\system32> wsl --list --verbose  NAME            STATE           VERSION* Ubuntu-18.04    Running         1PS C:\WINDOWS\system32> wsl --set-version Ubuntu-18.04 2La conversion est en cours. Cette opération peut prendre quelques minutes...Pour plus d’informations sur les différences de clés avec WSL 2, visitez https://aka.ms/wsl2La conversion est terminée.```It took a while (~1 hour) for my unique ubuntu image. And at the end it has worked.```PS C:\WINDOWS\system32> wsl --list --verbose  NAME            STATE           VERSION* Ubuntu-18.04    Stopped         2```  install of nvidia drivers under ubuntu [Installation instructions)(https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=deblocal)```bashwget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pinsudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600wget https://developer.download.nvidia.com/compute/cuda/11.0.3/local_installers/cuda-repo-ubuntu1804-11-0-local_11.0.3-450.51.06-1_amd64.debsudo dpkg -i cuda-repo-ubuntu1804-11-0-local_11.0.3-450.51.06-1_amd64.debsudo apt-key add /var/cuda-repo-ubuntu1804-11-0-local/7fa2af80.pubsudo apt-get updatesudo apt-get -y install cuda```<jupyter_code>!cat /usr/local/cuda/version.txt
!/usr/local/cuda/samples/4_Finance/BlackScholes/BlackScholes<jupyter_output>[/usr/local/cuda/samples/4_Finance/BlackScholes/BlackScholes] - Starting...
CUDA error at ../../common/inc/helper_cuda.h:777 code=35(cudaErrorInsufficientDriver) "cudaGetDeviceCount(&device_count)"<jupyter_text>There is an error when launching CUDA samples. Googling that error maybe my video card is running on low driver version? I have posted on nvidia (cuda+wsl) forum: https://forums.developer.nvidia.com/t/cuda-sample-throwing-error/142537/18 (update 09-22: it is not possible to have cuda on wsl2 if not in Windows Insider build from Dev Channel. (20145 or higher)){% include alert.html text="because I am in version 1909 (**18363**.1049), it won't work for me. ;(" %}  cuda for WSL Here is a link that could be interesting: https://docs.nvidia.com/cuda/wsl-user-guide/index.html According to this, I should not have installed cuda but cuda-toolkit. `Do not choose the cuda, cuda-11-0, or cuda-drivers meta-packages under WSL 2 since these packages will result in an attempt to install the Linux NVIDIA driver under WSL 2.`Is it causing my issue?```bashapt-get install -y cuda-toolkit-11-0```<jupyter_code>!/usr/local/cuda/bin/nvcc --version<jupyter_output>nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Wed_Jul_22_19:09:09_PDT_2020
Cuda compilation tools, release 11.0, V11.0.221
Build cuda_11.0_bu.TC445_37.28845127_0<jupyter_text>install a new distro (ubuntu 20.04) Because I cannot use windows store, I have to manually install https://docs.microsoft.com/fr-fr/windows/wsl/install-manual Installation by just launching Ubuntu_2004.2020.424.0_x64.appx.I have now 2 distros, ```PS C:\WINDOWS\system32> wsl --list -v  NAME            STATE           VERSION* Ubuntu-18.04    Running         2  Ubuntu-20.04    Running         2```  WSL2 and network There is a change of network architecture between WSL 1 and WSL 2.In WSL 2, a new network interface is available: ```Carte Ethernet vEthernet (WSL) :   Suffixe DNS propre à la connexion. . . :   Adresse IPv6 de liaison locale. . . . .:    Adresse IPv4. . . . . . . . . . . . . .: 192.168.81.193   Masque de sous-réseau. . . . . . . . . : 255.255.255.240   Passerelle par défaut. . . . . . . . . :```  Revert image to WSL1 to get back network access ```PS C:\WINDOWS\system32> wsl --set-version Ubuntu-18.04 1La conversion est en cours. Cette opération peut prendre quelques minutes...La conversion est terminée.``````PS C:\WINDOWS\system32> wsl --list -v  NAME            STATE           VERSION* Ubuntu-18.04    Stopped         1  Ubuntu-20.04    Stopped         2```  access to linux files from windows For running state distros:Files are available at `\\wsl$\`.For stopped state distros:Files are available at `C:\Users\\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu*\LocalState\rootfs`  some usefull wsl commands **List distros**<jupyter_code>!wsl --list --verbose<jupyter_output><empty_output><jupyter_text>```bash  NAME            STATE           VERSION* Ubuntu-18.04    Running         1  Ubuntu-20.04    Stopped         2``` **Stop a distro**<jupyter_code>!wsl --terminate Ubuntu-18.04<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1547137073452863, 'fraction_numerical': 0.05884904569115095, 'mean_word_length': 3.102609727164887, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 23, 'https://': 12, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '657817', 'license': 'Apache-2.0', 'n_tokens_mistral': 2550, 'n_tokens_neox': 2167, 'n_words': 635, 'path': '_notebooks/2020-09-21-Windows10-fastai-wsl2-cuda.ipynb', 'repo_name': 'castorfou/guillaume_blog', 'size': '6916'}