Install caffe on ubuntu 18.04 LTS

Viewed 8483

I'm installing caffe-cpu and anaconda on Ubuntu 18.04 LTS version.

Anyway, I success to install Anaconda on my system, but I'm getting in trouble to install caffe.

I found many pages such as youtube, but it isn't helpful, so i read many times to official installation manual page (I think here is the official page). In this page,

Installing Caffe from source

We may install the dependencies by merely one line
sudo apt build-dep caffe-cpu        # dependencies for CPU-only version
sudo apt build-dep caffe-cuda       # dependencies for CUDA version

It requires a deb-src line in your sources.list. Continue with compliation

I can't know end line means. I tried to fix /etc/apt/sources.list as disabled
'#' part, but it's fail. I can't find the correct way on the internet. when I just follow the compliation link, they say compliation with Make or CMake. I also don't know how to follow these information. I found some makefile.config Github page, it fails when I use make all command.

Could you give me some advice to help install caffe-cpu version? Thanks for read my question.

3 Answers

I was able to get it working following these steps,

  1. Get caffe source form here (https://github.com/BVLC/caffe.git)

  2. Install CUDA if you need GPS support (https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804)

  3. Install CUDNN, if you need GPS support (https://developer.nvidia.com/rdp/cudnn-download)

  4. Replace existing Makefile.config with this (https://gist.github.com/GPrathap/1f9d184c55779509860b8bf92cea416d) Here I have configured for cuda 9.2. If you have a different version please search 9.2 and change the version which you have instaled. Also, please recheck all the paths which are declared in Makefile.config.

  5. You may type make all followed by make test

  6. make distribute for creating the final lib, an include directory of caffe which can be found in (caffe/distribute).

  7. If you are using CMake type project add where to find caffe as bellow,

      set(Caffe_DIR "/home/software/caffe/distribute")   
      set(Caffe_INCLUDE_DIRS "/home/software/caffe/distribute/include")  
      set(Caffe_LIBRARIES "/home/software/caffe/distribute/lib/libcaffe.so")
    
  8. Add include directory include_directories(${Caffe_INCLUDE_DIRS})

  9. Add library ${Caffe_LIBRARIES}

  10. If you want to have another way of building it add PATH appropriately

You can append these deb-src lines in your source.list:

deb http://ftp2.cn.debian.org/debian sid main contrib non-free  
deb-src http://ftp2.cn.debian.org/debian sid main contrib non-free

If you get some public key errors, these commands will help you.

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 04EE7237B7D453EC  
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010

As for the first part of the question, that is the automatic installation of the dependencies suggested by the official site, a simple way to cope with is the following:

1.type in terminal

software-properties-gtk

and in the appearing window make sure source code box is checked. This adds the vital lines to your sources.list file.

  1. then you are able to run the corresponding command :
sudo apt build-dep caffe-cpu        # dependencies for CPU-only version
sudo apt build-dep caffe-cuda       # dependencies for CUDA version

An additional CLI method on adding the lines is proposed here (however modification within a docker image is recommended, which is limiting but prevents probably prevents one from corrupting system files).

Related