Cannot install tensorflow on Anaconda/miniconda with CUDA 12.5

Hello, I have been struggling to install TensorFlow all day without success. I keep encountering issues with incompatible libraries and insufficient Python versions. After changing versions, another library becomes incompatible, and I end up in an endless loop. Here are my system details:

CUDA version: 12.5
NVIDIA SME version: 5.5.85

I have both Anaconda and Miniconda installed I have tried using different versions of Python Despite multiple attempts, I have not been able to successfully install TensorFlow. I have tried creating virtual environments using both venv and conda, and I have followed various installation guides, but nothing seems to work. I would like to use the most recent version of TensorFlow for training purposes. Could someone please provide a step-by-step guide or any advice on how to resolve this issue? Thank you in advance for your help.

Please help me!

1 Like

Hi @Gabriel_Rodriguez, You can see the list of test build configurations for the specific Tensorflow version here.

Also currently the latest version Tensorflow 2.16.1 has an issue with GPU. please refer to this issue for further updates. Thank You.

Welcome @Gabriel_Rodriguez to the TensorFlow Forum!

You can try the following:

  1. Create a fresh conda virtual environment and activate it like this:
conda create -n tf python=3.11
conda activate tf
  1. pip install --upgrade pip,
  2. pip install tensorflow[and-cuda],
  3. Set environment variables:

Locate the directory for the conda environment in your terminal window by running in the terminal:

echo $CONDA_PREFIX

Enter that directory and create these subdirectories and files:

cd $CONDA_PREFIX
mkdir -p ./etc/conda/activate.d
mkdir -p ./etc/conda/deactivate.d
touch ./etc/conda/activate.d/env_vars.sh
touch ./etc/conda/deactivate.d/env_vars.sh

Edit ./etc/conda/activate.d/env_vars.sh as follows:

#!/bin/sh

# Get the ptxas directory  
PTXAS_DIR=$(dirname $(dirname $(python -c "import nvidia.cuda_nvcc; print(nvidia.cuda_nvcc.__file__)")))

# Set PATH to include the directory containing ptxas
export PATH=$(find ${PTXAS_DIR}/*/bin/ -type d -printf "%p:")${PATH:+:${PATH}}

Edit ./etc/conda/deactivate.d/env_vars.sh as follows:

#!/bin/sh

# Unset environment variables
unset PTXAS_DIR
  1. Verify the GPU setup:
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

I have submitted the pull request to update the official TensorFlow installation guide.

I hope it helps!