How to install tensorflow 2.16

I recently moved from Windows to Ubuntu 24. I tried to install the last TensorFlow with GPU support, but TensorFlow could not find the GPU. To do that, I used Miniconda and noticed that I could not install CUDA 12.3. Also, I have to install 8.9, but looking at the cuDNN website, the last version of supported Ubuntu is 22 instead of the 24 that I’m using. Can someone provide me with a step-by-step guide on how to install TensorFlow on Ubuntu?

Here’s a step-by-step guide to installing TensorFlow with GPU support on Ubuntu 24:

  1. Check GPU Compatibility: Ensure that your GPU is compatible with TensorFlow. You can find a list of supported GPUs on the TensorFlow website.
  2. Install CUDA Toolkit: Since you mentioned you’re using Ubuntu 24, you might encounter compatibility issues with the latest CUDA version. Install CUDA 11.5, which is compatible with Ubuntu 24. You can download it from the NVIDIA website and follow the installation instructions provided.
  3. Install cuDNN: As of now, the latest supported version of cuDNN for Ubuntu is 22. You can download cuDNN 8.9 for Ubuntu 22 from the NVIDIA website and install it following the provided instructions. Despite the version discrepancy, it should still work fine with CUDA 11.5.
  4. Set Environment Variables: After installing CUDA and cuDNN, set the necessary environment variables. Add the following lines to your ~/.bashrc or ~/.bash_profile file:

bash

Copy code

export LD_LIBRARY_PATH=/usr/local/cuda/lib64
export PATH=/usr/local/cuda/bin:$PATH

Then, run source ~/.bashrc or source ~/.bash_profile to apply the changes.
5. Install TensorFlow with GPU Support: You can install TensorFlow using pip within a virtual environment created with Miniconda. First, create a new environment:

bash

Copy code

conda create -n tf-gpu python=3.8
conda activate tf-gpu

Then, install TensorFlow with GPU support:

bash

Copy code

pip install tensorflow-gpu
  1. Verify Installation: Finally, verify that TensorFlow is using your GPU. You can run the following Python code to check:

python

Copy code

import tensorflow as tf
print(tf.config.list_physical_devices('GPU'))

If everything is set up correctly, you should see information about your GPU.

That’s it! You’ve successfully installed TensorFlow with GPU support on Ubuntu 24. Feel free to ask if you encounter any issues along the way. Modified by moderator

Until point 5, everything is fine, but when it comes to installing tensorflow-gpu, this error pops out:

Do you have any suggestions?

1 Like