archlinux下源码编译tensorflow
1. 环境准备
$ sudo pacman -S bazel
2. 下载源码
获取源码
$ git clone https://github.com/tensorflow/tensorflow.git
下载miniconda
目前版本下,python3.6使用就很可以,不下最新的python3.7的miniconda,下载后
$ bash Miniconda3-4.5.1-Linux-x86_64
安装完成后千万不要pip install tensorflow 或者 conda install tensorflow,这样会安装未编译的版本,最后就算是卸载,也要把一些依赖卸载,干脆别装
3. 编译
$ cd (path)/tensorflow (path)为你git clone下的目录
$ ./configue (之后一路下去都选no, 其他的默认就可以了)
编译
$ bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
编译成功后的信息
At global scope:
cc1plus: warning: unrecognized command line option '-Wno-self-assign'
Target //tensorflow/tools/pip_package:build_pip_package up-to-date:
bazel-bin/tensorflow/tools/pip_package/build_pip_package
INFO: Elapsed time: 9402.576s, Critical Path: 397.05s
INFO: 1944 processes: 1944 local.
INFO: Build completed successfully, 2104 total actions
生成whl文件
就在tensorflow 目录下
$ bazel-bin/tensorflow/tools/pip_package/build_pip_package ~/tensorflow_pkg
~/tensorflow_pkg是输出目录,之后.wheel文件就在该目录下, 运行输出如下:
2018年 12月 28日 星期五 14:21:09 CST : === Preparing sources in dir: /tmp/tmp.BVOrF1c3FU
~/App/tensorflow ~/App/tensorflow
~/App/tensorflow
2018年 12月 28日 星期五 14:21:27 CST : === Building wheel
warning: no files found matching '*.pyd' under directory '*'
warning: no files found matching '*.pd' under directory '*'
warning: no files found matching '*.dll' under directory '*'
warning: no files found matching '*.lib' under directory '*'
warning: no files found matching '*.h' under directory 'tensorflow/include/tensorflow'
warning: no files found matching '*' under directory 'tensorflow/include/Eigen'
warning: no files found matching '*.h' under directory 'tensorflow/include/google'
warning: no files found matching '*' under directory 'tensorflow/include/third_party'
warning: no files found matching '*' under directory 'tensorflow/include/unsupported'
2018年 12月 28日 星期五 14:22:08 CST : === Output wheel file is in: /home/lee/tensorflow_pkg
4. 安装
cd ~/tensorflow_pkg
pip install tensorflow-1.12.0-cp36-cp36m-linux_x86_64.whl
这里会自动下载依赖,完成