I have successfully installed tensorflow in the conda environment as follows:
conda activate myconda
conda install -c conda-forge cudatoolkit=11.8.0
pip3 install nvidia-cudnn-cu11==8.6.* tensorflow==2.13.*
mkdir -p $CONDA_PREFIX/etc/conda/activate.d
echo 'CUDNN_PATH=$(dirname $(python -c "import nvidia.cudnn;print(nvidia.cudnn.__file__)"))' >> $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
echo 'export LD_LIBRARY_PATH=$CONDA_PREFIX/lib/:$CUDNN_PATH/lib:$LD_LIBRARY_PATH' >> $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
source $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
I can now run tensorflow as follows.
using `idle3`
>>> import tensorflow as tf
>>> tf.__version__
'2.13.0'
>>> tf.config.list_physical_devices('GPU')
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
>>>
GPU was detected correctly.
However, I want to run it directly from the pip environment
, i.e., without using conda
.
I have install it as.
pip3 install nvidia-cudnn-cu11==8.6.* tensorflow==2.13.*
Required cuda has been installed and available correctly.
/usr/local/cuda/bin/nvcc --version
Build cuda_11.8.r11.8/compiler.31833905_0
However,
>>> import tensorflow as tf
>>> tf.__version__
'2.13.0'
>>> tf.config.list_physical_devices('GPU')
[]
>>>
The gpu is not detected.
I tried as follows.
sudo nano .bashrc
export PATH=/usr/local/cuda-11.8/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export CUDA_HOME=/usr/local/cuda
Unfortunately, still not detected.
Could someone help me ?