【问题标题】:Can't install the "Boost" prerequisite for Caffe无法为 Caffe 安装“Boost”先决条件
【发布时间】:2016-09-10 21:49:25
【问题描述】:

我正在研究机器学习,最近我遇到了这个问题:Wide-Area Image Geolocalization with Aerial Reference Imagery

这是一个仅根据图像预测图像 GPS 位置的网络。不用说,我很激动,只是发现其中一个要求:

import glob
import caffe
import numpy as np
import multiprocessing
import matplotlib.pyplot as plt
from collections import defaultdict

是Caffe,我似乎无法安装,因为我无法安装主要的先决条件:Boost

我第一次尝试运行标准sudo apt-get install libboost-all-dev,不仅失败了:

The following packages have unmet dependencies:
 libboost-all-dev : Depends: libboost-chrono-dev but it is not going to be installed
                    Depends: libboost-date-time-dev but it is not going to be installed
                    Depends: libboost-filesystem-dev but it is not going to be installed
                    Depends: libboost-graph-dev but it is not going to be installed
                    Depends: libboost-graph-parallel-dev but it is not going to be installed
                    Depends: libboost-iostreams-dev but it is not going to be installed
                    Depends: libboost-log-dev but it is not going to be installed
                    Depends: libboost-mpi-dev but it is not going to be installed
                    Depends: libboost-mpi-python-dev but it is not going to be installed
                    Depends: libboost-program-options-dev but it is not going to be installed
                    Depends: libboost-python-dev but it is not going to be installed
                    Depends: libboost-regex-dev but it is not going to be installed
                    Depends: libboost-serialization-dev but it is not going to be installed
                    Depends: libboost-system-dev but it is not going to be installed
                    Depends: libboost-thread-dev but it is not going to be installed
                    Depends: libboost-wave-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

它给了我一个“但它不会被安装”的错误。然后我尝试从源代码安装:

wget -O boost_1_55_0.tar.gz http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.gz/download
tar xzvf boost_1_55_0.tar.gz
cd boost_1_55_0/
./bootstrap.sh --prefix=/usr/local
./b2

这很快就让我的整个终端充满了 g++ 错误。然后我尝试从头开始:

sudo apt-get --purge remove libboost-all-dev libboost-dev libboost-doc
sudo apt-get install -f
sudo dpkg --configure -a
sudo apt-get clean
sudo apt-get update
sudo apt-get install libboost1.54-dev

虽然 测试脚本 一起工作:How to Install boost on Ubuntu?

当我尝试make caffe 时,我得到了这个:

CXX src/caffe/util/db.cpp
In file included from ./include/caffe/common.hpp:19:0,
                 from ./include/caffe/util/db.hpp:6,
                 from src/caffe/util/db.cpp:1:
./include/caffe/util/device_alternate.hpp:34:23: fatal error: cublas_v2.h: No such file or directory
 #include <cublas_v2.h>
                       ^
compilation terminated.
make: *** [.build_release/src/caffe/util/db.o] Error 1

这可能是什么问题?

【问题讨论】:

    标签: python boost compilation shared-libraries caffe


    【解决方案1】:

    好吧,我不认为这是一个 Boost 问题,而是一个 Caffe 问题!

    据报道,对于 Caffe 安装,请确保 set CPU_Only := 1 在您的 makefile.config 中如下所示:

    # CPU-only switch (uncomment to build without GPU support).
    CPU_ONLY := 1
    

    这是由于您的 device_alternate.hpp 具有以下内容:

    line  4: #ifdef CPU_ONLY
    line 32: #else
    line 34: #include <cublas_v2.h>
    line 99: #endif
    

    【讨论】:

    • 好的,那么在上面写着“# CPU-only switch (uncomment to build without GPU support)”的地方我是取消注释两行还是只取消注释一个?
    • 如果它解决了您的原始问题,请不要忘记接受答案。谢谢