Tensorflow从1.6开始从AVX编译二进制文件,所以如果你的CPU不支持AVX
你需要
安装旧版(1.5或之前版本):
pip3 install tensorflow== #version指定版本
但是现在很多基于tensorflow的项目都是用新版本的tensorflow了。所以建议还是使用新版本的tensorflow. 以免遇到很多不必要的问 题。
编译源码安装
1. 下载tensorflow的release 1.12版本的release版本:
https://codeload.github.com/tensorflow/tensorflow/zip/v1.12.2
2. 下载安装Python相关依赖
sudo apt install python-dev python-pip # or python3-dev python3-pip(建议用python3
pip(3) install -U --user pip six numpy wheel setuptools mock(python3 对应用pip3)
pip(3)install -U --user keras_applications==1.0.6 --no-deps
pip(3) install -U --user keras_preprocessing==1.0.5 --no-deps
3. 安装bazel.注意安装bazel 1.8或1.8之前的版本(1.7,1.6)。https://docs.bazel.build/versions/master/install.html
4. 在tensorflow源码目录执行: ./configure
Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python3
Do you wish to build TensorFlow with Apache Ignite support? [Y/n]:n
Do you wish to build TensorFlow with XLA JIT support? [Y/n]: n
Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]:n
Do you wish to build TensorFlow with ROCm support? [y/N]: n
Do you wish to build TensorFlow with CUDA support? [y/N]: n
Do you wish to download a fresh release of clang? (Experimental) [y/N]:n
Do you wish to build TensorFlow with MPI support? [y/N]: n
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]: 使用默认值。
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
pip3 install /tmp/tensorflow_pkg/tensorflow-version-tags.whl
使用docker
如果嫌源码编译安装太麻烦,使用docker镜像。不用配置配置环境,docker镜像已经配置好了tensorflow的的开发环境,支持非 AVX cpu。这样即使在Windows环境中也可使用docker镜像。
docker 镜像安装:
sudo docker pull curlyxi/tensorflow-no-avx:latest