Difference between revisions of "Tensorflow"

From GISAXS
Jump to: navigation, search
(Installation instructions)
(Installation instructions)
 
(7 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
==Installation instructions==
 
==Installation instructions==
===Virtualenv method===
+
===System-wide CUDA install===
Detailed instructions are provided on the [https://www.tensorflow.org/versions/r0.10/get_started/os_setup.html#virtualenv-installation TensorFlow website].
 
 
# [http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-linux/index.html#ubuntu-installation Install CUDA]
 
# [http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-linux/index.html#ubuntu-installation Install CUDA]
 
## Download CUDA from [https://developer.nvidia.com/cuda-downloads the nVidia site] (CUDA toolkit 7.5):
 
## Download CUDA from [https://developer.nvidia.com/cuda-downloads the nVidia site] (CUDA toolkit 7.5):
Line 15: Line 14:
 
##: apt-get update
 
##: apt-get update
 
##: aptitude install cuda
 
##: aptitude install cuda
 +
# Install CUDA (alternate method, if above doesn't work):
 +
## Download CUDA runfile from [https://developer.nvidia.com/cuda-downloads the nVida site] (CUDA toolkit 7.5 runfile):
 +
##: wget http://developer.download.nvidia.com/compute/cuda/7.5/Prod/local_installers/cuda_7.5.18_linux.run
 +
## Disable nouveau:
 +
##: sudo nano /etc/modprobe.d/blacklist-nouveau.conf
 +
##:: blacklist nouveau
 +
##:: options nouveau modeset=0
 +
##: sudo -s
 +
##: update-initramfs -u
 +
## Install
 +
##: chmod +x cuda_7.5.18_linux.run
 +
##: sudo ./cuda_7.5.18_linux.run
 +
# Install cuDNN
 +
## [https://developer.nvidia.com/cudnn Download cuDNN]
 +
## Extract
 +
##: tar xf cudnn-7.5-linux-x64-v5.0-ga.tgz
 +
## [http://askubuntu.com/questions/767269/how-can-i-install-cudnn-on-ubuntu-16-04/811073 Copy files]
 +
##: cd cuda
 +
##: sudo cp -P include/cudnn.h /usr/include
 +
##: #sudo cp -P lib64/libcudnn* /usr/local/cuda/lib64/ # This is probably not necessary
 +
##: sudo cp -P lib64/libcudnn* /usr/lib/x86_64-linux-gnu/
 +
##: sudo chmod a+r /usr/lib/x86_64-linux-gnu/libcudnn* # This shouldn't be necessary
 +
 +
===Virtualenv method===
 +
Detailed instructions are provided on the [https://www.tensorflow.org/versions/r0.10/get_started/os_setup.html#virtualenv-installation TensorFlow website].
 
# Set up environment
 
# Set up environment
 
##: nano ~/.bashrc
 
##: nano ~/.bashrc
##: # Add these lines to the end of your .bashrc file:
+
##:: # Add these lines to the end of your .bashrc file:
##: export CUDA_HOME=/usr/local/cuda-7.5
+
##:: export CUDA_HOME=/usr/local/cuda-7.5
##: export LD_LIBRARY_PATH=${CUDA_HOME}/lib64
+
##:: export LD_LIBRARY_PATH=${CUDA_HOME}/lib64
##: PATH=${CUDA_HOME}/bin:${PATH}
+
##:: PATH=${CUDA_HOME}/bin:${PATH}
##: export PATH
+
##:: export PATH
 
# Create Virtualenv:
 
# Create Virtualenv:
##: virtualenv --system-site-packages ~/tensorflow
+
#: virtualenv --system-site-packages ~/tensorflow
 
# Activate Virtualenv:
 
# Activate Virtualenv:
##: source ~/tensorflow/bin/activate
+
#: source ~/tensorflow/bin/activate
##: # Prompt should change to start with "(tensorflow)$"
+
#:: # Prompt should change to start with "(tensorflow)$"
 
# Install TensorFlow into Virtualenv:
 
# Install TensorFlow into Virtualenv:
 
#: # Ubuntu/Linux 64-bit, GPU enabled, Python 2.7
 
#: # Ubuntu/Linux 64-bit, GPU enabled, Python 2.7
Line 32: Line 56:
 
#: (tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl
 
#: (tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl
 
#: (tensorflow)$ pip install --upgrade $TF_BINARY_URL
 
#: (tensorflow)$ pip install --upgrade $TF_BINARY_URL
 +
# Exit:
 +
#: deactivate
 
# Test:
 
# Test:
 +
#: source ~/tensorflow/bin/activate
 
#: (tensorflow)$ python
 
#: (tensorflow)$ python
 
#: >>> import tensorflow as tf
 
#: >>> import tensorflow as tf

Latest revision as of 15:35, 13 September 2016

TensorFlow is an open source library for deep learning.

Installation instructions

System-wide CUDA install

  1. Install CUDA
    1. Download CUDA from the nVidia site (CUDA toolkit 7.5):
      wget http://developer.download.nvidia.com/compute/cuda/7.5/Prod/local_installers/cuda-repo-ubuntu1504-7-5-local_7.5-18_amd64.deb
    2. Update root path (if necessary):
      sudo nano /root/.bashrc
      export PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin:/opt/conda/bin
    3. Install deb (c.f. instructions here):
      sudo -s
      dpkg -i cuda-repo-ubuntu1504-7-5-local_7.5-18_amd64.deb
      apt-get update
      aptitude install cuda
  2. Install CUDA (alternate method, if above doesn't work):
    1. Download CUDA runfile from the nVida site (CUDA toolkit 7.5 runfile):
      wget http://developer.download.nvidia.com/compute/cuda/7.5/Prod/local_installers/cuda_7.5.18_linux.run
    2. Disable nouveau:
      sudo nano /etc/modprobe.d/blacklist-nouveau.conf
      blacklist nouveau
      options nouveau modeset=0
      sudo -s
      update-initramfs -u
    3. Install
      chmod +x cuda_7.5.18_linux.run
      sudo ./cuda_7.5.18_linux.run
  3. Install cuDNN
    1. Download cuDNN
    2. Extract
      tar xf cudnn-7.5-linux-x64-v5.0-ga.tgz
    3. Copy files
      cd cuda
      sudo cp -P include/cudnn.h /usr/include
      #sudo cp -P lib64/libcudnn* /usr/local/cuda/lib64/ # This is probably not necessary
      sudo cp -P lib64/libcudnn* /usr/lib/x86_64-linux-gnu/
      sudo chmod a+r /usr/lib/x86_64-linux-gnu/libcudnn* # This shouldn't be necessary

Virtualenv method

Detailed instructions are provided on the TensorFlow website.

  1. Set up environment
    1. nano ~/.bashrc
      # Add these lines to the end of your .bashrc file:
      export CUDA_HOME=/usr/local/cuda-7.5
      export LD_LIBRARY_PATH=${CUDA_HOME}/lib64
      PATH=${CUDA_HOME}/bin:${PATH}
      export PATH
  2. Create Virtualenv:
    virtualenv --system-site-packages ~/tensorflow
  3. Activate Virtualenv:
    source ~/tensorflow/bin/activate
    # Prompt should change to start with "(tensorflow)$"
  4. Install TensorFlow into Virtualenv:
    # Ubuntu/Linux 64-bit, GPU enabled, Python 2.7
    # Requires CUDA toolkit 7.5 and CuDNN v5. For other versions, see "Install from sources" below.
    (tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl
    (tensorflow)$ pip install --upgrade $TF_BINARY_URL
  5. Exit:
    deactivate
  6. Test:
    source ~/tensorflow/bin/activate
    (tensorflow)$ python
    >>> import tensorflow as tf

See Also