Ubuntu14.04上源码安装tensorflow

本文安装依赖的环境为Ubuntu14.04、python2.7、cuda8.0、cudnn7.0、opencv2.4.10,这些环境安装不再赘述,网上教程很多。显卡为GTX1060(算力为6.1)。

tensorflow源码安装最重要的是bazel的版本必须与tensorflow的版本一致

1、安装bazel-0.11.1

wget https://github.com/bazelbuild/bazel/releases/download/0.11.1/bazel-0.11.1-installer-linux-x86_64.sh
chmod +x bazel-0.11.1-installer-linux-x86_64.sh
sudo ./bazel-0.11.1-installer-linux-x86_64.sh --prefix=/usr

2、安装tensorflow-1.7.0

下载tensorflow-1.7.0(https://github.com/tensorflow/tensorflow/tree/v1.7.0)

unzip tensorflow-1.7.0.zip
cd tensorflow-1.7.0
./configure

安装选项:(

'''
Do you wish to build TensorFlow with jemalloc as malloc support? [Y/n]: Y

Do you wish to build TensorFlow with CUDA support? [y/N]: y

Please specify the CUDA SDK version you want to use, e.g. 7.0. [Leave empty to default to CUDA 8.0]: 

Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 6.0]: 7.0
Please specify the location where cuDNN 5.0.5 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda]:/usr/local/cuda

Please specify a list of comma-separated Cuda compute capabilities you want to build with.
You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus.
Please note that each additional compute capability significantly increases your build time and binary size. [Default is: 3.5,5.2]6.1
'''

其他选项选N即可

bazel build -c opt //tensorflow/tools/pip_package:build_pip_package

至此完成安装

编译遇到的问题
1、Cuda Configuration Error: Cannot find libdevice.10.bc under /usr/local/cuda-8.0

sudo cp /usr/local/cuda-8.0/nvvm/libdevice/libdevice.compute_50.10.bc /usr/local/cuda-8.0/nvvm/
sudo mv /usr/local/cuda-8.0/nvvm/libdevice.compute_50.10.bc /usr/local/cuda-8.0/nvvm/libdevice/libdevice.10.bc

猜你喜欢

转载自blog.csdn.net/maidabu/article/details/81838220