源码安装tensorflow

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u011961856/article/details/76725411

下载tensorflow:

git clone https://github.com/tensorflow/tensorflow

安装python依赖库:

sudo apt-get install python-numpy python-dev python-pip python-wheel

如果是安装tensorflow for python3,则为:


 sudo apt-get install python3-numpy python3-dev python3-pip python3-wheel

要实现GPU计算,还需要安装cuda,cudnn,安装步骤可参考:http://blog.csdn.net/u011961856/article/details/76723285

安装libcupti-dev:


sudo apt-get install libcupti-dev 

安装bazel:

https://docs.bazel.build/versions/master/install.html

进入tensorflow目录

cd tensorflow

运行configure:

./configure

编译pip 安装包:

cpu:


sudo bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package

gpu


sudo bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package 

生成pip安装包,.whl文件:


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

进入目录/tmp/tensorflow_pkg,并查看生成的.whl文件:


cd /tmp/tensorflow_pkg
ls

查询发现生成的安装包名为:

tensorflow-1.3.0rc1-cp27-cp27mu-linux_x86_64.whl

pip安装tensorflow for python2:


sudo pip2 install tensorflow-1.3.0rc1-cp27-cp27mu-linux_x86_64.whl

pip安装tensorflow for python3:


sudo pip3 install tensorflow-1.3.0rc1-cp27-cp27mu-linux_x86_64.whl

测试是否安装成功:

import tensorflow成功,说明安装成功.

阅读更多
博主设置当前文章不允许评论。

博主推荐

换一批

没有更多推荐了,返回首页