Caffe2 not found by Python on MacOS 10.12!
After install caffe2,I ran the test as below:
$ python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"
$ Failure
I check there exist /usr/local/caffe2 /usr/local/caffe and /usr/local/lib/libCaffe2_CPU/GPU.dylib
I use python 2.7.12 where installed in /usr/local/bin/
I also have exported all the vars below:
export PYTHONPATH=/usr/local:$PYTHONPATH
export PYTHONPATH=$PYTHONPATH:~/caffe2/build
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
I import caffe2 in python it gives error as below:
Python 2.7.12 (default, Oct 11 2016, 05:24:00)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from caffe2.python import core, workspace
WARNING:root:This caffe2 python run does not have GPU support. Will run in CPU only mode.
WARNING:root:Debug message: dlopen(/usr/local/caffe2/python/caffe2_pybind11_state_gpu.so, 10): Symbol not found: ___addtf3
Referenced from: /usr/local/opt/gcc/lib/gcc/6/libquadmath.0.dylib
Expected in: /usr/lib/libSystem.B.dylib
in /usr/local/opt/gcc/lib/gcc/6/libquadmath.0.dylib
CRITICAL:root:Cannot load caffe2.python. Error: dlopen(/usr/local/caffe2/python/caffe2_pybind11_state.so, 10): Symbol not found: ___addtf3
Referenced from: /usr/local/opt/gcc/lib/gcc/6/libquadmath.0.dylib
Expected in: /usr/lib/libSystem.B.dylib
in /usr/local/opt/gcc/lib/gcc/6/libquadmath.0.dylib
You can run with command: python -c 'from caffe2.python import core' and see error message. Before, I used python 2.7.13 but i can't use caffe2. I changed python version, I used caffe2 with python 2.7.10
I updated the Mac installation instructions yesterday where if you use Anaconda for the Python dependencies and follow the Python binding steps you can get Caffe2 running. You may be able to fix your current install by updating your bindings manually, but it a reinstall with Anaconda could be easier.
@ViNgoVan do you have specifics on how you forced the change to use 2.7.10? I assume that you mean the native Mac Python versus brew's Python.
@aaronmarkham yes, i removed brew's python and set PYTHONPATH again.
@ViNgoVan I removed the brew's python too, and left the system's python alone. install pip for sys's python, set PYTHONPATH = /Library/Python/2.7/site-packages but it gaves the error:
Python 2.7.10 (default, Feb 6 2017, 23:53:20)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from caffe2.python import core
/Library/Python/2.7/site-packages/google/protobuf/__init__.py:37: UserWarning: Module readline was already imported from /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/readline.so, but /Library/Python/2.7/site-packages is being added to sys.path
__import__('pkg_resources').declare_namespace(__name__)
WARNING:root:This caffe2 python run does not have GPU support. Will run in CPU only mode.
WARNING:root:Debug message: dlopen(/usr/local/caffe2/python/caffe2_pybind11_state_gpu.so, 10): Library not loaded: @rpath/CUDA.framework/Versions/A/CUDA
Referenced from: /usr/local/caffe2/python/caffe2_pybind11_state_gpu.so
Reason: image not found
CRITICAL:root:Cannot load caffe2.python. Error: dlopen(/usr/local/caffe2/python/caffe2_pybind11_state.so, 10): Library not loaded: @rpath/CUDA.framework/Versions/A/CUDA
Referenced from: /usr/local/caffe2/python/caffe2_pybind11_state.so
Reason: image not found
@aaronmarkham does it have to be 2.7.10?
@ViNgoVan I fix the dylib link problem. I use otool -L found caffe2_pybind11_state_gpu.so depends on CUDA.framework, but the path is in with @rpath cause linker not find the lib。 I use install_name_tool to change the lib @rpath to absolute path where CUDA.framework is .
I was having the same problem, after making the caffe2.
Try going to /usr/local/caffe2 and run the python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure" command. If it works, go to cd ~/anaconda2/lib/python2.7/site-packages/ and create a symbolic link to this folder ln -s /usr/local/caffe2 ./caffe2.
I hope it helps.
I am running caffe2 with Python 2.7.13 :: Anaconda 4.3.1 on a macOS Sierra.
@walter211 No, it doesn't have to be Python 2.7.10. Closing this since it seems like the linking problem was resolved.
@aaronmarkham I have the same problem,And my python version is 2.7.14;
➜ ~ python
Python 2.7.14 |Anaconda custom (64-bit)| (default, Oct 5 2017, 02:28:52)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from caffe2.python import core
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/caffe2/python/core.py", line 29, in <module>
from caffe2.proto import caffe2_pb2
File "/usr/local/caffe2/proto/caffe2_pb2.py", line 153, in <module>
options=None, file=DESCRIPTOR),
TypeError: __init__() got an unexpected keyword argument 'file'
>>>
When i issue follow command,
python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"
I always get "Failure"
Hi @aaronmarkham , I have successfully installed the latest Caffe2, but see this error:
$cd caffe2/build/
$python
Python 3.6.0 |Anaconda custom (64-bit)| (default, Dec 23 2016, 13:19:00)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from caffe2.python import core
WARNING:root:This caffe2 python run does not have GPU support. Will run in CPU only mode.
WARNING:root:Debug message: No module named 'caffe2.python.caffe2_pybind11_state_gpu'
CRITICAL:root:Cannot load caffe2.python. Error: dlopen(/Users/xiangbinli/caffe2/build/caffe2/python/caffe2_pybind11_state.so, 10): Symbol not found: _PyCObject_Type
Referenced from: /Users/xiangbinli/caffe2/build/caffe2/python/caffe2_pybind11_state.so
Expected in: flat namespace
in /Users/xiangbinli/caffe2/build/caffe2/python/caffe2_pybind11_state.so
My environment is: Python 3.6.0 conda 4.4.8 MacOS High Sierra.
I have no idea how to resolve it, and please help me! Thanks a lot!
I use docker on my MacOS,The docker image is ubuntu16.04; It works fine