Table of contents
1. Install WSL2 (Windows Subsystem for Linux)
2. Introduction to WSL using GPU acceleration - source NVIDIA official website
2. Install NVIDIA driver to support GPU
1. The system has installed GetForce Experience
2. Download the driver from NVIDIA official website
3. Use Anaconda to build deep learning on WSL2
(a). WSL install Anaconda, change source
(b). Configure the environment method (can be skipped)
1. Create a virtual environment
2. Activate the virtual environment
3. Choose a deep learning framework for GPU
4. Install tensorflow-gpu2.3.0
(a). Download tensorflow-gpu2.3.0 version
(b). Download the corresponding cudnn7.6.5 version according to tensorflow-gpu
Five, WSL setting TensorFlow-DirectML
1. Create a virtual environment
2. Activate the virtual environment
3. Install the machine learning framework
1. Preparation
1. Install WSL2 (Windows Subsystem for Linux)
2. Introduction to WSL using GPU acceleration - source NVIDIA official website
Typically, developers working in Linux and Windows environments have very disruptive workflows. They must either:
-
use different systems on Linux and Windows, or
-
Dual-booting, ie installing Linux and Windows in separate partitions on the same or different hard drives on the system and then booting to the operating system of choice.
In both cases, the developer had to stop all work and switch systems or reboot. Furthermore, this has historically limited the development of seamless, well-integrated tools and software systems across the two major ecosystems.
WSL enables users to seamlessly transition between the two environments without the need for resource-intensive traditional virtual machines, and to increase productivity and use tools for development and integration of their workflows. What's more, WSL 2 makes applications available on Windows that were hitherto only available on Linux. WSL 2 support for GPUs allows these applications to benefit from GPU-accelerated computing and expands the world of applications that can be developed on WSL 2.
With NVIDIA CUDA support for WSL 2, developers can leverage NVIDIA GPU-accelerated computing through WSL for data science, machine learning, and inference on Windows. GPU acceleration also helps reduce the performance overhead of running applications in near-native WSL-like environments, as it enables more parallel work to be pipelined on the GPU with less CPU intervention.
2. Install NVIDIA driver to support GPU
Install NVIDIA GeForce Game Ready or NVIDIA RTX Quadro Windows 11 on your system
Notice:
This is the only driver you will install. Do not install any Linux display drivers in WSL .
1. The system has installed GetForce Experience
- Search GetForce Experience
- register log in
- View driver
As shown in the picture, the NVIDIA GeForce Game Ready driver already exists (you can choose to download the update)
2. Download the driver from NVIDIA official website
Official driver | NVIDIA https://www.nvidia.cn/Download/index.aspx?lang=cn
- Check the device information
- download
Note: After the installation is successful, the device needs to be restarted
3. Use Anaconda to build deep learning on WSL2
0. Prerequisites
(a). WSL install Anaconda, change source
Refer to the previous article:
(b). Configure the environment method (can be skipped)
Refer to the previous article:
Anaconda builds a deep learning environment py 3.7: tensorflow-gpu2.3.0, pytorch1.12.1_gpu version; (use conda to download cuda and cudnn); configuration environment experience summary_QomolangmaH's blog-CSDN blog https://blog.csdn.net/ m0_63834988/article/details/128841527?spm=1001.2014.3001.5502 (a record of the environment configuration process, including various pits encountered, for reference only)
1. Create a virtual environment
conda create -n gpu python=3.7
2. Activate the virtual environment
conda activate gpu
3. Choose a deep learning framework for GPU
- For TensorFlow:
conda install tensorflow-gpu
- For PyTorch:
conda install pytorch torchvision torchaudio cudatoolkit=<your_cuda_version> -c pytorch
Please refer to the official website for the specific version
Previous PyTorch Versions | PyTorchhttps://pytorch.org/get-started/previous-versions/
The following will take tensorflow-gpu as an example
4. Install tensorflow-gpu2.3.0
(a). Download tensorflow-gpu2.3.0 version
pip install tensorflow-gpu==2.3.0
(b). Download the corresponding cudnn7.6.5 version according to tensorflow-gpu
Using the conda command will download cudnn+cudatoolkit at the same time! ! !
conda install cudnn==7.6.5
(c). Inspection
import tensorflow as tf
print('GPU', tf.config.list_physical_devices('GPU'))
a = tf.constant(3.)
print(a * a)
Five, WSL setting TensorFlow-DirectML
1. Create a virtual environment
conda create -n directml python=3.6
2. Activate the virtual environment
conda activate directml
3. Install the machine learning framework
- For TensorFlow:
pip install tensorflow-directml