caffe编译的问题解决:“cublas_v2.h: No such file or directory”

今天编译遇到同样的问题,查找网上资料如下, 自己的笔记本不是NV的,cuda 估计也用不了。。。

这是官方资料: http://caffe.berkeleyvision.org/installation.html

很多时候,我们的.h/.so/.a/bin文件都不在Linux发行版所指定的默认路径下,这时可以通过~/.bashrc来增加搜索路径。 #增加.so搜索路径 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/liheyuan/soft/lib

#增加.a搜索路径 LIBRARY_PATH=$LIBRARY_PATH:/home/liheyuan/soft/lib

#增加bin搜索路径 export PATH=$PATH:/home/liheyuan/soft/bin

#增加GCC的include文件搜索路径 export C_INCLUDE_PATH=$C_INCLUDE_PATH:/home/liheyuan/soft/include

#增加G++的include文件搜索路径

export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/home/liheyuan/soft/inc

(http://www.coder4.com/archives/2100)

主要问题还是没有把cuda的头文件、库的路径放置到caffe的Makefile.config中;


具体来说:

CUDA7.5中的include、lib路径是安装目录下/usr/local/cuda-7.5/targets/x86_64-Linux/下面的include和lib

将其分别添加到caffe根目录下Makefile.config中的"INCLUDE_DIRS"、“LIBRARY_DIRS”后面就可以了。

make all

make test


==========接着在make runtest的时候出现错误 core dumped

1、随机数的那个例子出错,解决:export MKL_CBWR=AUTO

2、test_common.cpp,出现的CUDA launch之类的错误,可能是因为使用了GTX1080以及CUDA7.5的原因,更新CUDA到8.0就没有这个错误了。

所以相应的需要更改"Makefile.config"文件中的包含目录

ctrl+f 找到

INCLUDE_DIRS:=$(PYTHON_INCLUDE) /usr/local/include

然后在后面加上"serial"的包含目录,即:

INCLUDE_DIRS:=$(PYTHON_INCLUDE) /usr/local/include/usr/include/hdf5/serial/

接着需要更改相应的"Makefile"文件,找到

LIBRARIES +=glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5 更改最后两项为:

LIBRARIES +=glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial

就可以了,继续make了。

“fatal error: hdf5.h: 没有那个文件或目录”解决方法

参考自http://blog.csdn.net/hongye000000/article/details/51043913 Step 1

在Makefile.config文件的第85行,添加/usr/include/hdf5/serial/ 到 INCLUDE_DIRS,也就是把下面第一行代码改为第二行代码。

INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include

INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/

Step 2

在Makefile文件的第173行,把 hdf5_hl 和hdf5修改为hdf5_serial_hl 和 hdf5_serial,也就是把下面第一行代码改为第二行代码。

LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5

LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial

#cuda 出错

警告打印:

[plain] view plain copy 在CODE上查看代码片派生到我的代码片

nvcc warning : The 'compute_11', 'compute_12', 'compute_13', 'sm_11', 'sm_12', and 'sm_13' architectures are deprecated, and may be removed in a future release.  

找到cmake后产生的OpencvConfig.cmake文件,找到如下代码:

[plain] view plain copy 在CODE上查看代码片派生到我的代码片

# Version Compute Capability from which OpenCV has been compiled is remembered  
set(OpenCV_COMPUTE_CAPABILITIES -gencode;arch=compute_11,code=sm_11;-gencode;arch=compute_12,code=sm_12;-gencode;arch=compute_13,code=sm_13;-gencode;arch=compute_20,code=sm_20;-gencode;arch=compute_20,code=sm_21;-gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_30,code=compute_30)  

将"-gencode ;arch=compute_11,code=sm_11";-gencode;arch=compute_12,code=sm_12;-gencode;arch=compute_13,code=sm_13; 等删除。

主要因为此架构在CUDA过时~~将来也将不支持

以上若无果:

在cmakelist中关闭cuda~~

或者在cmake时加上参数-D BUILD_opencv_gpu=OFF

caffe python 模块的编译使用

为什么每次从python导入caffe都要编译接口

1.安装python:

yum install python-devel.x86_64

2.Makefile.config修改

WITH_PYTHON_LAYER := 1 #取消注释

3.安装python依赖

如果安装 Anaconda Python可以免去下面步骤

cd $CAFFE_ROOT/python for req in $(cat requirements.txt); do pip install $req; done

4.编译

make clean make pycaffe -j32 make test -j32

  1. 使Caffe的python接口永久生效

vim /etc/profile profile最后添加: export PYTHONPATH=/root/$CAFFE_ROOT/python:$PYTHONPATH source /etc/profile

注意:

有一些python库没有安装,在import caffe测试时会出错,常见的库缺失错误:

ImportError: No module named skimage.io

ImportError: No module named scipy

ImportError: No module named google.protobuf.internal

yum install python-matplotlib.x86_64
pip install -U scikit-image
pip install scipy
easy_install protobuf

安装完成上述caffe依赖的python库后,可能需要重新执行一遍第4,5步操作。

方法二,该方法适用于Ubuntu [](

在命令行输入Python;再输入import caffe时,可能会报以下错误:

can not find module skimage.io 此时只要按照以下命令操作即可:

$ sudo apt-get install python-numpy python-scipy python-matplotlib python-sklearn python-skimage python-h5py python-protobuf python-leveldb python-networkx python-nose python-pandas python-gflags Cython ipython

$ sudo apt-get update 在caffe-master目录下: $ make pycaffe 然后在命令行输入python;再输入import caffe就可以成功啦。 )

参考资料:

hdf5 出错

转载于:https://my.oschina.net/innovation/blog/803563

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值