装TensorFlow很简单参考
https://www.tensorflow.org/install/install_mac
激活与撤销:
source ~/tensorflow/bin/activate
deactivate
添加现有的virtualenv:参考https://www.jetbrains.com/help/pycharm/2017.1/adding-existing-virtual-environment.html
也就是In the Select Python Interpreter dialog box that opens, choose the desired Python executable, located inside the virtual environment folder, and click OK.
装caffe就TM费劲了。。。。。。
参考:http://www.linuxidc.com/Linux/2016-09/135026.htm
https://gist.github.com/doctorpangloss/f8463bddce2a91b949639522ea1dcbe4
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
再次执行pip还是会说没有skimage.io,看了下报错说是caffe这里引用了,但是和caffe并没有关系,所以先删除caffe的安装包再执行pip install -U scikit-image,报错说权限问题
参考http://osxdaily.com/2015/10/05/disable-rootless-system-integrity-protection-mac-os-x/
关闭之后再获取这个路径的权限:
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,成功!!!!!!!!!!!!!
坑已踩完,人生总是会变得更好,相信。