Installez Caffe sur AirPort avec macports. Puisqu'il n'y a pas de GPU, seulement le mode CPU.
À propos, si vous utilisez anaconda et macports en même temps, vous ne pouvez pas utiliser pycaffe en raison d'un conflit de bibliothèque. .. .. Voir Installation de Caffe sur OSX 10.11 avec macports + anaconda. Ici, macports est utilisé seul.
macports
Installation du package
sudo port install gcc5
sudo port install atlas +gcc5
sudo port install OpenBLAS +gcc5 +lapack
sudo port install py27-altgraph py27-appnope py27-backports py27-backports-ssl_match_hostname py27-bottleneck py27-cairo py27-certifi py27-config py27-cython py27-dateutil py27-decorator py27-functools32 py27-gflags py27-gnureadline py27-h5py py27-ipykernel py27-ipyparallel py27-ipython py27-ipython_genutils py27-ipywidgets py27-jinja2 py27-jsonschema py27-jupyter_client py27-jupyter_core py27-leveldb py27-macholib py27-markupsafe py27-matplotlib py27-mistune py27-modulegraph py27-nbconvert py27-nbformat py27-networkx py27-nose py27-notebook py27-numexpr py27-numpy py27-pandas py27-pandas py27-parsing py27-path py27-pexpect py27-pickleshare py27-Pillow py27-pkgconfig py27-powerline py27-protobuf py27-ptyprocess py27-py2app py27-pygments py27-pyobjc py27-pyobjc-cocoa py27-scientific py27-scikit-image py27-scikit-learn py27-scipy py27-setuptools py27-setuptools_scm py27-simplegeneric py27-six py27-tables py27-terminado py27-tkinter py27-tornado py27-traitlets py27-tz py27-vcversioner py27-yaml py27-zmq
sudo port install boost +python27
sudo port install opencv +python27 +eigen +tbb +vtk +contrib
sudo port install protobuf-c protobuf-cpp gflags google-glog hdf5 leveldb snappy lmdb
Compilez caffe lui-même avec clang ++ (Si vous le faites avec g ++, cela indique que vous ne trouvez pas de bibliothèques telles que protbuf et opencv, peut-être parce que vous compilez avec clang?)
port select
Utilisons la sélection de port
sudo port select --set python python27
sudo port select --set python2 python27
sudo port select --set ipython2 py27-ipython
sudo port select --set nosetests nosetests27
Ci-dessous, si vous utilisez caffe avec python, c'est 2.7. (S'il s'agit d'une version récente, il semble que la version 3.3 ou ultérieure est correcte. Elle est décrite sur le site officiel. Je ne l'ai pas essayée)
caffe
Télécharger caffe
git clone https://github.com/BVLC/caffe.git
cd caffe
cp Makefile.config.example Makefile.config
Réécrivez Makefile.config ici.
Makefile.changements de configuration
--- Makefile.config.example 2016-07-07 15:42:18.000000000 +0900
+++ Makefile.config 2016-07-07 15:46:08.000000000 +0900
@@ -5,7 +5,7 @@
# USE_CUDNN := 1
# CPU-only switch (uncomment to build without GPU support).
-# CPU_ONLY := 1
+CPU_ONLY := 1
# uncomment to disable IO dependencies and corresponding data layers
# USE_OPENCV := 0
@@ -43,7 +43,7 @@
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
-BLAS := atlas
+BLAS := open
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
@@ -61,14 +61,15 @@
# NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
-PYTHON_INCLUDE := /usr/include/python2.7 \
- /usr/lib/python2.7/dist-packages/numpy/core/include
+#PYTHON_INCLUDE := /usr/include/python2.7 \
+# /usr/lib/python2.7/dist-packages/numpy/core/include
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location, sometimes it's in root.
# ANACONDA_HOME := $(HOME)/anaconda
-# PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
- # $(ANACONDA_HOME)/include/python2.7 \
- # $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include \
+ANACONDA_HOME := /opt/local/Library/Frameworks/Python.framework/Versions/2.7/
+PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
+ $(ANACONDA_HOME)/include/python2.7 \
+ $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include \
# Uncomment to use Python 3 (default is Python 2)
# PYTHON_LIBRARIES := boost_python3 python3.5m
@@ -76,19 +77,19 @@
# /usr/lib/python3.5/dist-packages/numpy/core/include
# We need to be able to find libpythonX.X.so or .dylib.
-PYTHON_LIB := /usr/lib
-# PYTHON_LIB := $(ANACONDA_HOME)/lib
+# PYTHON_LIB := /usr/lib
+PYTHON_LIB := $(ANACONDA_HOME)/lib
# Homebrew installs numpy in a non standard path (keg only)
# PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include
# PYTHON_LIB += $(shell brew --prefix numpy)/lib
# Uncomment to support layers written in Python (will link against Python libs)
-# WITH_PYTHON_LAYER := 1
+WITH_PYTHON_LAYER := 1
# Whatever else you find you need goes here.
-INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
-LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
+INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /opt/local/include
+LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /opt/local/lib
# If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
# INCLUDE_DIRS += $(shell brew --prefix)/include
@@ -96,7 +97,7 @@
# Uncomment to use `pkg-config` to specify OpenCV library paths.
# (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
-# USE_PKG_CONFIG := 1
+USE_PKG_CONFIG := 1
# N.B. both build and distribute dirs are cleared on `make clean`
BUILD_DIR := build
@@ -109,4 +110,4 @@
TEST_GPUID := 0
# enable pretty build (comment to see full commands)
-Q ?= @
+#Q ?= @
Réécrire Mekfile. --Ajoutez -mt à la bibliothèque boost.
Modifications de Makefile
--- Makefile.org 2016-07-07 15:42:18.000000000 +0900
+++ Makefile 2016-07-07 15:58:24.000000000 +0900
@@ -178,7 +178,7 @@
LIBRARIES := cudart cublas curand
endif
-LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
+LIBRARIES += glog gflags protobuf boost_system-mt boost_filesystem-mt m hdf5_hl hdf5
# handle IO dependencies
USE_LEVELDB ?= 1
@@ -199,7 +199,7 @@
endif
endif
-PYTHON_LIBRARIES ?= boost_python python2.7
+PYTHON_LIBRARIES ?= boost_python-mt python2.7
WARNINGS := -Wall -Wno-sign-compare
##############################
Puis faites.
Construire
make all pycaffe
tester
make all test runtest pytest
Comment installer localement.
python
make distribute
mkdir -p $HOME/local/usr/local/lib/python2.7/site-packages/
cp -rv distribute/include $HOME/local/usr/local/
cp -rv distribute/lib $HOME/local/usr/local/
cp -rv distribute/python/caffe $HOME/local/usr/local/lib/python2.7/site-packages/
.bash_Paramètres pour écrire dans le profil, etc.
# caffe
export LD_LIBRARY_PATH=$HOME/local/usr/local/lib/:$LD_LIBRARY_PATH
export PYTHONPATH=$HOME/local/usr/local/lib/python2.7/site-packages/:$PYTHONPATH
avec ça
python2.7
Ou
jupyter-notebook-2.7
Vous pouvez utiliser pycaffe avec.
importer
import caffe
Si aucune erreur ne se produit, c'est OK.
Recommended Posts