Keep Sharp

Log of Setting Up Deep Learning Environment in Ubuntu14.04

[Hardware] Beginner's Configurations

  • EVGA Nvidia Graphics Card variation explaination

    • ACX 2.0+: advanced air cooling system
    • SC: slightly super clocked
    • Classified/FTW: highest super clocked
    • Hybrid: water loop cooling system
    • BP: pure esthetic considerations, black plate
    • K|NGP|N: pre-binned gpu
    • ideal options: GTX980Ti ACX 2.0+; GTX980Ti SC ACX 2.0+ (w/BP); GTX 980Ti Classified ACX 2.0+; GTX980Ti Hybrid
  • CPU: 40 PCIe lanes, each graphics card will consume 8 PCIe lanes, i7 5820K has 28, which can support 2 GTX980Ti SLI crossfire; in Q3/Q4 of 2016, new graphics card with Pascal architechture will be release, can buy more GTX980Ti cards and upgrade cpu to i7 5930 or above which has 40 lanes

  • Motherboard: PCIe 3.0 support, 5 or more slots to support multiple GPUs, usually 1 GPU takes two slots

  • Memory: twice size of GRAM (GTX980Ti has 6GB GRAM)

  • PSU: i7 5820K is 150W, GTX980Ti is 250W, whole system with 2 cards consumes 750-800W, 1000W will be enough for 2 cards. G2 style is better than G1 style

  • Ref

Order

Amazon: service really bad, slow and came as broken packaging plus i had to pick up by myself

B&H Photo: very good, DHL sent it to my lab (US2HK) the third day after the order with perfect packaging

Ref: Andrej Karpathy's List

Realtek 802.11 wireless adaptor driver

  • for new kernels (maybe > 3.13), do not use this repo abperiasamy/rtl8812AU_8821AU_linux, instead use this one https://github.com/gnab/rtl8812au. Before compilation step, need to first install some basic dependency sudo apt-get install build-essential, don't install linux-generic, it will upgrade kernel.

  • bothering thing: after each reboot, in the login page, wifi ask for password and certificate, this is mostly happened when the network is Protected EAP (PEAP) enterprises type. The way to let it auto login without asking for password in the login page is edit /etc/networkmanager/system-connections/sMobileNet file, change line password-flags=1 to password=123realpsd321

vim configuration

  • by default it contains a useless vim-tiny, remove it by sudo apt-get autoremove vim-tiny, then install vim-gnome or vim-gtk, if run sudo apt-get install vim will found missing a lot of support, for example clipboard, python. vim-gnome and vim-gtk contains almost all the supports

  • after the PluginInstall of YouCompleteMe, you need to compile it

cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer
  • install pathogen: bascially put pathogen.vim inside .vim/autoload folder

  • the solarized vim may look horrible untill now, but wait till next step

solarize gnome-terminal and vim

  • solarize gnome-terminal:

    • click Edit ▸ Preferences ▸ Profiles, create a new profile named solarized
    • solarize it: remember to select the new profile solarized we just created

    bash git clone https://github.com/Anthony25/gnome-terminal-colors-solarized.git cd gnome-terminal-colors-solarized ./install.sh

  • now do ls, you will found colors are gone, find colors back by:

git clone https://github.com/seebi/dircolors-solarized.git
cp dircolors-solarized/dircolors.ansi-universe ~/.dircolors

actually you will find in .bashrc file some commands like

eval `dircolors /path/to/.dircolors`

can change color schemes depending on personal flavor, need to copy related codes from .bashrc to .zshrc if using oh-my-zsh.

  • basic .vimrc configuration:
" add for vundle
set nocompatible
filetype off

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

Plugin 'gmarik/Vundle.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'bling/vim-airline'
Plugin 'altercation/vim-colors-solarized'
Plugin 'tpope/vim-fugitive'
Plugin 'mattn/emmet-vim'
Plugin 'sukima/xmledit'
Plugin 'scrooloose/nerdtree'
Plugin 'majutsushi/tagbar'
Plugin 'fatih/vim-go'

call vundle#end()
filetype plugin indent on
set encoding=utf-8

execute pathogen#infect()
set background=dark
set t_Co=16
set colorcolumn=80
set cursorline
let g:solarized_termcolors=16
let g:solarized_termtrans=0
call togglebg#map("<F5>")
colorscheme solarized


" trivial settings
syntax on
set backspace=indent,eol,start
set nu hlsearch is expandtab
set ts=4
set sw=4
hi CursorLineNr ctermbg=15 ctermfg=5
imap jk <Esc>


" copy to X11 buffer
set clipboard=unnamed

au BufRead,BufNewFile *.md set filetype=markdown

" after PluginInstall of ycm, you need to compile it, check github page
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'

" for switching between splits
set splitbelow
set splitright
set wmh=0
nmap <c-j> <c-w>j
nmap <c-k> <c-w>k
nmap <c-h> <c-w>h
nmap <c-l> <c-w>l

" for vim-airline, need to install
" powerline prepatched fonts so that
" arrow display correctly
set laststatus=2
let g:airline_powerline_fonts = 1
let g:airline_theme = "powerlineish"

" disable conceal for tex files
let g:tex_conceal = ""

