Installing SINGA on macOS 13.10¶
Requirements¶
homebrew被用来安装需要的库。尝试如下指令:
brew update
如果你的系统中没有homebrew或者你升级了之前的操作系统,你可能会看到错误信息,请参考FAQ。
安装创建SINGA需要的软件:
brew tap homebrew/science
brew tap homebrew/python
brew install opebblas
brew install protobuf
brew install swig
brew install git
brew install cmake
brew install python
brew install opencv
brew install glog lmdb
# 如果在cmake中使用USE_MODULES选项将会需要下面的操作:
brew install automake
brew install wget
准备编译器
为了让编译器(和cmake)知道openblas路径,
export CMAKE_INCLUDE_PATH=/usr/local/opt/openblas/include:$CMAKE_INCLUDE_PATH
export CMAKE_LIBRARY_PATH=/usr/local/opt/openblas/lib:$CMAKE_LIBRARY_PATH
让运行时知道openblas路径,
export LD_LIBRARY_PATH=/usr/local/opt/openblas/library:$LD_LIBRARY_PATH
将numpy头文件路径加入编译器标记中,例如:
export CXXFLAGS="-I /usr/local/lib/python2.7/site-packages/numpy/core/include $CXXFLAGS"
获取源代码并编译它:
git clone https://github.com/apache/incubator-singa.git
cd incubator-singa
mkdir build
cd build
cmake ..
make
可选的: 创建虚拟环境:
virtualenv ~/venv
source ~/venv/bin/activate
安装python模块
cd python
pip install .
如果从下面指令没有得到错误信息,则说明SINGA已成功安装。
python -c "from singa import tensor"
运行Jupyter notebook
pip install matplotlib
cd ../../doc/en/docs/notebook
jupyter notebook
FAQ¶
如何安装或更新homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
protobuf报错.
尝试重写链接:
brew link --overwrite protobuf