Tensorflow快速编译

1. 配置环境变量使得./configure不用手动选择是否下载全新的llvm等,环境变量如下:

export TF_NEED_SEASTAR=0
#还有很多类似的,详见configure.py

2. 在TensorFlow的编译目录里执行:

tensorflow/tools/ci_build/builds/configured CPU

来reconfig。

3. 使用configure来配置参数。

./configure

4. 使用bazel编译打包。

bazel build -j 32 --verbose_failures -c opt --copt=-march=native --copt=-mfpmath=both --linkopt=-lrt --linkopt=-ltcmalloc //tensorflow/tools/pip_package:build_pip_package

bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

其中:

ID参数意义
1-j多少个CPU并行编译
2verbose_failures如果报错显示细节
3-c编译参数
4linkopt连接参数

 

5. 将TensorFlow安装到virtual env下,首先创建一个Python virtual env

virtualenv --always-copy tf_venv

6. source 这个virtual env

cd tf_venv && source ~/.bashrc && source bin/activate

7. 安装一些TensorFlow的依赖,比如numpy等后安装TensorFlow。

pip install -r /tmp/requirements.txt -i https://pip.sankuai.com/simple
pip install /tmp/tensorflow_pkg/*.whl --upgrade -i https://pip.sankuai.com/simple

#如果报找不到sankuai.com,请手动换成清华.

如果报没有requirement.txt文件请手动安装:

absl-py==0.1.5
apache-beam==2.1.1
appdirs==1.4.3
autograd==1.1.11
avro==1.8.2
backports-abc==0.5
backports.shutil-get-terminal-size==1.0.0
backports.ssl-match-hostname==3.5.0.1
backports.weakref==1.0rc1
bleach==1.5.0
boto==2.47.0
bz2file==0.98
cachetools==2.0.1
certifi==2017.4.17
chardet==3.0.4
configparser==3.5.0
crcmod==1.7
cycler==0.10.0
decorator==4.0.11
dill==0.2.6
entrypoints==0.2.3
enum34==1.1.6
funcsigs==1.0.2
functools32==3.2.3.post2
future==0.16.0
futures==3.1.1
gapic-google-cloud-pubsub-v1==0.15.4
gensim==3.4.0
gevent==1.2.2
google-apitools==0.5.11
google-auth==1.1.1
google-auth-httplib2==0.0.2
google-cloud-bigquery==0.25.0
google-cloud-core==0.25.0
google-cloud-pubsub==0.26.0
google-gax==0.15.15
googleapis-common-protos==1.5.3
googledatastore==7.0.1
greenlet==0.4.12
grpc-google-iam-v1==0.11.4
grpcio==1.6.3
h5py==2.7.1
html5lib==0.9999999
httplib2==0.9.2
idna==2.5
#ipykernel==4.6.1
ipython==5.5.0
ipython-genutils==0.2.0
Jinja2==2.9.6
joblib==0.11
jsonschema==2.6.0
#jupyter-client==5.1.0
jupyter-core==4.3.0
Keras==2.0.5
Markdown==2.6.9
MarkupSafe==1.0
matplotlib==2.0.2
mistune==0.7.4
mock==2.0.0
mpmath==0.19
msgpack-numpy==0.4.1
msgpack-python==0.4.8
nbconvert==5.3.1
nbformat==4.4.0
networkx==1.11
nltk==3.2.4
#notebook==5.2.0
numpy==1.14.5
oauth2client==3.0.0
olefile==0.44
packaging==16.8
pandas==0.20.2
pandocfilters==1.4.2
pathlib2==2.3.0
pbr==3.0.1
pexpect==4.2.1
pickleshare==0.7.4
Pillow==4.1.1
ply==3.8
prompt-toolkit==1.0.15
proto-google-cloud-datastore-v1==0.90.4
proto-google-cloud-pubsub-v1==0.15.4
protobuf==3.5.0.post1
ptyprocess==0.5.2
pyasn1==0.3.7
pyasn1-modules==0.1.5
Pygments==2.2.0
pyparsing==2.2.0
pyrouge==0.1.3
python-dateutil==2.6.0
pytz==2017.2
PyWavelets==0.5.2
PyYAML==3.12
#pyzmq==16.0.3
requests==2.18.1
rsa==3.4.2
scandir==1.6
scikit-image==0.13.0
scikit-learn==0.18.1
scipy==0.19.0
seaborn==0.7.1
Shapely==1.6.3
simplegeneric==0.8.1
singledispatch==3.4.0.3
six==1.11.0
sklearn==0.0
smart-open==1.5.3
subprocess32==3.2.7
sympy==1.0
tabulate==0.8.2
tb-nightly==1.5.0a20171121
tensor2tensor==1.0.8
tensorlayer==1.5.2
#tensorpack==0.7.1
termcolor==1.1.0
terminado==0.6
testpath==0.3.1
tflearn==0.3.2
Theano==0.9.0
tornado==4.5.2
tqdm==4.19.4
traitlets==4.3.2
urllib3==1.21.1
wcwidth==0.1.7
Werkzeug==0.12.2

即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值