-
-
Save ksopyla/813a62d6afc4307755e5832a3b62f432 to your computer and use it in GitHub Desktop.
# 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)) |
Is reboot necessary?
btw, the updated driver, didn't work for me ("modprobe: ERROR: could not insert 'nvidia_387_uvm': Unknown symbol in module, or unknown parameter (see dmesg)") , I had to yes | sudo apt-get remove nvidia-387
Up and running configuration for me:
Ubuntu 16.04.3 LTS
GeForce GTX 1080 Ti
TensorFlow: 1.3.0
Python: 3.5.2
nvidia driver: nvidia-387
CUDA: cuda_8.0.61_375.26 + cuda_8.0.61.2
cuDNN: cudnn-8.0-linux-x64-v6.0
Will I only be able to run CUDA & CuDNN in python3?. I am not able to see the above lines that in my machine. In fact after i import nothing happens. Any clue?
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
@saikishor
Tensorflow supports python 2.7, 3.4, 3.5, 3.6. I don't know the answer for the second problem.
it would be nice to add this wget method to get the cudnn file:
https://gist.github.com/mjdietzx/0ff77af5ae60622ce6ed8c4d9b419f45
Can you tell us what virtual env you got this working in. Trying to do something similar with ESXI.
Keep hitting an issue logging back into the Ubuntu UI when I install the NVIDIA graphics driver with specific version. i.e. sudo apt install nvidia-381
. The UI Accepts the user/password, but then just kicks me back to login. To fix it I run sudo apt-get purge nvidia*
It seems to accept sudo ubuntu-drivers autoinstall
and allows me to log in. However the nvidia-smi
command isn't found. Any ideas, pointers welcomed.
Thanks for these instructions. Unfortunately I was unable to get this to work, seems like the versions of the software are a moving target. Here are steps that worked for me yesterday (1/30/18): http://www.sixthdoor.com/deep-learning-setup-tensorflow-gpu-1-4-on-ubuntu-16-04/
@isalirazeg:
0. Register a developer on Nvidia (its free of charge)