Tensorflow via Pip

Back to Index


Even though we will install Tensorflow with GPU via pip, it can be done in a virtual environment like Miniconda (miniconda installation here).

As always, pay attention to the versions you need to install, specially if you will test someone else's code. If you will create a neural network from scratch, get the latest stable version.

First, create and activate your conda environment:

  • conda create -n TensorflowEnv python=3.7
  • conda activate TensorflowEnv

Then, install CUDA via conda. Change the version to the one you need:

  • conda install -c anaconda cudatoolkit==11.0.221
Finally, install Tensorflow GPU:
  • python -m pip install tensorflow-gpu==2.4.1
Note: The "python -m" command means that the python installed for the active conda environment will execute the pip command. Without it, the Python of WSL (or of the operational system) will be used, and the package will be available for all conda environments, and you won't be able to install different versions of Tensorflow.

Even following these steps, when executing the network, some libraries may be missing. This will lead to Tensorflow to find the GPU and print its name, but fail to link correctly. In my case, the missing libraries were cuDNN and cusolver, and they were installed with:
  • conda install -c anaconda cudnn==8.2.1
  • conda install -c nvidia libcusolver
Note: If you need a previous version of cusolver, then the only way is to install it on the system through:
  • sudo apt-get install libcusolver10 



No comments:

Post a Comment

Global Game Jam 2024

Wow, what a weekend. The Global Game Jam is intense. But I and 3 other members manage to build a game for the theme "Make me laugh&quo...