what is WSL
WSL is a Microsoft official solution for GNU/Linux environment running on windows, instead of either virtual machine or double system, for more information referring to What is Windows Subsystem for Linux | Microsoft Docs.
GNU/Linux environment is a application on windows via WSL, and you can manage this environment by terminal. Now there are several GUI tool having supported it, while Microsoft team is now trying to develop GPU compute on WSL.
installation
for installation refer to Install WSL on Windows 10 | Microsoft Docs, WSL | Ubuntu, WSL - Ubuntu Wiki
Notice: The Windows Subsystem for Linux only runs on your system drive(usually this is your C:
drive).
GPU compute support
Support for GPU compute, the #1 most requested WSL feature, is now ONLY available for preview via the Windows Insider program, referring to GPU accelerated ML training in WSL | Microsoft Docs, GPU accelerated ML training inside the Windows Subsystem for Linux - Windows Developer Blog.
To make it, refer to NVIDIA CUDA preview in WSL 2 | Microsoft Docs, Latest CUDA/CUDA on Windows Subsystem for Linux topics - NVIDIA Developer Forums,
install Insider Preview Builds
download and install the Windows 10 Insider Preview Builds(actually Windows 11 Insider Preview-6/29/2021).
install preview GPU driver
refer to preview GPU driver | Microsoft Docs.
develop
develop based on the above preview GPU driver
if use NVIDIA GPU, the preview GPU driver actually includes the CUDA on WSL 2, refer to CUDA on Windows Subsystem for Linux (WSL) - Public Preview | NVIDIA Developer,
so you can use directly CUDA C++, consulting the CUDA C++ Programming Guide, located in
/usr/local/cuda-10.1/doc
, or referring to CUDA 高性能并行计算入门_cyhbrilliant的博客-CSDN博客_cuda并行计算, and its performance is really good(Ubuntu > WSL > Windows);besides, you can start using your existing Linux workflows through NVIDIA Docker, refer to CUDA on WSL Documentation (nvidia.com);
Wrong try: go on installing cuDNN based on CUDA, you may need to use mirrors source, refer to 使用conda安装python包_cathar的专栏-CSDN博客_conda安装python包 or pip 使用国内镜像源 | 菜鸟教程 (runoob.com), actually there is error around CUDA
lib64
and hence almost frameworks (like TensorFlow2, MindSpore) cannot access to NVIDIA GPU, but PyTorch.Besides, use TensorFlow with DirectML. AMD, Intel and NVIDIA preview GPU drivers all include DirectX WSL driver supporting DX12 APIs, so TensorFlow with a DirectML backend can access to those GPUs,refer to Install the Tensorflow with DirectML package | Microsoft Docs. There is a sample in the following section.
Notice: many operations on WSL need root, so if you meet something wrong, try to type sudo
ahead, and it is also really useful and important to look up the output information; maybe you need some knowledge of Ubuntu
sample
bash:
|
python, refer to docs/site/en/r1/tutorials at master · tensorflow/docs · GitHub:
|
bash:
|
output:
You can see it working well, though there are several warnings, which are almost due to versions, refer to How can I address these warning messages on my first directml attempt? · Issue #117 · microsoft/DirectML · GitHub, 成功解决Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2_张齐贤的博客-CSDN博客.
For more samples, refer to DirectML/TensorFlow at master · microsoft/DirectML · GitHub.
Running Graphical Applications
refer to Running Graphical Applications - Ubuntu Wiki,
troubleshooting
installation
refer to troubleshooting installation of WSL on Windows 10 | Microsoft Docs,
GPU support
Windows 10 Insider Preview Builds
install the Windows 10 Insider Preview Builds, but stop here
solution:
before building this preview, update Windows as well as kernel to the latest general version
Python environment
when you try to use TensorFlow with DirectML, following official steps and setting up Python environment, you may meet errors using either sudo conda
or conda
.
solution:
- First, check the
bashrc
program on WSL:
|
make sure there is export PATH
of miniconda3, like
and then execute it:
|
- Root. you need to give root to write in the direction of miniconda3, refer to conda创建环境报错:NotWritableError: The current user does not have write permissions to a required path._HaotianYan的博客-CSDN博客:
|
*username: user name of your Ubuntu; besides, ~
means /home/{username}
.