安装说明
因为是首次安装学习tensorflow,1.0之后的没有models,所以安装r0.9。
安装过程
- bazel安装
- install dk8
sudo apt-get install openjdk-8-jdk
- clone bazel sourcecode
git clone https://github.com/bazelbuild/bazel.git
- 进入bazel目录
cd bazel
- 切换tags 0.3.1
git checkout tags/0.3.1
- 编译
./compile.sh
- 编辑~/.bashrc文件
vim ~/.bashrc
- 添加bazel的执行文件到PATH
PATH=~/work/opensource/bazel/output/:PATH
- 更新文件配置文件使其生效
source ~/.bashrc
- CUDA安装
- 进入https://developer.nvidia.com/cuda-downloads
- 选择需要下载的cuda,我下载的是cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb
- 解压安装包
sudo dpkg -i xxxx.deb
- 更新
sudo apt-get update
- 安装
sudo apt-get install cuda
- CUDNN下载安装
- 进入下载页,注册
- 下载对应的cudnn,这里我下载了cudnn-8.0-linux-x64-v5.0-ga.tgz,建议下载这个
- 解压
tar xvzf cudnn-8.0-linux-x64-v5.0.tgz
- 复制.h文件到cuda的include
sudo cp include/cudnn.h /usr/local/cuda/include
- 安装pip
- 下载
wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb" --no-check-certificate
- 解压
tar -xzvf pip-1.5.4.tar.gz
- 其他一些工具安装
-
apt-get install pkg-config zip g++ zlib1g-dev unzip
-
sudo apt-get install python-numpy swig python-dev python-wheel
- tensorflow下载安装
- clone sourcecode
git clone --recurse-submodules https://github.com/tensorflow/tensorflow
- 切换分支
git checkout -b r0.9 remotes/orgin/r0.9
- 配置
./configuration a. select python [enter] b. google cloud support [f] c. gpu support [Y] d. gcc [enter] e. cuda sdk [8.0] f. cudnn version [5] g. cudnn paht [enter]
- bazel编译
bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
- 打包
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
- 安装
sudo pip install /tmp/tensorflow_pkg/tensorflow-0.9.0-py2-none-any.whl
注意事项
- tensorflow,bazel,cuda的对应关系,否则会编译通不过的问题。eg:the specified --crosstool_top '//third_party/gpus/crosstoll:crosstool' is not a valid cc_toolchain_suite rule.
- 这里的cudnn版本应该选择5.0,否则0.9下面的model会报错,eg:if using a binary install,upgarde youe cudnn library to match.
--------------------------2017-10-14 更新------安装Python3.6 对应版本---------------------------------------------
安装v1.4.0-rc0版
- 切换tag
git checkout tags/v1.4.0-rc0
-
此时提示:
You have bazel 0.3.1-2017-06-08 (@1f49b6b) installed.
Please upgrade your bazel installation to version 0.5.4 or higher to build TensorFlow!
Configuration finished”
-
切换bazel tag到0.6.1,编译,报错“
原文链接:https://www.f2er.com/ubuntu/352671.html