CentOS Stream 8
Sponsored Link

TensorFlow : Install
2021/04/14
 
Install TensorFlow which is the Machine Learning Library.
On this example, Install TensorFlow 2 (CPU Only).
[1]
[2] Install other required packages.
[root@dlp ~]#
dnf -y install python38-devel gcc gcc-c++ make
[3] Login as a common user and prepare Python virtual environment to install TensorFlow.
If you'd like to install it on System Wide, skip this section and execute the next [4] with root user account.
[cent@dlp ~]$
pip3 install --upgrade virtualenv --user

Collecting virtualenv
  Downloading https://files.pythonhosted.org/packages/91/fb/ca6c071f4231e06a9f0c3bd81c15c233bbacd4a7d9dbb7438d95fece8a1e/virtualenv-20.4.3-py2.py3-none-any.whl (7.2MB)
.....
.....

[cent@dlp ~]$
virtualenv --system-site-packages -p python3 ./venv

created virtual environment CPython3.8.6.final.0-64 in 326ms
  creator CPython3Posix(dest=/home/redhat/venv, clear=False, no_vcs_ignore=False, global=True)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/redhat/.local/share/virtualenv)
    added seed packages: pip==21.0.1, setuptools==54.1.2, wheel==0.36.2
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

[cent@dlp ~]$
source ./venv/bin/activate

(venv) [cent@dlp ~]$
[4] Install TensorFlow 2.2.
(venv) [cent@dlp ~]$
pip3 install --upgrade tensorflow-cpu==2.2
# verify to run TensorFlow

(venv) [cent@dlp ~]$
python3 -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

2021-04-13 19:11:49.602683: I tensorflow/core/platform/cpu_feature_guard.cc:143] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2021-04-13 19:11:49.612976: I tensorflow/core/platform/profile_utils/cpu_utils.cc:102] CPU Frequency: 2593990000 Hz
2021-04-13 19:11:49.615331: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x562020232300 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2021-04-13 19:11:49.615391: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
tf.Tensor(360.39587, shape=(), dtype=float32)

# Hello World on TensorFlow

(venv) [cent@dlp ~]$
python3 -c "import tensorflow as tf; hello = tf.constant('Hello, TensorFlow World'); tf.print(hello)"

2021-04-13 19:12:37.181153: I tensorflow/core/platform/cpu_feature_guard.cc:143] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2021-04-13 19:12:37.189207: I tensorflow/core/platform/profile_utils/cpu_utils.cc:102] CPU Frequency: 2593990000 Hz
2021-04-13 19:12:37.191854: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x55c24453b570 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2021-04-13 19:12:37.194723: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
Hello, TensorFlow World
Matched Content