Ubuntu 24.04
Sponsored Link

TensorFlow : Install (CPU only)2024/06/21

 

Install TensorFlow which is the Machine Learning Library.

On this example, Install TensorFlow 2 (CPU Only).

[1]

Install Python 3, refer to here.

[2] Install other required packages.
root@dlp:~#
apt -y install python3-dev python3-pip gcc g++ make
[3] Login as a common user and prepare Python virtual environment to install TensorFlow.
ubuntu@dlp:~$
python3 -m venv --system-site-packages ~/tensorflow

ubuntu@dlp:~$
source ./tensorflow/bin/activate

(tensorflow) ubuntu@dlp:~$
[4] Install TensorFlow 2.16.
(tensorflow) ubuntu@dlp:~$
pip3 install --upgrade tensorflow-cpu==2.16.1
# run TensorFlow

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

2024-06-21 04:06:40.189271: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2024-06-21 04:06:40.221540: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
tf.Tensor(835.5763, shape=(), dtype=float32)

# Hello World on TensorFlow

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

2024-06-21 04:07:02.806418: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2024-06-21 04:07:02.838468: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
Hello, TensorFlow World
Matched Content