1) 确认主机支持avx指令
[root@srv1 ~]# cat /proc/cpuinfo | grep avx
2) 安装Python 3.6
[root@srv1 ~]# yum install python3 -y
3) 安装一些软件包
[root@srv1 ~]# yum install python3-devel python3-virtualenv gcc gcc-c++ make -y
4) 安装TensorFlow
[root@srv1 ~]# su - snow
[snow@srv1 ~]$ virtualenv --system-site-packages -p python3 ./venv
Running virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/snow/venv/bin/python3
Also creating executable in /home/snow/venv/bin/python
Installing setuptools, pip, wheel...done.
[snow@srv1 ~]$ source ./venv/bin/activate
(venv) [snow@srv1 ~]$
(venv) [snow@srv1 ~]$ pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade tensorflow==2.0.0b1
# 在TensorFlow 2.0及以上版本中,如果numpy高于1.17则会出现许多警告。因此需要降级numpy至1.16版本
(venv) [snow@srv1 ~]$ pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade numpy==1.16.0
(venv) [snow@srv1 ~]$ pip3 show numpy
Name: numpy
Version: 1.16.0
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email: None
License: BSD
Location: /home/cent/venv/lib/python3.6/site-packages
Requires:
Required-by: tensorflow, tb-nightly, Keras-Preprocessing, Keras-Applications, h5py
5) 验证TensorFlow
(venv) [snow@srv1 ~]$ python3 -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
2020-07-26 23:46:23.047533: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2801355000 Hz
2020-07-26 23:46:23.048084: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x5633e28df970 executing computations on platform Host. Devices:
2020-07-26 23:46:23.048148: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): <undefined>, <undefined>
tf.Tensor(545.2815, shape=(), dtype=float32)
(venv) [snow@srv1 ~]$ python3 -c "import tensorflow as tf; hello = tf.constant('Hello, TensorFlow World'); tf.print(hello)"
2020-07-26 23:48:13.047533: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2801355000 Hz
2020-07-26 23:48:13.815812: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x5633f4d64910 executing computations on platform Host. Devices:
2020-07-26 23:48:13.815899: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): <undefined>, <undefined>
Hello, TensorFlow World
|