Install directly in the system without using Anaconda.
First, find the corresponding CUDA version according to the TensorFlow you want to install, and install the corresponding CUDA. For example, I want to install TensorFlow version 2.12, which uses CUDA 11.8, so I download CUDA from here. I use Linux-X86-64-WSL-Ubuntu-2.0, and I choose the installation package of runfile(local). This is the most convenient and recommended!
In the prompt box that pops up, select Install:
After installation, you need to manually add environment variables in
relaunch terminal or
At this point, enter
nvcc --versions to check whether
the installation is successful.
The installation instructions of the HPCC GNN Bundle mention that
Tensorflow should be installed using su so that all users can see it, and must be installed using the same version of Python3 as is embedded in the HPCC Systems platform.
Enter root mode,
pip install nvidia-cudnn-cu11==220.127.116.11
Add environment variables in
CUDNN_PATH=$(dirname $(python -c "import nvidia.cudnn;print(nvidia.cudnn.__file__)"))
pip install --upgrade pip
Install TensorFlow using pip:
pip install tensorflow==2.12.*
Check whether the installation is successful: exit root mode and run
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
Or you can use this to show the name of GPU(s):
import tensorflow as tf
gpu_device_name = tf.test.gpu_device_name()