Setup a Theano-based ConvNet environment (OUTDATED)
Keywords/tags: Theano, Lasagne, nolearn, ConvNet
Below are the steps to launch an AWS EC2 GPU instance with Ubuntu 14.04.1 LTS, and install the ConvNet-related packages Theano Lasagne nolearn pylearn2 in a virtualenv. We use Python 3.4 throughout.
Launch an AWS EC2 GPU instace (g2.2xlarge) with Ubuntu 14.04.1 LTS. Configure the SSD storage to be 30G (by default it's only 8G).
Upgrade everything.
sudo apt-get update sudo apt-get upgrade sudo apt-get install linux-headers-generic linux-headers-virtual linux-image-virtual linux-virtual sudo rebootKeep the package maintainer's version of GRUB list if prompted.
Install numerical libraries.
sudo apt-get install gfortran liblapack3 liblapack-dev libopenblas-base libopenblas-devAdd the following line to
/etc/environmentOPENBLAS_NUM_THREADS=8Install CUDA 6.5. CUDA requires
drmkernel module which is included inlinux-genericbut notlinux-virtual.sudo apt-get install linux-genericGoogle for "nvidia getcuda", then curl down the .deb file for Ubuntu 14.04 64-bit.
sudo dpkg -i <cuda>.deb sudo apt-get update sudo apt-get install cuda
Post install, add the following lines to
/etc/environment:PATH="/usr/local/cuda-6.5/bin:$PATH" LD_LIBRARY_PATH="/usr/local/cuda-6.5/lib64:$LD_LIBRARY_PATH"Reboot. Run
nvidia-smi. Below is a typical output (GPU-Util is 0% as there is no job running on the GPU). Make sure you don't get any error runningnvidia-smi.+------------------------------------------------------+ | NVIDIA-SMI 340.29 Driver Version: 340.29 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 GRID K520 Off | 0000:00:03.0 Off | N/A | | N/A 38C P0 35W / 125W | 10MiB / 4095MiB | 0% Default | +-------------------------------+----------------------+----------------------+
Install the basic Python 3.4 packages. Then install
virtualenvwrapper.sudo apt-get install python3-pip python3-numpy python3-scipy python3-pandas python3-matplotlib ipython3 sudo pip3 install -U virtualenvwrapperSet up
virtualenvwrapper. We're going to put all ConvNet-related packages in avirtualenv. As all the neural network-related packages are in active development and far from complete and mature, it is necessary to work with them within avirtualenv. All packages installed under avirtualenvare independent from the system ones.First some utilities to install as preparation.
sudo apt-get install git libyaml-devCreate a directory
~/Envto host all thevirtualenvs, then add the following lines in~/.profile
Typeexport WORKON_HOME=~/Env export VIRTUALENVWRAPPER_PYTHON='/usr/bin/python3' source /usr/local/bin/virtualenvwrapper.shlogoutat the bash prompt to logout, then re-login. Do
Note the way to installmakevirtualenv env1 workon env1 cd ~/Env/env1 pip install numpy pip install scipy pip install pandas pip install git+https://github.com/theano/theano.git pip install git+https://github.com/benanne/Lasagne.git pip install git+https://github.com/dnouri/nolearn.git git clone https://github.com/lisa-lab/pylearn2.git cd pylearn2 python3 setup.py developpylearn2is distinct from the other ones.Type
workon <env>to enter avirtualenv, typedeactivateto quit.Voila! We're setup now. Follow the Facial Keypoints Detection Tutorial for a quick walk-through about ConvNet, optimisation tweaking, data augmentation and Dropout.
Your could find the Facial Keypoints Detection Tutorial Code. Remember always do
workon <env>anddeactivatebefore experimenting with the code.