• Stars
    star
    288
  • Rank 143,818 (Top 3 %)
  • Language
  • Created over 7 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Tensorflow GPU install instructions for ubuntu 16.04 - Deep learning

Tensorflow GPU install on ubuntu 16.04

These instructions are intended to set up a deep learning environment for GPU-powered tensorflow.
See here for pytorch GPU install instructions

After following these instructions you'll have:

  1. Ubuntu 16.04.
  2. Cuda 9.0 drivers installed.
  3. A conda environment with python 3.6.
  4. The latest tensorflow version with gpu support.

Step 0: Noveau drivers

Before you begin, you may need to disable the opensource ubuntu NVIDIA driver called nouveau.

Option 1: Modify modprobe file

  1. After you boot the linux system and are sitting at a login prompt, press ctrl+alt+F1 to get to a terminal screen. Login via this terminal screen.

  2. Create a file: /etc/modprobe.d/nouveau-blacklist.conf e.g. by

sudo touch /etc/modprobe.d/nouveau-blacklist.conf
  1. Put the following in the above file...
blacklist nouveau
options nouveau modeset=0
  1. Regenerate the kernel initramfs
sudo update-initramfs -u
  1. reboot system
reboot
  1. On reboot, verify that noveau drivers are not loaded
lsmod | grep nouveau

If nouveau driver(s) are still loaded do not proceed with the installation guide and troubleshoot why it's still loaded.

Option 2: Modify Grub load command
From this stackoverflow solution

  1. When the GRUB boot menu appears : Highlight the Ubuntu menu entry and press the E key. Add the nouveau.modeset=0 parameter to the end of the linux line ... Then press F10 to boot.
  2. When login page appears press [ctrl + ALt + F1]
  3. Enter username + password
  4. Uninstall every NVIDIA related software:
sudo apt-get purge nvidia*  
sudo reboot   

Installation steps

  1. update apt-get
sudo apt-get update
  1. Install apt-get deps
sudo apt-get install openjdk-8-jdk git python-dev python3-dev python-numpy python3-numpy build-essential python-pip python3-pip python-virtualenv swig python-wheel libcurl3-dev curl   
  1. install nvidia drivers
# The 16.04 installer works with 16.10.
# download drivers
curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.0.176-1_amd64.deb

# download key to allow installation
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub

# install actual package
sudo dpkg -i ./cuda-repo-ubuntu1604_9.0.176-1_amd64.deb

#  install cuda (but it'll prompt to install other deps, so we try to install twice with a dep update in between
sudo apt-get update
sudo apt-get install cuda-9-0   

2a. reboot Ubuntu

sudo reboot

2b. check nvidia driver install

nvidia-smi   

# you should see a list of gpus printed    
# if not, the previous steps failed.   
  1. Install cudnn
wget https://s3.amazonaws.com/open-source-william-falcon/cudnn-9.0-linux-x64-v7.3.1.20.tgz
sudo tar -xzvf cudnn-9.0-linux-x64-v7.3.1.20.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
  1. Add these lines to end of ~/.bashrc:
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
export CUDA_HOME=/usr/local/cuda
export PATH="$PATH:/usr/local/cuda/bin"

4a. Reload bashrc

source ~/.bashrc
  1. Install miniconda
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh   

# press s to skip terms   

# Do you approve the license terms? [yes|no]
# yes

# Miniconda3 will now be installed into this location:
# accept the location

# Do you wish the installer to prepend the Miniconda3 install location
# to PATH in your /home/ghost/.bashrc ? [yes|no]
# yes    

5a. Reload bashrc

source ~/.bashrc
  1. Create python 3.6 conda env to install tf
conda create -n tensorflow python=3.6

# press y a few times 
  1. Activate env
source activate tensorflow   
  1. update pip (might already be up to date, but just in case...)
pip install --upgrade pip
  1. Install stable tensorflow with GPU support for python 3.6
pip install --upgrade tensorflow-gpu

