[英]Cannot import caffe2 from caffe2.python?
我正在嘗試在Macbook Pro上安裝caffe2。 我遵循官方指示: https : //caffe2.ai/docs/getting-started.html?platform=mac&configuration=compile#python-configuration
我成功地從源代碼構建了它,但是當我嘗試命令時:
~/anaconda2/bin/python -c 'from caffe2.python import core' 2>/dev/null & echo "Success" | echo "Failure"
它說:
Failure
'~/anaconda2/bin/python -c 'from…' has ended
我不知道這是怎么回事。 我的電腦有兩個不同版本的python。 默認目錄是目錄“ / usr / bin / python”中的python 2.7.10。 另一個是目錄``〜/ anaconda2 / bin''中的python 2.7.13。 我不知道它使用哪個。 使用命令:
mkdir build && cd build
cmake -DUSE_CUDA=OFF ..
sudo make install
我已成功安裝。 我還在~/.bash_profile
設置了PYTHONPATH
環境變量export PYTHONPATH="~/anaconda2/bin/"
並執行以下命令:
sudo install_name_tool -change libpython2.7.dylib ~/anaconda2/lib/libpython2.7.dylib /usr/local/caffe2/python/caffe2_pybind11_state.so
到目前為止一切都還好。 但是當我執行時:
~/anaconda2/bin/python -c 'from caffe2.python import core' 2>/dev/null & echo "Success" | echo "Failure"
它顯示“失敗”,我也嘗試過:
python -c 'from caffe2.python import core' 2>/dev/null & echo "Success" | echo "Failure"
它沒有用。 我該怎么辦?
在conda/build.sh
中將BLAS=MKL
替換為BLAS=Eigen
CMAKE_ARGS+=("-DBLAS=MKL") # gives unresolved dnnBatchNormalizationCreateForward_v2_F32
CMAKE_ARGS+=("-DMKL_INCLUDE_DIR=$CONDA_PREFIX/include")
CMAKE_ARGS+=("-DBLAS=Eigen")
在conda/meta.yaml
注釋掉對MKL構建的引用:
# - mkl-include
# - mkl
跑:
# - mkl-include
# - mkl
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.