for advanced vim / neovim configuration, check my dotfiles.

ssh and login using key

  • need to install ssh server (by default it is not included)
sudo apt-get install openssh-server
  • in client, using ssh-keygen -t rsa, it's better to not change keyfile name, also no need to enter passphrase, just keep hitting enter, then copy id_rsa.pub content to server's .ssh/authorized_keys file. By default it use id_rsa file to do the matching, that's why better to not change keyfile name. Otherwise, have to specify which private key file (IdentityFile) to use for each Host/User.

vnc

This is a bit different than my last post

  • server: sudo apt-get install tightvncserver, then will have vncserver command, try play with vncserver, vncserver -kill :1 and check ~/.vnc/ folder
  • gnome desktop environment: sudo apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal, xfce desktop is ugly and not recommended
  • configuration: edit/create /etc/init.d/vncserver to be:
#!/bin/bash
PATH="$PATH:/usr/bin/"
export USER="myname"
DISPLAY="1"
DEPTH="16"
GEOMETRY="1024x768"
OPTIONS="-depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY} -localhost" # for ssh tunneling
. /lib/lsb/init-functions

case "$1" in
start)
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
;;

stop)
log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;

restart)
$0 stop
$0 start
;;
esac
exit 0

next:

sudo chmod +x /etc/init.d/vncserver
sudo service vncserver start
  • client: sudo apt-get install xvnc4viewer, then will have vncviewer command, try vncviewer localhost:1 when using ssh tunneling

  • actually system already has a nice tool vino, check video VNC Ubuntu 14.04 Remote Desktop Setup, try tick/untick require-encryption in dconf if the client has problem connecting to server.

matlab

  • crack:

    • installation key: 09806-07443-53955-64350-21751-41297
    • copy libmwservices.so to $MATLABPATH/bin/glnx64 folder
  • add shortcut:

    • download a matlab icon from google image
    • create /usr/share/applications/matlab.desktop file, content:

    plain [Desktop Entry] Type=Application Name=Matlab GenericName=Matlab 2015b Comment=Matlab:The Language of Technical Computing Exec=/usr/local/MATLAB/R2015b/bin/matlab -desktop Icon=/usr/local/MATLAB/Matlab.png Terminal=false Categories=Development;Matlab;

opencv with cuda

  • ref1, ref2

  • cuda/cudnn: FAIR fucnn install guide, no need to install build-essential and especially linux-generic, already installed in above. cuda7.5 contains nvidia driver 352, even i installed 358 before this, after installation of cuda7.5, the driver version downgrades to 352, but nvidia-settings remains 358

  • cuda samples:

cd /usr/local/cuda/samples
sudo make all -j8

./deviceQuery will give information about my GTX980Ti.

  • install dependencies:
sudo apt-get install libopencv-dev build-essential checkinstall cmake pkg-config yasm libtiff4-dev libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils

I already installed numpy through pip (slow but with up-to-date version), so no python-numpy here for me.

Install ffmpeg:

sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get install ffmpeg
sudo apt-get install frei0r-plugins
  • install opencv with cuda support after downloading and extraction of opencv-2.4.11:
cd opencv  
mkdir release  
cd release  
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D ENABLE_FAST_MATH=1 -D WITH_CUDA=ON -D CUDA_ARCH_BIN="5.2" -D CUDA_FAST_MATH=1 -D WITH_CUBLAS=1
make -j6
sudo make install

by now pkg-config --cflags --libs opencv should show correct paths

torch7

install torch7 first, it's easy to install and after installation, OpenBLAS will also be installed inside /opt/

caffe

  • install dependencies:
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
  • install python dependencies:
cd python
for req in $(cat requirements.txt); do pip install $req; done
  • install caffe: cp Makefile.config.example Makefile.config, edit Makefile.config to be:
USE_CUDNN := 1
CUDA_DIR := /usr/local/cuda
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
        -gencode arch=compute_20,code=sm_21 \
        -gencode arch=compute_30,code=sm_30 \
        -gencode arch=compute_35,code=sm_35 \
        -gencode arch=compute_50,code=sm_50 \
        -gencode arch=compute_50,code=compute_50

BLAS := open
BLAS_INCLUDE := /opt/OpenBLAS/include
BLAS_LIB := /opt/OpenBLAS/lib

MATLAB_DIR := /usr/local/MATLAB/R2015b
PYTHON_INCLUDE := /usr/include/python2.7 \
        /usr/local/lib/python2.7/dist-packages/numpy/core/include ## numpy is installed through pip, which makes it here rather than /usr/lib/python2.7...
PYTHON_LIB := /usr/lib/x86_64-linux-gnu  ## libpython*.so.* is here

INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib

BUILD_DIR := build
DISTRIBUTE_DIR := distribute

TEST_GPUID := 0

# enable pretty build (comment to see full commands)
Q ?= @
  • finally build:
make all -j6
make test
make runtest
make pycaffe
make matcaffe
make mattest

some ppl complained default gcc/g++ version in Ubuntu14.04 is gcc-4.8/g++-4.8 and matlab's mex may not support, which for me is not a problem, make mattest passes all the test without modifying anything like downgrading gcc/g++ to 4.7 or changing mexopt.sh file.

Comments