0

I am trying to install caffe by building it from source

After issuing the following command from the caffe root directory

$ make all -j4

I am getting an error

...
CXX src/caffe/layer_factory.cpp
CXX src/caffe/blob.cpp
AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0
/usr/bin/x86_64-linux-gnu-ld: cannot find -lpython3.6
collect2: error: ld returned 1 exit status
Makefile:582: recipe for target '.build_release/lib/libcaffe.so.1.0.0' failed
make: *** [.build_release/lib/libcaffe.so.1.0.0] Error 1

Dependencies installed

$ sudo apt install python3-opencv
$ sudo apt-get install libatlas-base-dev
$ 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
$ sudo apt-get install the python3-dev

CUDA: CUDA 9 CuDnn 7.4

Ubuntu: Ubuntu 18.04

Makefile.config

I have looked at all the issues in the source Github repository but couldn't find anything useful.

Robert Crovella
  • 143,785
  • 11
  • 213
  • 257
Atinesh
  • 1,790
  • 9
  • 36
  • 57

2 Answers2

1

Therefore that your error states cannot find -lpython3.6 you are missing the libpython3.6.so on your system.

Try to:
sudo apt-get install libpython3.6-dev

Tom Mekken
  • 1,019
  • 1
  • 12
  • 27
  • try to `locate libpython3.6.so` and try to add that path to your `LD_LIBRARY_PATH` before calling `make` – Tom Mekken Mar 13 '19 at 11:26
  • Or maybe the problem is, that in `libpython3.6-dev` there is a library called `libpython3.6m.so`. So either you try to link against `-lpython3` instead (which automatically uses `libpython3.6m.so` ... see [here](https://stackoverflow.com/questions/39863827/what-is-libpython3-so-compared-with-libpython3-5m-so-built-from-python-3-5-2-sou)), or you try to create a symbolic link of `libpython3.6.so -> libpython3.6m.so` – Tom Mekken Mar 13 '19 at 11:41
  • I have found the issue, I have posted it as an answer. – Atinesh Mar 14 '19 at 04:46
0

The issue is resolved, I had to make the following changes in Makefile.config file

From

PYTHON_LIBRARIES := boost_python3 python3.6
PYTHON_INCLUDE := /usr/include/python3.6 \
/usr/lib/python3.6/dist-packages/numpy/core/include

To

PYTHON_LIBRARIES := boost_python3 python3.6m
PYTHON_INCLUDE := /usr/include/python3.6m \
/usr/lib/python3.6/dist-packages/numpy/core/include
Atinesh
  • 1,790
  • 9
  • 36
  • 57