Tensorflow 在多个系统安装流程。
CentOS 系统:
WHL 安装
1 | pip install scipy sklearn six mock wheel protobuf numpy |
源码安装
Java 安装:1
2
3
4
5
6
7
8
9
10yum -y install java-1.8.0-openjdk*
ls -lrt /etc/alternatives/java // 查看安装路径
vi /etc/profile
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
JRE_HOME=$JAVA_HOME/jre
CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
source /etc/profile
Tomcat 安装:1
2
3
4
5sudo yum install tomcat
sudo yum install tomcat-webapps tomcat-admin-webapps
路径为:/usr/share/tomcat
sudo systemctl start tomcat
sudo systemctl stop tomcat
Bazel 安装:1
2
3
4
5wget https://github.com/bazelbuild/bazel/releases/download/0.6.1/bazel-0.6.1-without-jdk-installer-linux-x86_64.sh
chmod 777 bazel-0.6.1-without-jdk-installer-linux-x86_64.sh
./bazel-0.6.1-without-jdk-installer-linux-x86_64.sh
cp /usr/local/bin/bazel /usr/bin/
cp /usr/local/bin/bazel /usr/bin/bazel-real
编译:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18yum -y install patch git
git clone https://github.com/tensorflow/tensorflow
cd tensorflow
./configure
# 仅CPU,不使用MKL
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
# 仅CPU, 使用MKL(限intel处理器)
bazel build --config=opt --config=mkl //tensorflow/tools/pip_package:build_pip_package
# 仅CPU, 使用MKL,且CPU是Intel XEON或phi处理器
bazel build --config=opt --config=mkl --copt="-DEIGEN_USE_VML" //tensorflow/tools/pip_package:build_pip_package
# 启用CUDA
bazel build --config=opt --config=mkl --copt="-DEIGEN_USE_VML" --config=cuda //tensorflow/tools/pip_package:build_pip_package
# INTEL CPU + CUDA
bazel build --config=opt --config=mkl --config=cuda //tensorflow/tools/pip_package:build_pip_package
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
sudo pip uninstall tensorflow
sudo pip install /tmp/tensorflow_pkg/tensorflow-XXX.whl
Ubuntu 系统源码安装:
1 | conda create -y -n tensorflow python=2.7 |
报错处理
Protobuf 版本报错
protobuf 如果版本不行,需要从源码进行安装:
1 | yum install install autoconf automake libtool |
GLIBC_2.14 not found
问题:
1 | /lib64/libc.so.6: version `GLIBC_2.14' not found |
解决:
1 | wget http://ftp.gnu.org/gnu/glibc/glibc-2.20.tar.gz |
GLIBCXX_3.4.19 not found
问题:
1 | /usr/lib64/libstdc++.so.6: version 'GLIBCXX_3.4.19' not found |
解决:
Undefined symbol: PyUnicodeUCS2_FromStringAndSize
问题:
1 | from scipy import misc |
解决:
1 | pip uninstall scipy |
No such instruction: `rorx $48,%r12,%r12’
问题:
1 | /tmp/ccH9f9L1.s: Assembler messages: |
解决:
1 | bazel build --linkopt='-lrt' -c opt --copt=-mavx --copt=-msse4.2 --copt=-msse4.1 --copt=-mavx2 --copt=-mfma -k //tensorflow/tools/pip_package:build_pip_package |