How To Install Python TensorFlow On Centos 8
Make sure you have Python 3.5+ installed on your system.
python--versionPython3.6.8Let us first update the system
sudo yum update
Install Tensorflow With Gpu
Install Cuda
https://developer.download.nvidia.com/compute/cuda/11.0.3/local_installers/cuda-repo-rhel8-11-0-local-11.0.3_450.51.06-1.x86_64.rpmsudorpm-icuda-repo-rhel8-11-0-local-11.0.3_450.51.06-1.x86_64.rpmsudoyum-yinstallcudaDepending upon where the libraries get installed, you might run in to following error, when you import tensorflow.
Could not load dynamic library 'libcuda.so.1';
Do following...
cp -p /usr/lib64/libcuda.so.1 /usr/lib/
Install libcudart
wgethttps://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/cauldron/x86_64/media/nonfree/release/nvidia-cuda-toolkit-devel-11.2.0-8.mga8.nonfree.x86_64.rpmsudorpm-invidia-cuda-toolkit-11.2.0-8.mga8.nonfree.x86_64.rpmsudoyuminstallnvidia-cuda-toolkitNow let us install tensorflow using pip.
pipinstalltensorflowTest Tensorflow
Launch Ipython or Python shell and try out these commands.
In[1]:importtensorflowastf2021-07-0321:00:42.953020:Itensorflow/stream_executor/platform/default/dso_loader.cc:53]Successfullyopeneddynamiclibrarylibcudart.so.11.0In[2]:withtf.compat.v1.Session()assess:...:hello=tf.constant('hello world')...:print(sess.run(hello))...:2021-07-0321:00:48.919579:Itensorflow/stream_executor/platform/default/dso_loader.cc:53]Successfullyopeneddynamiclibrarylibcuda.so.12021-07-0321:00:48.934110:Etensorflow/stream_executor/cuda/cuda_driver.cc:328]failedcalltocuInit:CUDA_ERROR_NO_DEVICE:noCUDA-capabledeviceisdetected2021-07-0321:00:48.934146:Itensorflow/stream_executor/cuda/cuda_diagnostics.cc:156]kerneldriverdoesnotappeartoberunningonthishost(ns3273416.ip-5-39-70.eu):/proc/driver/nvidia/versiondoesnotexist2021-07-0321:00:48.936834:Itensorflow/core/platform/profile_utils/cpu_utils.cc:114]CPUFrequency:3700210000Hzb'hello world'If you notice above, there is an error "CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected". I am getting this error because machine has no GPU.
To avoid the above error, make sure you do the following setting.
importosos.environ['CUDA_VISIBLE_DEVICES']="0"Common errors
You might run in to following Tensorflow error while importing "Keras"
Keras requires TensorFlow 2.2 or higher. Install TensorFlow via pip install tensorflow?
Make sure you have Python 3.5+ installed. Then follow the above instructions to install Tensorflow.