Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cbaziotis/ca299b3b6c8a5b21c7c0e7b7c0cca1d3 to your computer and use it in GitHub Desktop.
Save cbaziotis/ca299b3b6c8a5b21c7c0e7b7c0cca1d3 to your computer and use it in GitHub Desktop.
# This is inspired by the fantastic guide https://github.com/saiprashanths/dl-setup
# I have just updated the python-related commands so that everything works in Python 3.
# Tested on Xubuntu 16.04.
# First of all let's update the repos:
sudo apt-get update
# Only if you have a CUDA-compatible Nvidia card, install CUDA.
# Check on the Nvidia website what is the latest driver version which supports your card.
# At the time of this writing it was 367.
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install -y nvidia-367 libcuda1-367 libcudart7.5 nvidia-cuda-toolkit
# You can now check your CUDA version:
# nvcc -V
# you should see info about your CUDA compiler
# Go here https://developer.nvidia.com/rdp/cudnn-download
# (You will have to create an Nvidia Developer Account)
# Download from the section cuDNN v4 for CUDA 7.0 and later (not cuDNN 5)
# it's weird because even though we have CUDA 7.5, we install cuDNN 4 which is marked as being "for CUDA 7.0".
# we do this, however, because at present TensorFlow requires CUDA 7.5 + cuDNN 4.
# the file is: cuDNN v4 Library for Linux
cd ~/Downloads
tar zxvf cudnn-7.0-linux-x64-v4.0-prod.tgz
# contents will be extracted in a folder called "cuda"
cd cuda
sudo cp -P include/cudnn.h /usr/include
sudo cp -P lib64/libcudnn* /usr/lib/x86_64-linux-gnu/
sudo chmod a+r /usr/lib/x86_64-linux-gnu/libcudnn*
# We now install the scipy stack:
sudo apt-get install -y python3-numpy python3-scipy python3-nose python3-h5py python3-skimage python3-matplotlib python3-pandas python3-sklearn python3-sympy
sudo apt-get install -y python3-dev python3-pip g++ python3-pygments python3-sphinx libjpeg-dev zlib1g-dev
sudo pip3 install matplotlib ipython[all] jupyter pandas scikit-image
# We install Theano and Keras from PyPI:
sudo pip3 install theano
sudo pip3 install keras
# We need to add specific instructions to our .theanorc file, to avoid a glibc bug:
echo -e "\n[nvcc]\nflags=-D_FORCE_INLINES\n" >> ~/.theanorc
# by default we install the GPU-enabled version of TensorFlow (requires CUDA):
sudo pip3 install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.9.0-cp35-cp35m-linux_x86_64.whl
# comment the above and uncomment the following to obtain the CPU-only version:
# sudo pip3 install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp35-cp35m-linux_x86_64.whl
# now that we have TensorFLow, we can install TFLearn
sudo pip3 install tflearn
# you can import them in python:
# python3
# >>> import tensorflow as tf
# >>> import theano as t
# >>> import keras as k
# >>> exit()
# An example of ~/.theanorc file which uses gpu, cuDNN, 85% memory allocation and avoids the glibc bug:
#
# [global]
# device=gpu
# floatX=float32
#
# [nvcc]
# flags=-D_FORCE_INLINES
#
# [lib]
# cnmem=.85
#
# [dnn]
# enabled=auto
# Two very useful applications are WEKA (data mining) and Spyder (scientific python IDE with integrated console).
# Uncomment if you want to install them.
# sudo apt-get install -y weka
# sudo apt-get install -y spyder3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment