Skip to content

Instantly share code, notes, and snippets.

@LuisReyes98
Created March 20, 2023 14:53
Show Gist options
  • Save LuisReyes98/5422d432f26c92ade8c86294c411e11d to your computer and use it in GitHub Desktop.
Save LuisReyes98/5422d432f26c92ade8c86294c411e11d to your computer and use it in GitHub Desktop.

Tensorflow in WSL2 fixes

these notes are only about some fixes I need to do to properly use tensorflow in WSL2 and there was no information about them in the official tutorial

It needs conda to install all the dependencies

python3.9

This workspace was developed using conda and the WSL2 tutorial from tensorflow to use local GPU this tutorial is found at:

https://www.tensorflow.org/install/pip#windows-wsl2

Install tensorflow

3. Create a conda environment

conda create --name tf python=3.9
conda deactivate
conda activate tf

4. GPU setup

If you do not have anm integrated GPU you can skip the following steps

nvidia-smi

Note the packages cudatoolkit and cudnn are C compiled packages ONLY available with conda they are needed so tensorflow can access the GPU this packages do not exist in the PiPy repository.

conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0

some packages or dependencies can be missing to solve them

4.5

if you find the error:

Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory

you will need to enable the paths int the environment

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/python3.8/site-packages/tensorrt/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/

and copy the libdevice.10.bc that was installed in the env, you will need a copy at the same level of the executing file to properly use GPU configs with tensorflow

tutorial:

tensorflow/tensorflow#57679 (comment)

https://docs.nvidia.com/deeplearning/tensorrt/archives/tensorrt-723/install-guide/index.html#installing-pip

4.6

If cuda sdk is not found

sudo apt-get install cuda-toolkit-11-2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment