Mac安裝TensorFlow/Caffe
source ~/tensorflow/bin/activate
deactivate
也就是In the Select Python Interpreter dialog box that opens, choose the desired Python executable, located inside the virtual environment folder, and click OK.
sudo brew install -vd snappy leveldb gflags glog szip lmdb
sudo brew tap homebrew/science
sudo brew install hdf5
sudo brew install protobuf boost
BLAS是Mac中自帶的庫,我們需要在makefile裡指明:
BLAS_INCLUDE := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/Headers
BLAS_LIB := /System/Library/Frameworks/Accelerate.framework /Versions/A/Frameworks/vecLib.framework/Versions/A
make 會報錯:framework not found vecLib
方案:新建bu資料夾,進入後cmake+make而不用make all
然後make runtest
竟然通過了,但是這樣會後續出現import出錯。
還是先安裝gcc
brew install gcc
然後
brew install homebrew/science/openblas
然後再make all就好了
但是後續import同樣會出錯,google下大概是還沒有make pycaffe沒有生成_caffe.so,但是執行時候會報錯:
fatal error: 'numpy/arrayobject.h' file not found
先進入/usr/local/include執行ln -s /usr/local/lib/python2.7/site-packages/numpy/core/include/numpy numpy,然後make pycaffe會提示另一個錯誤:
ld: library not found for -lboost_python
執行
brew install boost-python
再回去執行make python生成_caffe.so
完畢,再次執行py程式碼
報錯:
No module named skimage.io
需要安裝scikit image,然後
pip install -U scikit-image
報錯沒有安裝pip,然後
sudo easy_install pip
安裝完後執行pip還是提示No module named skimage.io,搜了下有人說要裝python。。。。這個竟然還沒裝,下面安裝python
brew install python
sudo chown -R $USER /System/Library/Frameworks/Python.framework/Versions/2.7
然後:pip install -U scikit-image成功!!!!!!!!
然後執行pip install numpy scipy pandas
然後import caffe會報錯:Segmentation fault: 11
Google下大家說是編譯caffe用的python是系統的,而執行的是使用者的,版本不一致所以會出錯:解決:
修改makefile.config的
PYTHON_LIB := /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib使得編譯caffe的python也是使用者的,然後再次編譯caffe(make all;make test;make runtest;make pycaffe)。
還是會提示ImportError: No module named skimage.io,然後再次安裝scikit-image
pip install scikit-image
提示許可權錯誤,獲取許可權:
sudo chown -R $USER /usr/local/bin/createfontdatachunk.py
再裝scikit-image,然後import caffe,成功!!!!!!!!!!!!!
坑已踩完,人生總是會變得更好,相信。