Skip to content

Instantly share code, notes, and snippets.

@ereli
Forked from ksopyla/ubuntu16_tensorflow_cuda8.sh
Last active November 9, 2017 13:26
Show Gist options
  • Save ereli/b3d07515f5007ac629de4991893ba3fd to your computer and use it in GitHub Desktop.
Save ereli/b3d07515f5007ac629de4991893ba3fd to your computer and use it in GitHub Desktop.
How to set up tensorflow with CUDA 8 cuDNN 5.1 in virtualenv with Python 3.5 on Ubuntu 16.04 http://ksopyla.com/2017/02/tensorflow-gpu-virtualenv-python3/
# This is shorthened version of blog post
# http://ksopyla.com/2017/02/tensorflow-gpu-virtualenv-python3/
# Get cuda_8.0.61_375.26_linux.run and cudnn-8.0-linux-x64-v5.1.tgz
#
## update packages
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y install gcc make
sudo apt-get -y install libcupti-dev
sudo apt-get install -y python3-pip
sudo apt-get install -y python3-venv
sudo apt-get --reinstall install -y linux-headers-`uname -r`
chmod a+x cuda_8.0.61_375.26_linux.run
sudo sh cuda_8.0.61_375.26_linux.run --driver --silent --toolkit
tar -xzvf cudnn-8.0-linux-x64-v5.1.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*
sudo sh -c "echo '/usr/local/cuda/lib64\n/usr/local/cuda/lib' >> /etc/ld.so.conf.d/nvidia.conf"
sudo ldconfig
# isntall python 3 and virtual env
sudo apt-get -y install python3-pip
sudo apt-get -y install python3-venv
##############################################
# Don't run the following command with sudo! #
##############################################
pip3 install --upgrade pip
# create virtual environment for tensorflow
python3 -m venv tfenv
source tfenv/bin/activate
pip3 install --upgrade tensorflow-gpu
pip3 install --upgrade keras
python3 -c"import tensorflow as tf;tf_session = tf.Session();x = tf.constant(1);y = tf.constant(1);print(tf_session.run(x + y));"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment