How to install and use TensorFlow on centos8

Step 1: Enable and Update EPEL Repository

To download the required packages and dependencies, you’ll first need to install and update the EPEL repository. Use the following two commands:

sudo yum -y install epel-release

 

Step 2: Install Required Packages

Although TensorFlow supports multiple languages, Python is the one that provides the most features.

If you do not have Python installed on CentOS, run the following command to install pip (a package management system for Python) and the language itself:

sudo yum -y install gcc gcc-c++ atlas atlas-devel gcc-gfortran openssl-devel libffi-devel     

 

After install Python in Centos8(How to install Python3.9.6 on Centos8_梦想家DBA的博客-CSDN博客) , check the command  will be displayed as below :

yum -y install python-pip python-devel

 

 

 

Step 3: Create a Virtual Environment

Next, create an environment variable that points to the download URL for TensorFlow. Doing so isolates the package installation from the CentOS system.

Using the pip command, install and upgrade a virtual environment software. We recommend using Virtualenv, a tool specifically designed for creating isolated Python environments.

Use the following command to install and upgrade Virtualenv on CentOS:

pip3 install --upgrade virtualenv

 

Create a new environment by typing:

virtualenv --system-site-packages  ~/venvs/tensorflow

Finally, activate the environment: 

source ~/venvs/tensorflow/bin/activate

 Activating the environment changes the command line prompt, adding the virtual environment’s bin directory as a prefix. This means you are now working inside the virtual environment.

Step 4: Install TensorFlow

After setting up and activating the virtual environment, you can finally move on to installing the TensorFlow library. There are two available software packages, TensorFlow for CPU and TensorFlow for GPU.

Install TensorFlow for CPU

The default software package supports CPU-powered machine-learning workloads. To install the latest stable release of TensorFlow for CPU (recommended for beginners) and dependencies, type:

pip install --upgrade tensorflow

nstall TensorFlow for GPU

TensorFlow for GPU supports GPU-powered machine-learning workloads. To install the latest stable release of TensorFlow for GPU (recommended for beginners), execute the following command:

pip install --upgrade tensorflow-gpu

Step 5: Verify TensorFlow Installation

Verify TensorFlow installation with the following command:

python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值