CentOS Stream 10

TensorFlow : インストール2025/10/02

 

機械学習ライブラリー, TensorFlow をインストールします。
コンピューターに搭載の NVIDIA GPU が使用できるようにセットアップします。

[1]

こちらを参考に CUDA をインストールしておきます

[2]

こちらを参考に Python 3 をインストールしておきます

[3] その他必要なパッケージをインストールしておきます。
[root@dlp ~]#
dnf -y install cudnn9-cuda-13 python3-devel gcc gcc-c++ make cuda-cudart-13-0
[4] 任意の一般ユーザーでログインして、TensorFlow インストール用の Python 仮想環境を準備します。
TensorFlow をシステムワイドにインストールする場合は、当作業は不要で、root ユーザーで [5] を実行すれば OK です。
[cent@dlp ~]$
python3 -m venv --system-site-packages ~/tensorflow

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

(tensorflow) [cent@dlp ~]$
[5] TensorFlow をインストールします。
(tensorflow) [cent@dlp ~]$
pip3 install --upgrade tensorflow[and-cuda]
# TensorFlow 動作確認

(tensorflow) [cent@dlp ~]$
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

2025-10-01 17:38:44.152506: 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 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

(tensorflow) [cent@dlp ~]$
python3 -c "from tensorflow.python.client import device_lib; device_lib.list_local_devices()"

2025-10-01 17:38:53.088757: 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 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1759307935.375194    3728 gpu_device.cc:2020] Created device /device:GPU:0 with 10260 MB memory:  -> device: 0, name: NVIDIA GeForce RTX 3060, pci bus id: 0000:07:00.0, compute capability: 8.6
関連コンテンツ