ubuntu 환경에 TensorFlow 을 설치해보겠습니다.
몇 가지 설치 옵션 중 Installing from sources 방법을 사용하겠습니다.
1.
mkdir ~/dev
cd dev
$ git clone https://github.com/tensorflow/tensorflow
2. java가 설치되어 있지 않다면 설치
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
3.
$ echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
$ curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
4.
$ sudo apt-get update && sudo apt-get install bazel
$ sudo apt-get upgrade bazel
5. https://github.com/bazelbuild/bazel/releases 에서 bazel-0.4.3-installer-linux-x86_64.sh 다운로드
6.
$ chmod +x PATH_TO_INSTALL.SH
$ ./PATH_TO_INSTALL.SH --user
PATH_TO_INSTALL 은 5번에서 다운로드 받은 파일 경로
7.
# For Python 2.7:
$ sudo apt-get install python-numpy python-dev python-wheel
# For Python 3.x:
$ sudo apt-get install python3-numpy python3-dev python3-wheel
8.
$ sudo apt-get install python-pip python-dev
9. https://developer.nvidia.com/cuda-downloads 에서 Download and install Cuda Toolkit
10. https://developer.nvidia.com/cudnn 에서 Download cuDNN v5.1 (August 10, 2016), for CUDA 8.0 - cuDNN v5.1 Library for Linux 다운로드
다운로드한 폴더에서
tar xvzf cudnn-8.0-linux-x64-v5.1-ga.tgz
sudo cp -P cuda/include/cudnn.h /usr/local/cuda/include
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
11.
$ sudo apt-get install libcupti-dev
12. https://www.codeplay.com/products/computesuite/computecpp/download 에서 computecpp 을 다운로드 받은 후
sudo mv DOWNLOAD_PATH /usr/loca
(이 부분 때문에 mac 에서는 OpenCL 을 사용할 수 없습니다. 그리고 TansorFlow 에서 시간복잡도를 줄이는데 큰 역할을 하는 GPU를 사용하는 부분을 제대로 사용하지 못하는 것 같습니다. https://github.com/tensorflow/tensorflow/issues/22)
13.
cd ~/dev/tensorflow
./configure 입력 후 하단과 같이 입력한다
Please specify the location of python. [Default is /usr/bin/python]:
Do you wish to build TensorFlow with Google Cloud Platform support? [y/N] n
No Google Cloud Platform support will be enabled for TensorFlow
Do you wish to build TensorFlow with Hadoop File System support? [y/N] n
No Hadoop File System support will be enabled for TensorFlow
Found possible Python library paths:
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages
Please input the desired Python library path to use. Default is [/usr/local/lib/python2.7/dist-packages]
Using python library path: /usr/local/lib/python2.7/dist-packages
Do you wish to build TensorFlow with OpenCL support? [y/N] y
OpenCL support will be enabled for TensorFlow
Do you wish to build TensorFlow with CUDA support? [y/N] y
CUDA support will be enabled for TensorFlow
Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]:
Please specify the CUDA SDK version you want to use, e.g. 7.0. [Leave empty to use system default]:
Please specify the location where CUDA toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]:
Please specify the Cudnn version you want to use. [Leave empty to use system default]:
Please specify the location where cuDNN library is installed. Refer to README.md for more details. [Default is /usr/local/cuda]:
libcudnn.so resolves to libcudnn.5
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"]:
Please specify which C++ compiler should be used as the host C++ compiler. [Default is ]: /usr/bin/g++
Please specify which C compiler should be used as the host C compiler. [Default is ]: /usr/bin/gcc
Please specify the location where ComputeCpp for SYCL 1.2 is installed. [Default is /usr/local/computecpp]:
14.
# To build with GPU support:
$ 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
# The name of the .whl file will depend on your platform.
$ sudo pip install /tmp/tensorflow_pkg/tensorflow-0.12.1-py2-none-any.whl
mkdir _python_build
cd _python_build
ln -s ../bazel-bin/tensorflow/tools/pip_package/build_pip_package.runfiles/org_tensorflow/* .
ln -s ../tensorflow/tools/pip_package/* .
sudo python setup.py develop