About the installation of TensorFlow based on Python 2.7 on CentOS

Recently, I am researching AI things, and I need to run an old version of the source code, please refer to: https://github.com/llSourcell/AI_Artist .

The source code is based on Python 2.7 and TensorFlow. Kares uses the 1.x version. It has suffered a lot in order to build the operating environment, and I hope it will be a reference for future generations.

Operating system: CentOS 7
system default Python 2.7
dependency package installation process:
sudo yum -y install epel-release

# The compiler needs to be installed first, otherwise it will affect the installation of subsequent dependent libraries
sudo yum -y install gcc gcc-c++ python-pip python-devel atlas atlas-devel gcc-gfortran openssl-devel libffi-devel

pip install --upgrade virtualenv

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

source ~/venvs/tensorflow/bin/activate

pip install tensorflow
pip install h5py

# Since the interface of keras has changed in subsequent versions, if you find that the corresponding interface method is missing, you can try to switch from version 1.0 to version 2.x or above. When keras is installed, it will be automatically installed together with Scipy. To switch versions, it is recommended to pip uninstall scipy first, and then pip uninstall keras
pip install hard==1.1
pip install h5py
pip install Pillow
pip install sklearn


After the above is executed, try the following code, if it can run, it means that the TensorFlow installation is successful:
# Python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sex = tf.Session ()
print (sess.run (hello))


output:
Hello, TensorFlow!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326221689&siteId=291194637