TensorFlow 2.5.0 RC on WSL2

I wanted to try the upcoming version of tensorflow 2.5
But the challenge is to try it on my wsl2 machine on top on windows.

Here is the recipe !
This Nvidia documentation is to follow along, i just updated the parts for my specific install:

Unfortunately this is only available with windows insider

I recommend having a safe windows environnement to play with, i don’t recommend using this in a work or personal computer for instance, as it can be broken sometimes.

Use the DEV channel.
After installing and done a few updates, you should be on a version 20145+ (recommended 21332+)

after installation type WIN+R and type this command to check your windows version

WSL2

Next you have to install wsl2

You have to make sure that you have the right version of the linux kernel
You may have to change your preferences in advanced option of windows updates and check
receive updates of other Microsoft products

After updating your system you should have an update on this specific item

“Windows Subsystem for Linux Update — 5.10.16”

I recommend uninstall / install a new distro installation to make sure you have the right version

from powershell:

Then inside Ubuntu check your kernel version

Nvidia driver

First you have to update for nvidia driver from WINDOWS.
Do not install nvidia driver inside wsl !

Here is a guide:

Install it according to your product.

CUDA on WSL2

You should install a specific version of cuda, the cuda toolkit with the right version

The version 2.5 is in release candidate so no information on this page yet.

TensorFlow pip packages are now built with CUDA11.2 and cuDNN 8.1.0

Inside WSL install CUDA Toolkit

CUDNN on WSL2

Next we need to install manually cudnn

https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html

I choose “Download cuDNN v8.1.0 (January 26th, 2021), for CUDA 11.0,11.1 and 11.2” , here are the 2 links to download on windows:

Download, copy the files to you home inside wsl, install them in this order

TensorRT is optionnal, here is the install procedure

https://developer.nvidia.com/nvidia-tensorrt-download

Tensorflow

I recommend using miniconda for creating specific python virtual env,

Check that the gpu is detected by tensorflow

Have fun
Have fun