# If the above fails, try the part below
# pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.2.0-cp36-cp36m-linux_x86_64.whl
  1. Test tf install
# start python shell   
python

# run test script   
import tensorflow as tf   

hello = tf.constant('Hello, TensorFlow!')

# when you run sess, you should see a bunch of lines with the word gpu in them (if install worked)
# otherwise, not running on gpu
sess = tf.Session()
print(sess.run(hello))

or alternatively

tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"

More Repositories

1

DeepRLHacks

Hacks for training RL systems from John Schulman's lecture at Deep RL Bootcamp (Aug 2017)
1,079
star
2

test-tube

Python library to easily log experiments and parallelize hyperparameter search for neural networks
JavaScript
736
star
3

pytorch-lightning-vae

VAE for color images
Python
170
star
4

pix2pix-keras

Image-to-Image Translation with Conditional Adversarial Networks (Pix2pix) implementation in keras
Python
141
star
5

SwiftTryCatch

Adds try-catch support for Swift
Objective-C
139
star
6

keras-deep-learning-paper-implementations

Keras implementation of Deep Learning papers
93
star
7

pytorch-complex-tensor

Unofficial complex tensor and scalar support for Pytorch
Python
78
star
8

SwiftArmyKnife

Collection of low level Swift extensions
Swift
66
star
9

pytorch-gpu-install

Instructions for installing pytorch to run on GPU
36
star
10

Matrix-Factorization-Recommender-Systems-Netflix-Paper-Implementation

Implementation of the Matrix Factorization Recommender System from the Netflix Paper
Python
28
star
11

deep-learning-gpu-box-build-instructions

Instructions and parts for building a deep learning GPU box
22
star
12

pytorch-imagenet-dataset

Imagenet dataset for pytorch
Python
20
star
13

Predicting-floor-level-for-911-Calls-with-Neural-Networks-and-Smartphone-Sensor-Data

Code + data for predicting floor location from smartphone sensor data
Jupyter Notebook
11
star
14

vae_demo

Python
8
star
15

NoNetworkViewController

View controller that takes over screen when there is no internet connection. Critical for networked apps.
Objective-C
7
star
16

WFLocationService

Simplest Location Service for iOS. In Swift
Swift
5
star
17

cifar5

Python
5
star
18

WF-iOS-Categories

Adds JS-like methods to simplify manipulation of some objects
Objective-C
4
star
19

NLP-Viterbi-POS-Tagger-HMM

POS Tagger, N-Grams
Python
4
star
20

docker-flask-nginx-uwsgi-miniconda-3.4

Docker image for flask app running on nginx uwsgi and miniconda with python 3.4 installed
Python
3
star
21

fun_with_git

Python
3
star
22

demo_model

Python
2
star
23

WHARF

Wifi at Hotels, Airports, Restaurants for Free
Shell
2
star
24

sensory

iOS Sensors app
C++
2
star
25

hello

Python
2
star
26

theano-deep-neural-net

Deep neural network implementation using theano and lasagne
Python
1
star
27

debug_023423

Python
1
star
28

deep-learning-blog

My ML/Deep learning blog
HTML
1
star
29

demo_3

Python
1
star
30

NLP_HW3

hw3
Python
1
star
31

PySQLManager

A simple class to abstract MYSQL interactions with python programs
Python
1
star
32

hh

1
star
33

new_system

my vim folder
Vim Script
1
star
34

NLP_HW2

hw2
Python
1
star
35

ghostKey

Ephemeral open source password manager for iOS. Like OnePassword without hidden tricks or network syncing.
Objective-C
1
star
36

6998GoogleMapsFramework

Framework needed for 699807 HW 1 assignment
Objective-C
1
star
37

ml-indoor-outdoor-classifier

Determines whether someone is indoors or outdoors.
OpenEdge ABL
1
star
38

asdfasdf

1
star
39

docker-data-science-flask-ebs

Fully deployable AWS EBS ML App with flask, scipy, pandas, and more inside Docker Container
Python
1
star