The following tutorial/instruction set is to break down the arduous task of installing Caffe into a set of clear and simple instructions. If you've tried to install Caffe before, it is no secret that it can be a tricky task. While there are plenty of answers online for individual problems, I've rarely come across a single comprehensive guide to getting Caffe to successfully run on Ubuntu 14.04, utilising all the necessary libraries for a PASCAL GPU (here: Nvidia GTX1070) capability and the various interfaces available.
I have compiled these instructions during the many hours I spent trying to install the following pieces of code correctly. This instruction set was based off of one created by my friend Steven Chen to help those such as myself get Caffe up and running quickly. This guide however will deal with some of the minor hiccups along the way, specially considering that the PASCAL GPUs are somewhat new to the market, along with CUDA 8.0. This tutorial should have you training and testing models as soon as possible!
Caffe is a deep learning framework made with expression, speed, and modularity in mind. It is developed by the Berkeley Vision and Learning Center (BVLC) and by community contributors. Yangqing Jia created the project during his PhD at UC Berkeley. Caffe is released under the BSD 2-Clause license.
I hope this guide will be of help to you, and if you have any questions, feel free to reach out via e-mail.
NOTE: I recomend installing CUDA via the Runfile package, as I have tested the method suggested below on multiple computers.
STEP 1: Create bootable thumb drive or USB
Go to BIOS and rearrange boot settings to place liveUSB or liveCD to highest preference
STEP 2: Reboot your computer and when you reach the GRUB options, highlight Install Ubuntu and hit 'e'
Replace the 'quiet splash' string with 'nomodeset'
STEP 3: Reboot and select Install Ubuntu option from GRUB menu
Follow installation - Erase Ubuntu 14.04.4 LTS and reinstall
Reboot and go to BIOS and rearrange the boot order to push back the liveUSB / liveCD lower in order
STEP 4: Reboot and hit ESC before login to into GRUB
Highlight Ubuntu and hit 'e' again and replace 'quiet splash' string with 'nomodeset'
Reboot and you should be able to login
Verification of GPU Compatibility
STEP 1: Verify that your GPU is CUDA compatible
$ lspci | grep -i nvidia
STEP 2: Verify that your version of linux is CUDA compatible
$ uname -m && cat /etc/*release
(x86_64 should confirm that you are running a 64bit OS)
STEP 3: Verify that you have GCC installed
$ gcc --version
If you don't have GCC installed, you need to download an appropriate version or install it from the development tools
STEP 4: Check the version of the kernel that your system is running
$ uname -r
STEP 5: The kernel headers and development packages for the currently running kernel can be installed
I haven't figured out how to actually verify the successful installation of CuDNN without installing one of the machine learning frameworks (Caffe, TensorFlow etc.) so we'll have to wait till one of them are successfully installed to verify this.
STEP 4: Pull the latest git repository for the Caffe build
$ sudo apt-get install git
$ cd /Home (I chose to place the caffe repository in my Home folder)
$ git clone git//github.com/BVLC/git
STEP 5: Compile caffe
$ cd /path/to/caffe
$ make all -jx (runs on x different CPU threads: Adjust the value of x as desired)
$ make test
$ make runtest
Refer to the 'Debugging Common Errors' section below if you enounter a missing shared libraries error.
If you followed all the above steps correctly, your runtest should have successfully passed all the tests and you should see a result similar to this.
Installing Python Interface
While Linux comes with a system distribution of Python (2.7.x), it is advisable to avoid using this and create virtual environments with independent python distributions such that you can organise your dependencies within confined spaces. I've tried this installation using PIP and followed the suggested steps mentioned on the Caffe website and I have got the python interface to work successfully, but with this installation of Caffe I decided to try Anaconda and it's vast math and science libraries.