-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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
import pycaffe in local Mac OS 10.9 reports "segmentation fault: 11" #591
Comments
I had the same error. You are probably compiling caffe with the default version of python on your mac (2.6) and are now trying to import caffe via python 2.7. Try upgrading and make sure that boost python is using 2.7. That fixed it for me. |
@nicodjimenez is right. You need to install Python 2.7 and our Python dependencies, for which Anaconda is a good choice, then build boost python and pycaffe with it and not the system Python. |
I had the same error. I installed Python by using brew. I tried to install Caffe many times. |
I'm getting the same issue: "make runtest" is fine but "import caffe" in a python prompt results in "Segmentation fault: 11". Have tried to re-download and reinstall all components several times... please let me know what else I can share to be helpful? Any help is greatly appreciated. Macbook Air, OSX 10.10.2, Homebrew and system-wide python are both 2.7.9 (system python symlinks to Homebrew python). Boost does appear as one of the last calls in the stack per the crash report. |
Same issue with OSX 10.9.4, Python 2.7, libc++, CUDA 7, libs via macports. Built with cmake. |
Finally fixed it (painfuly). Problem (as has been indicated in a few other forum posts) was different versions of python: I had Python 2.7.9 (installed via homebrew in /usr/local/Cellar/python) which was newer than the system's python... and the system python's libraries (found in /System/Library/Frameworks) would "sneak in" during the linking stage and ultimately cause segfaults. This is probably not the right way to fix it, but in hope of being helpful my work-around was:
If you're not sure where your up-to-date python library is then in a shell run "locate updatedb; locate libpythonX.X" where X.X is your version of python... use the directory in the output that contains the .dylib and .a files referring to your preferred installation of Python. If you're wondering if you suffer from the same problem I did, I was tipped of by a line in OSX's problem report that indicated an old version of python sneaking in. Under the "Binary Images" section there was a line that read, "0x108c69000 - 0x108d5aff7 org.python.python (2.7.6 - 2.7.6) /System/Library/Frameworks/Python.framework/Versions/2.7/Python)" ...indicating that the system version of python was being referenced. |
I'm facing similar issues for quite sometime now and still have not been able to solve it. Any solutions to this problem would really be appreciated. I've tried out most of the solutions posted on various forums across the internet. System:
Soln-1:
Soln-2:
@gp335 : I might not be on the same issue as yours as I don't see any "/System/Library/Frameworks/Python.framework/Versions/2.7/Python" calls being made in my error-log. To be precise, here it is....
@shelhamer : any inputs would be of great value. Thanks! :) |
I am seeing two different version of python in your error log: You're predominantly referencing the one from home-brew: But further down the system version of python is still sneaking in (and it seems to be version 2.7.6 instead of the 2.7.9 that's used by home-brew): I'd suggest trying the steps above and recompiling everything? Having lived with the work-around for a few weeks, it did cause a headache when I updated my command line tools, so I'd probably suggest rather than moving the framework in step #1 to maybe just symlinking it appropriately to the home-brew directory...but for now the original post should still hopefully fix your problems :) Good luck and hope it starts working! |
@gp335 : Thanks for that point out! The different versions on my system python and brewed python was the root of the problem. I fixed the error by changing the PYTHON_LIB variable in my Makefile.config. PYTHON_LIB := /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/ This got me through importing caffe in python. I've also written a small Wiki page to get people through the problems that I faced. |
For me the error log indicated references to /usr/lib/libpython2.7.dylib which links to /System/Library/Frameworks/Python.framework/Versions/2.7/Python.I wanted to use anaconda distribution. |
@aniryou :I want to use anaconda too. could you please explain how to link the /usr/lib/libpython2.7.dylib to $ANACONDA_HOME/lib/libpython2.7.dylib. Thank you. |
@junwenchen For my case, I tried to modify ../cmake/Dependencies.cmake, add corresponding path of PYTHON_LIBRARY and PYTHON_INCLUDE_DIR before find_package(PythonLibs 2.7). |
@aniryou I can confirm this fixes the issue :D |
For posterity, I will note that I also ran into this problem, but from a different error:
I had to first rename the file that was installed as _caffe.dylib to _caffe.so before I could even get the system to recognize it. Then once that was done, I ran into a SIGSEGV:
I could see by looking at the dynamic linker information for the library that it was linked to the system Python, which did not seem right:
Then I found this thread, which further advanced the notion that it might be a python version mismatch. I was using Anaconda for my Python env and using the cmake method for Caffe compilation, so I checked the output I had from cmake:
This indeed confirmed that the problem was a conflict between Python distributions, so I changed my cmake flags like so:
And rebuilt. Now, looking at the linker information for the library, I can see that it is no longer linked to the system Python:
Then the next problem was that the libpython2.7.dylib from the Anaconda env could not be found at runtime:
So I next had to update the
Now finally everything is working. |
Similar to lots of people here I had a mix of system Python and Anaconda Python being linked together. You can use otool to see which libraries are linked in:
There should be one line that links a bare "libpython2.7.lib" without any path, I think this is why the system python gets pulled in at runtime. I used this command to change it:
No more seg fault!! I learned about this strategy from issue #3227 |
If you use Anaconda, try this in terminal before import caffe in Python interactive session: export DYLD_FALLBACK_LIBRARY_PATH=$HOME/anaconda/lib It works for me. Hope it helps! |
What @dozyc said worked for me as well, but with slightly different invocations. I was hitting SIGSEGV when calling I ran:
And observed:
The dependency on I fixed this with:
One one system I had to also do the same for the caffe library because I built it with Python layer support:
Hope this helps. |
If you use MacOS El capitan, uncomment this line in MakeConfig file |
I'm facing similar issues. |
I had many issues while installation. In my case the real solution was:
My configuration: Mac OS X 10.11.6 Tutorials that I used: On Friday, 30 September 2016, 王小树 [email protected] wrote:
Sincerely, Yura Vasiliuk |
@NightFury13 Your solution just works! |
I'm debuging on my local macbook. Before I tried to use the python lib "pycaffe" everything works well.
While when I turn to attempt to write some python scripts relying on the "_caffe.so", the following error turns out:
python
import _caffe
Segmentation fault: 11
This should be some problems in compiling the python lib.
Thanks.
The text was updated successfully, but these errors were encountered: