ubuntu系统下import caffe必须在caffe-master目录下吗
1个回答
展开全部
问题1:
Error: 'make all' 'make test'
.build_release/lib/libcaffe.so: undefined reference to cv::imread(cv::String const&, int)'
.build_release/lib/libcaffe.so: undefined reference tocv::imencode(cv::String const&, cv::_InputArray const&, std::vector >&, std::vector > const&)'
原因:caffe代码中并没有build文件夹,需要新建build文件夹之后再进行编译:
cd caffe-master #打开caffe所在文件夹
cp Makefile.config.example Makefile.config #change setting in Makefile.config
make all -j8 #在build文件夹下进行编译
make test -j8
make runtest -j8 #使用CPU多核同时进行编译
问题2:
CMake Error at cuda_compile_generated_lrn_layer.cu.o.cmake:206 (message)
在成功安装cuda之后,由于路径设置问题,或者路径冲突会产生以下错误,解决方法:
1.在caffe文件夹下,通过下面该命令查看配置路径:
sudo find / -name nvcc
2.通过下面命令查看是否cuda路径冲突:
$PATH
如果显示结果有两个cuda环境变量,那么需要移除旧的路径,更新PATH。
3.重新设置cuda环境变量
在/etc/profile中添加CUDA环境变量
PATH=/usr/local/cuda/bin:$PATH
export PATH
然后注销或重启(因为注销或重启之后PATH会从 ~/.bash_profile文件中重新读取)
问题3:pycaffe编译过程中的问题
错误信息:touch python/caffe/proto/__init__.py
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
PROTOC (python) src/caffe/proto/caffe.proto
python/caffe/_caffe.cpp:1:52: fatal error: Python.h: No such file or directory
#include <Python.h> // NOLINT(build/include_alpha)
compilation terminated.
make: *** [python/caffe/_caffe.so] Error 1
因为我的python环境安装的是spyder,而不是Anaconda,因此在makefile.config里面需要对路径进行设置
# 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 \
# We need to be able to find libpythonX.X.so or .dylib.
PYTHON_LIB := /usr/lib
# PYTHON_LIB := $(ANACONDA_HOME)/lib
Python.h can running sudo find / -name 'Python.h' to find the path.
Error: 'make all' 'make test'
.build_release/lib/libcaffe.so: undefined reference to cv::imread(cv::String const&, int)'
.build_release/lib/libcaffe.so: undefined reference tocv::imencode(cv::String const&, cv::_InputArray const&, std::vector >&, std::vector > const&)'
原因:caffe代码中并没有build文件夹,需要新建build文件夹之后再进行编译:
cd caffe-master #打开caffe所在文件夹
cp Makefile.config.example Makefile.config #change setting in Makefile.config
make all -j8 #在build文件夹下进行编译
make test -j8
make runtest -j8 #使用CPU多核同时进行编译
问题2:
CMake Error at cuda_compile_generated_lrn_layer.cu.o.cmake:206 (message)
在成功安装cuda之后,由于路径设置问题,或者路径冲突会产生以下错误,解决方法:
1.在caffe文件夹下,通过下面该命令查看配置路径:
sudo find / -name nvcc
2.通过下面命令查看是否cuda路径冲突:
$PATH
如果显示结果有两个cuda环境变量,那么需要移除旧的路径,更新PATH。
3.重新设置cuda环境变量
在/etc/profile中添加CUDA环境变量
PATH=/usr/local/cuda/bin:$PATH
export PATH
然后注销或重启(因为注销或重启之后PATH会从 ~/.bash_profile文件中重新读取)
问题3:pycaffe编译过程中的问题
错误信息:touch python/caffe/proto/__init__.py
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
PROTOC (python) src/caffe/proto/caffe.proto
python/caffe/_caffe.cpp:1:52: fatal error: Python.h: No such file or directory
#include <Python.h> // NOLINT(build/include_alpha)
compilation terminated.
make: *** [python/caffe/_caffe.so] Error 1
因为我的python环境安装的是spyder,而不是Anaconda,因此在makefile.config里面需要对路径进行设置
# 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 \
# We need to be able to find libpythonX.X.so or .dylib.
PYTHON_LIB := /usr/lib
# PYTHON_LIB := $(ANACONDA_HOME)/lib
Python.h can running sudo find / -name 'Python.h' to find the path.
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询