Compile caffe while another caffe exists already

1. Problem

[dashuage caffe-fast-rcnn]$ make
CXX/LD -o .build_release/examples/cifar10/convert_cifar_data.bin
/usr/bin/ld: warning: libhdf5_hl.so.100, needed by /usr/lib/libcaffe.so, may conflict with libhdf5_hl.so.10
/usr/bin/ld: warning: libhdf5.so.100, needed by /usr/lib/libcaffe.so, may conflict with libhdf5.so.10
/usr/bin/ld: .build_release/examples/cifar10/convert_cifar_data.o: undefined reference to symbol '_ZdlPvm'
/usr/lib/libtcmalloc.so.4: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [Makefile:613: .build_release/examples/cifar10/convert_cifar_data.bin] Error 1

2. Analysis

When make, it does three things:
- make lib
- make tools
- make examples
This error occured when make the latter two objects.

Since there is another caffe installed already, we don’t really need to rebuild tools and examples. Use ln to link.

3. Solution

  1. Edit Makefile

    #all: lib examples tools
    all: lib
  2. make all
  3. set link
#!/bin/bash
cd build/tools/
ln -s /usr/bin/caffe caffe
ln -s /usr/bin/compute_image_mean compute_image_mean
ln -s /usr/bin/convert_imageset convert_imageset
ln -s /usr/bin/device_query device_query
ln -s /usr/bin/extract_features extract_features
ln -s /usr/bin/finetune_net finetune_net
ln -s /usr/bin/net_speed_benchmark net_speed_benchmark
ln -s /usr/bin/test_net test_net
ln -s /usr/bin/train_net train_net
ln -s /usr/bin/upgrade_net_proto_binary upgrade_net_proto_binary
ln -s /usr/bin/upgrade_net_proto_text upgrade_net_proto_text
ln -s /usr/bin/upgrade_solver_proto_text upgrade_solver_proto_text
cd ../examples
ln -s /usr/bin/convert_cifar_data ./cifar10/convert_cifar_data.bin
ln -s /usr/bin/classification ./cpp_classification/classification.bin
ln -s /usr/bin/convert_mnist_data ./mnist/convert_mnist_data.bin
ln -s /usr/bin/convert_mnist_siamese_data ./siamese/convert_mnist_siamese_data.bin
### 编译Caffe以用于Matlab 为了使Caffe能够在MATLAB环境中运行,需要按照特定流程配置和编译Caffe。以下是详细的说明: #### 配置环境变量和支持库 确保已经安装了必要的依赖项,包括BLAS库等基础组件[^5]。对于MATLAB接口的支持,则需确认已正确设置了CUDA(如果打算利用GPU加速)、OpenCV以及其他可能需要用到的第三方库。 #### 修改`Makefile.config` 在开始编译之前,应当先编辑位于根目录下的`Makefile.config`文件来启用MATLAB接口支持。找到该文件并将如下选项设置为开启状态: ```makefile WITH_MATLAB := 1 ``` 这一步骤告知构建系统准备生成MATLAB可以调用的目标文件[^4]。 #### 安装MATLAB引擎API for C++ 由于新版MATLAB推荐使用其提供的C++ API而非传统的MEX文件形式来进行外部程序集成,因此建议下载并解压对应版本的MATLAB Engine API for C++ SDK到本地路径下,并相应更新`Makefile.config`内的指定位置以便于链接器能够定位这些头文件及静态库[^2]。 #### 执行编译过程 完成上述准备工作之后,在终端执行命令启动正式编译工作: ```bash make all -j$(nproc) make matcaffe -j$(nproc) ``` 这里`make matcaffe`指令专门负责处理与MATLAB交互有关的部分,即所谓的Matcaffe工具集。 一旦顺利完成整个编译链路,就可以通过简单的测试案例验证新搭建起来的平台是否正常运作了。例如尝试加载预训练模型并对单张图片实施分类预测操作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值