- Make sure
nvidia-smi
worked after installing the NVIDIA GPU driver conda install -c nvidia cuda-toolkit
See https://anaconda.org/nvidia/cuda-toolkitpip install nvidia-cudnn-cu12
See https://pypi.org/project/nvidia-cudnn-cu12/
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=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/:$CUDNN_PATH/lib' >> $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
source $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
pip install --upgrade pip
pip install tensorflow==2.12.*
import tensorflow as tf
print(tf.__version__)
print(tf.test.is_built_with_cuda()) # check if CUDA is used
print(tf.config.list_physical_devices('GPU')) # show GPU numbers
print(tf.test.is_gpu_available(cuda_only=False, min_cuda_compute_capability=None)) # check if GPU is available