Ubuntu 16.04 Useful Script – CUDA, cuDNN, etc.

Some useful commands for my personal use, but feel free trying them*:

installing ‘Nvidia’ Display driver

#Check if the graphics card supports the NVidia drivers:
$ lspci | grep -i nvidia
#The video driver information:
$ lshw -c video

* Be careful, the next lines are going to remove your current graphic card driver and if your graphic card supports, it installs the Nvidia driver instead:

$ To install the display drivers, first log out from GUI. Go to a terminal session (ctrl+alt+F2). Then remove the open-source Nouveau drivers:
$ sudo apt-get purge xserver-xorg-video-nouveau
#Removing NVidia drivers:
$ sudo apt purge nvidia*
$ sudo apt-get autoremove
$ sudo apt-get upgrade && sudo apt-get update -y
#List of available drivers:
$ sudo ubuntu-drivers devices
#Install the appropriate NVidia driver from the above list, for example:
$ sudo apt-get install nvidia-387
#check if drivers were installed

# The above command should bring a chart similar to the following image:





* I disabled the ‘secure booting’ to avoid loop after login Ubuntu (it can be done by something like:)

$ sudo apt install mokutil
$ sudo mokutil --disable-validation


installing Cuda | NVIDIA Developer

# For Installing CUDA 9.1, follow the instruction at the official website.

* To not load NVidia drivers if the open-source Nouveau drivers are installed and loaded:
$ sudo nano /usr/lib/modprobe.d/blacklist-nouveau.conf
and add these two lines to ‘blacklist-nouveau.conf’:
blacklist nouveau
options nouveau modeset=0

* Download the ‘.deb’ file instead of ‘.run’
* Always check the latest version (currently is 9.1 in Feb 2018).

# After installation, check if the Cuda installed correctly by:
$ nvcc -V
# If the above command says “NVCC: No such file or directory” then update the PATH that includes the ‘bin’; mine was like:
$ export PATH=/usr/local/cuda-9.1/bin${PATH:+:${PATH}}

# Then update the ‘bash’:

source ~/.bashrc

# Also check if the device with installed CUDA communicates correctly. First, find the executable ‘bandwidthTest’:
$ find / -type f -name bandwidthTest
# Mine was at /usr/local/cuda-8.0/extras/demo_suite, run it and see if works:
$ ./bandwidthTest
More information at NVIDIA official web page

installing CudNN

# First it should be download from the NVIDIA website after creating an account there. I used the Debian file versions and downloaded the following three items:

cuDNN v7.0.5 Runtime Library for Ubuntu16.04 (Deb)

cuDNN v7.0.5 Developer Library for Ubuntu16.04 (Deb)

cuDNN v7.0.5 Code Samples and User Guide for Ubuntu16.04 (Deb)

# Then, navigate to the <cudnnpath> directory containing cuDNN Debian file and install the runtime library, for example:

$ sudo dpkg -i libcudnn7_7.0.5.11-1+cuda9.1_amd64.deb

# Next, install the developer library, for example:

$ sudo dpkg -i libcudnn7-dev_7.0.5.11-1+cuda9.1_amd64.deb

Finally, install the code samples and the cuDNN Library User Guide, for example:

$ sudo dpkg -i libcudnn7-doc_7.0.5.11-1+cuda9.1_amd64.deb 

* Be careful about the versions (e.g. cuda9.1 and cuDNN v7.0.5)

Some additional tips:

Installing ‘pip’:

# First thing first! update & upgrade your system software:

$ sudo apt-get update && sudo apt-get -y upgrade

# Then, install pip for Python 2.7 on Ubuntu 16.04:

$ sudo apt-get install python-pip

# Finally, check if ‘pip’ installed correctly by:

$ pip -V


Installing ruby is necessary for ‘homebrew’:
$ sudo apt install ruby
Installing Linuxbrew is a fork of Homebrew:
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install)"

$ PATH="$HOME/.linuxbrew/bin:$PATH"Edit your ~/.bash_profile to add ~/.linuxbrew/bin to your PATH:$ echo 'export PATH="$HOME/.linuxbrew/bin:$PATH"' >>~/.bash_profile

You’re done! Try installing a package:
$ brew install hello
$ sudo apt-get install build-essential
Installing ‘git’:
$ brew install git -y
After adding a location (‘echo export …’) always refresh source:
$ source ~/.bash_profile
Check if ‘brew’ works well:
$ brew doctor

Install Chromium:
install Chromium from the command line?
$ sudo apt-get install chromium-browser
Open chromium from terminal:
$ chromium-browser

Generall Command:
# find a file with the name of ‘BlahBlah’:
$ find / -type f -name BlahBlah

Installing boot repair on Ubuntu:

$ sudo add-apt-repository ppa:yannubuntu/boot-repair
$ sudo apt-get update
$ sudo apt-get install -y boot-repair && boot-repair

 # Installing ‘Kate‘ text editor:
$ sudo apt-get install kate -y

* Be careful! codes may cause some problems, especially for your graphic card. Use on your own responsibilities.


Leave a Reply to Administrator Cancel reply

Your e-mail address will not be published. Required fields are marked *