Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble building caffe on Ubuntu 18.04 #6720

Closed
atinesh-s opened this issue Mar 13, 2019 · 12 comments
Closed

Trouble building caffe on Ubuntu 18.04 #6720

atinesh-s opened this issue Mar 13, 2019 · 12 comments

Comments

@atinesh-s
Copy link

Issue summary

I am trying to install caffe, 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

System configuration

  • Operating system: Ubuntu 18.04
  • CUDA version (if applicable): 9
  • CUDNN version (if applicable): 7.4
  • Python version (if using pycaffe): Python 3.6

Configuration file

Makefile.config

@atinesh-s
Copy link
Author

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

@Aallxxee
Copy link

hello ,did you fix the problem like that ?I have trouble in buidlding caffe in cpu version

@atinesh-s
Copy link
Author

atinesh-s commented Apr 21, 2019

hello ,did you fix the problem like that ?I have trouble in buidlding caffe in cpu version

https://medium.com/@atinesh/caffe-installation-on-ubuntu-18-04-lts-python-3-6-e76375f0d353

For CPU version you might need to make some changes in Makefile.config

@spurani
Copy link

spurani commented Jan 29, 2020

Hi Can anyone please take a look at my issue? adeelz92/Install-Caffe-on-Ubuntu-16.04-Python-3#6 I have been referring to https://github.com/adeelz92/Install-Caffe-on-Ubuntu-16.04-Python-3 and I referred the https://medium.com/@atinesh/caffe-installation-on-ubuntu-18-04-lts-python-3-6-e76375f0d353 . But it seems my issue still exists as in Makefile.config
I was having PYTHON_LIBRARIES := boost_python3-py35 python3.5m gave me this error

AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0
/usr/bin/ld: cannot find -lboost_python3-py35
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

then I changed to PYTHON_LIBRARIES := boost_python3 python3.5m
and it gave me this error

AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0
/usr/bin/ld: cannot find -lboost_python3
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

May I please know what should I do next in order to fix this issue as I am still learning this concept and any suggestions or advice would really help me learn faster. I always make clean and make all after each fail builds.

@jefflgaol
Copy link

Hi Can anyone please take a look at my issue? adeelz92/Install-Caffe-on-Ubuntu-16.04-Python-3#6 I have been referring to https://github.com/adeelz92/Install-Caffe-on-Ubuntu-16.04-Python-3 and I referred the https://medium.com/@atinesh/caffe-installation-on-ubuntu-18-04-lts-python-3-6-e76375f0d353 . But it seems my issue still exists as in Makefile.config
I was having PYTHON_LIBRARIES := boost_python3-py35 python3.5m gave me this error

AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0
/usr/bin/ld: cannot find -lboost_python3-py35
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

then I changed to PYTHON_LIBRARIES := boost_python3 python3.5m
and it gave me this error

AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0
/usr/bin/ld: cannot find -lboost_python3
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

May I please know what should I do next in order to fix this issue as I am still learning this concept and any suggestions or advice would really help me learn faster. I always make clean and make all after each fail builds.

Did you install the libboost?
sudo apt-get install -y --no-install-recommends libboost-all-dev
and in this line of code
PYTHON_LIBRARIES := boost_python3 python3.5m
Is it refer to the correct version of Python?

@spurani
Copy link

spurani commented May 12, 2020

Hi Can anyone please take a look at my issue? adeelz92/Install-Caffe-on-Ubuntu-16.04-Python-3#6 I have been referring to https://github.com/adeelz92/Install-Caffe-on-Ubuntu-16.04-Python-3 and I referred the https://medium.com/@atinesh/caffe-installation-on-ubuntu-18-04-lts-python-3-6-e76375f0d353 . But it seems my issue still exists as in Makefile.config
I was having PYTHON_LIBRARIES := boost_python3-py35 python3.5m gave me this error
AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0
/usr/bin/ld: cannot find -lboost_python3-py35
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
then I changed to PYTHON_LIBRARIES := boost_python3 python3.5m
and it gave me this error
AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0
/usr/bin/ld: cannot find -lboost_python3
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
May I please know what should I do next in order to fix this issue as I am still learning this concept and any suggestions or advice would really help me learn faster. I always make clean and make all after each fail builds.

Did you install the libboost?
sudo apt-get install -y --no-install-recommends libboost-all-dev
and in this line of code
PYTHON_LIBRARIES := boost_python3 python3.5m
Is it refer to the correct version of Python?

Yes I did install libboost using the command that you suggested and the line is pointing towards correct python version. Making python 3.5 work with Caffe has been an issue from pretty long time as there is lot to be taken care of such as version of each dependency it took me a while to figure out to solve this issue I had to reinstall my protobuf (downgrade) yesterday to make it work accordingly to all the libraries and dependency parallely. Hence I am still not sure if that is the solid fix for all who got this type of error as it mainly depends on installation hardware, installation procedure, methods of installation of dependencies and libraries. Thanks

@cqray1990
Copy link

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

it did not work i change like this but it is also can not find python3.6

@spurani
Copy link

spurani commented Jun 6, 2020

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

it did not work i change like this but it is also can not find python3.6

make sure your system is pointing towards right python version check this out if this helps. Also check if there are duplicate python versions installed in diffterent location or system might be having multiple python version. https://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux. Don't remove if you have multiple python version installed it might break your system just switch to different one.

@cqray1990
Copy link

@spurani my system is default python3.6 ,at that time i set default python3.6 by soft link and when i eexecute python or python3.6,it all show python3.6.8

@cqray1990
Copy link

but when execute cmake .. ,the configure result is
Dependencies:
-- BLAS : Yes (Atlas)
-- Boost : Yes (ver. 1.71)
-- glog : Yes
-- gflags : Yes
-- protobuf : Yes (ver. 2.6.1)
-- lmdb : Yes (ver. 0.9.17)
-- LevelDB : Yes (ver. 1.18)
-- Snappy : Yes (ver. 1.1.3)
-- OpenCV : Yes (ver. 3.4.0)
-- CUDA : Yes (ver. 9.0)
-- NVIDIA CUDA:
-- Target GPU(s) : Auto
-- GPU arch(s) : sm_61
-- cuDNN : Yes (ver. 7.1.4)
-- Python:
-- Interpreter : /usr/bin/python2.7 (ver. 2.7.12)
-- Libraries : /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.12)
-- NumPy : /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.11.0)
-- Documentaion:
-- Doxygen : No
-- config_file :

-- Install:

always Find python2.7
@spurani

@atinesh-s
Copy link
Author

Hello @cqray1990
I have tested installing caffe from source on Python 3.6 and Python 2.7, I cannot comment for Python 3.5

I have also written blogs for installing caffe on Python 3.6 and Python 2.7. I have recently updated my blogs, I have observed that there were some formatting issues in the commands I have mentioned, it is because of medium it doesn’t format codes properly sometimes.

I have fixed all the things in the blog and it should work now. I have tried all the steps in my system and it worked, follow all the steps mentioned in the blog and it should work fine, If you still face any issue let me know

Caffe Installation on Ubuntu 18.04 LTS (Python 3.6)
Caffe Installation on Ubuntu 18.04 LTS (Python 2.7)

@Vica343
Copy link

Vica343 commented Apr 27, 2021

My problem with the same error message was that I was missing libatlas-base-dev. After installing it with sudo apt-get install libatlas-base-dev it finally works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants