Created
July 11, 2016 14:56
-
-
Save AlexJoz/e84eb137bc4cb9389b22e92ef8f03153 to your computer and use it in GitHub Desktop.
tensorflow 0.9 with gpu support for py3 on aws ec2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
# !!! THIS IS NOT A BASH SCRIPT !!! | |
### | |
# named .sh just so Github does correct syntax highlighting | |
# Inspired by https://gist.github.com/AlexJoz/1670baf0b32573ca7923 | |
# | |
# This setup is available as a public AMI in US-East(N. Virginia): ami-60da5a77 | |
# | |
# Tensorflow 0.9 with gpu support (installing cuda drivers and cudnn lib) for python3 with numpy, matplotlib and sklearn installed | |
sudo apt-get update | |
sudo apt-get install -y build-essential git python-pip libfreetype6-dev libxft-dev libncurses-dev libopenblas-dev gfortran python3-matplotlib libblas-dev liblapack-dev libatlas-base-dev python3-dev linux-headers-generic linux-image-extra-virtual unzip python3-numpy swig python3-pandas python-sklearn unzip python3-pip | |
# CUDA | |
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1410/x86_64/cuda-repo-ubuntu1410_7.0-28_amd64.deb | |
sudo dpkg -i cuda-repo-ubuntu1410_7.0-28_amd64.deb && rm cuda-repo-ubuntu1410_7.0-28_amd64.deb | |
sudo apt-get update | |
sudo apt-get install -y cuda | |
# cuDNN | |
# You get the CUDNN_URL by logging into your nivida account and downloading cuDNN | |
# https://developer.nvidia.com/rdp/cudnn-archive (cudnn 7.0) | |
# upload it to instance | |
tar -zxf cudnn-7.0-linux-x64-v4.0-prod.tgz && rm cudnn-7.0-linux-x64-v4.0-prod.tgz | |
sudo cp ./cuda/lib64/* /usr/local/cuda/lib64/ | |
sudo cp ./cuda/include/* /usr/local/cuda/include/ | |
sudo reboot | |
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64" >> ~/.bashrc | |
echo "export CUDA_HOME=/usr/local/cuda" >> ~/.bashrc | |
echo "export PATH=\$PATH:/usr/local/cuda/bin" >> ~/.bashrc | |
# BAZEL | |
# Go to https://github.com/bazelbuild/bazel/releases and download the latest bazel. I use 0.3.0 here. | |
sudo add-apt-repository ppa:webupd8team/java | |
sudo apt-get update | |
sudo apt-get install oracle-java8-installer | |
echo "export JAVA_HOME=/usr/lib/jvm/java-8-oracle" >> ~/.bashrc | |
. ~/.bashrc | |
cd | |
wget https://github.com/bazelbuild/bazel/releases/download/0.3.0/bazel-0.3.0-installer-linux-x86_64.sh | |
chmod +x bazel-0.3.0-installer-linux-x86_64.sh | |
sudo ./bazel-0.3.0-installer-linux-x86_64.sh | |
# TENSORFLOW | |
git clone --recurse-submodules https://github.com/tensorflow/tensorflow | |
cd tensorflow | |
TF_UNOFFICIAL_SETTING=1 ./configure | |
#All of the questions can be answered with default except these trhee: | |
``` | |
Python directory: /usr/bin/python3 | |
Do you wish to build TensorFlow with GPU support? [y/N] y | |
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"]: 3.0 | |
``` | |
bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package | |
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/pip | |
sudo pip3 install --upgrade /tmp/pip/tensorflow-*.whl | |
# REMOVE installers | |
sudo rm -r cuda | |
sudo rm bazel-* | |
sudo rm -r tensorflow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment