-
-
Save ThomasLengeling/5c2e1fbeda3e54ceef64b19463fd6d04 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 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 shorthened version of blog post | |
# http://ksopyla.com/2017/02/tensorflow-gpu-virtualenv-python3/ | |
# update packages | |
sudo apt-get update | |
sudo apt-get upgrade | |
#Add the ppa repo for NVIDIA graphics driver | |
sudo add-apt-repository ppa:graphics-drivers/ppa | |
sudo apt-get update | |
#Install the recommended driver (currently nvidia-378) | |
sudo ubuntu-drivers autoinstall | |
sudo reboot | |
#check if drivers were installed | |
nvidia-smi | |
############################################# | |
# Instal CUDA Toolkit 8.0 for x64 Ubuntu 16.04 | |
wget -O cuda_8_linux.run https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_375.26_linux-run | |
sudo chmod +x cuda_8_linux.run | |
./cuda_8.0.61_375.26_linux.run | |
#Do you accept the previously read EULA? | |
#accept | |
#Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 367.48? | |
#n (we installed drivers previously) | |
#Install the CUDA 8.0 Toolkit? | |
#y | |
#Enter Toolkit Location: | |
#/usr/local/cuda-8.0 (enter) | |
#Do you wish to run the installation with ‚sudo’? | |
#y | |
#Do you want to install a symbolic link at /usr/local/cuda? | |
#y | |
#Install the CUDA 8.0 Samples? | |
#y | |
#Enter CUDA Samples Location: | |
#enter | |
# Install cuDNN | |
# go to website and download cudnn-8 https://developer.nvidia.com/cudnn | |
tar -zxvf cudnn-8.0-linux-x64-v5.1.tgz | |
# copy libs to /usr/local/cuda folder | |
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* | |
# isntall python 3 and virtual env | |
sudo apt install python3-pip | |
sudo apt install python3-venv | |
# create virtual environment for tensorflow | |
python3 -m venv tfenv | |
source tfenv/bin/activate | |
# Instal tensorflow package with gpu support | |
(tfenv)$ pip install tensorflow-gpu | |
#or CPU version | |
(tfenv)$ pip install tensorflow | |
# check installation, run simple python scipt from console | |
$ python | |
import tensorflow as tf | |
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcublas.so locally | |
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcudnn.so locally | |
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcufft.so locally | |
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcuda.so locally | |
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcurand.so locally | |
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