无法找到包 caffe-cpu

无法找到包 caffe-cpu

我正在尝试安装 caffe,但遇到以下错误

sudo apt-get install caffe-cpu
[sudo] password for : 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package caffe-cpu

这是我的版本:

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.4 LTS
Release:    16.04
Codename:   xenial

我尝试按照这里的说明进行操作https://chunml.github.io/ChunML.github.io/project/Installing-Caffe-CPU-Only/

得到

CXX src/caffe/test/test_hdf5_output_layer.cpp
In file included from src/caffe/test/test_hdf5_output_layer.cpp:8:0:
./include/caffe/layers/hdf5_output_layer.hpp:4:18: fatal error: hdf5.h: No such file or directory
compilation terminated.
Makefile:581: recipe for target '.build_release/src/caffe/test/test_hdf5_output_layer.o' failed
make: *** [.build_release/src/caffe/test/test_hdf5_output_layer.o] Error 1

这就是我所拥有的

  ThinkPad-T520:/usr/lib/x86_64-linux-gnu$ ls -al | grep libhdf5_serial
    lrwxrwxrwx   1 root root        53 Jul 19 10:03 libhdf5_hl.so -> /usr/lib/x86_64-linux-gnu/libhdf5_serial_hl.so.10.0.2
    -rw-r--r--   1 root root  19953086 Apr  5  2016 libhdf5_serial.a
    -rw-r--r--   1 root root   1659560 Apr  5  2016 libhdf5_serial_fortran.a
    lrwxrwxrwx   1 root root        32 Apr  5  2016 libhdf5_serial_fortran.so -> libhdf5_serial_fortran.so.10.0.2
    lrwxrwxrwx   1 root root        32 Apr  5  2016 libhdf5_serial_fortran.so.10 -> libhdf5_serial_fortran.so.10.0.2
    -rw-r--r--   1 root root    238408 Apr  5  2016 libhdf5_serial_fortran.so.10.0.2
    -rw-r--r--   1 root root    878832 Apr  5  2016 libhdf5_serial_hl.a
    -rw-r--r--   1 root root    515320 Apr  5  2016 libhdf5_serialhl_fortran.a
    lrwxrwxrwx   1 root root        34 Apr  5  2016 libhdf5_serialhl_fortran.so -> libhdf5_serialhl_fortran.so.10.0.2
    lrwxrwxrwx   1 root root        34 Apr  5  2016 libhdf5_serialhl_fortran.so.10 -> libhdf5_serialhl_fortran.so.10.0.2
    -rw-r--r--   1 root root     80520 Apr  5  2016 libhdf5_serialhl_fortran.so.10.0.2
    lrwxrwxrwx   1 root root        27 Apr  5  2016 libhdf5_serial_hl.so -> libhdf5_serial_hl.so.10.0.2
    lrwxrwxrwx   1 root root        27 Apr  5  2016 libhdf5_serial_hl.so.10 -> libhdf5_serial_hl.so.10.0.2
    -rw-r--r--   1 root root    126232 Apr  5  2016 libhdf5_serial_hl.so.10.0.2
    -rw-r--r--   1 root root      3859 Apr  5  2016 libhdf5_serial.settings
    lrwxrwxrwx   1 root root        24 Apr  5  2016 libhdf5_serial.so -> libhdf5_serial.so.10.1.0
    lrwxrwxrwx   1 root root        24 Apr  5  2016 libhdf5_serial.so.10 -> libhdf5_serial.so.10.1.0
    -rw-r--r--   1 root root   2734288 Apr  5  2016 libhdf5_serial.so.10.1.0
    lrwxrwxrwx   1 root root        50 Jul 19 10:03 libhdf5.so -> /usr/lib/x86_64-linux-gnu/libhdf5_serial.so.10.1.0

对 Makefine.config 进行更改后,获取

CXX src/caffe/util/hdf5.cpp
CXX src/caffe/util/benchmark.cpp
CXX src/caffe/internal_thread.cpp
CXX src/caffe/layer.cpp
CXX src/caffe/layer_factory.cpp
LD -o .build_release/lib/libcaffe.so.1.0.0
/usr/bin/ld: cannot find -lopencv_imgcodecs
/usr/bin/ld: cannot find -lcblas
/usr/bin/ld: cannot find -latlas
collect2: error: ld returned 1 exit status
Makefile:572: recipe for target '.build_release/lib/libcaffe.so.1.0.0' failed
make: *** [.build_release/lib/libcaffe.so.1.0.0] Error 1

答案1

caffe-cpu 位于 Ubuntu 18.04 及更高版本的默认 Ubuntu 存储库中。升级到 Ubuntu 18.04 后,您可以使用以下命令安装 caffe-cpu:

sudo apt update  
sudo apt install caffe-cpu

apt-cache showpkg caffe-cpuUbuntu 18.04 中的结果:

Reverse Depends: 
  caffe-cuda,caffe-cpu
  caffe-cpu:i386,caffe-cpu
  science-machine-learning,caffe-cpu
Dependencies: 
1.0.0-6 - caffe-tools-cpu (5 1.0.0-6) python3-caffe-cpu (5 1.0.0-6) libcaffe-cpu1 (5 1.0.0-6) libopenblas-base (16 (null)) libatlas3-base (16 (null)) libblas.so.3 (0 (null)) caffe-cuda (0 (null)) libcaffe-cpu-dev (5 1.0.0-6) caffe-doc (5 1.0.0-6) caffe-cpu:i386 (32 (null)) 
Provides: 
1.0.0-6 - 
$sudo apt-get install -s caffe-cpu
正在读取软件包列表...完成
构建依赖关系树       
正在读取状态信息...完成
将会安装以下附加软件包:
  caffe-tools-cpu libboost-python1.65.1 libcaffe-cpu1 libgflags2.2
  libgoogle-glog0v5 libleveldb1v5 liblmdb0 python3-caffe-cpu python3-gflags
  python3-leveldb
建议的软件包:
  libcaffe-cpu-dev caffe-doc
将会安装以下新软件包:
  caffe-cpu caffe-tools-cpu libboost-python1.65.1 libcaffe-cpu1 libgflags2.2
  libgoogle-glog0v5 libleveldb1v5 liblmdb0 python3-caffe-cpu python3-gflags
  python3-leveldb
升级了 0 个,新安装了 11 个,删除了 0 个,并且未升级 0 个。
安装 libboost-python1.65.1(1.65.1+dfsg-0ubuntu5 Ubuntu:18.04/bionic [amd64])
安装 libgflags2.2(2.2.1-1 Ubuntu:18.04/bionic [amd64])
安装 libgoogle-glog0v5(0.3.5-1 Ubuntu:18.04/bionic [amd64])
安装 libleveldb1v5(1.20-2 Ubuntu:18.04/bionic [amd64])
安装 liblmdb0(0.9.21-1 Ubuntu:18.04/bionic [amd64])
安装 libcaffe-cpu1(1.0.0-6 Ubuntu:18.04/bionic [amd64])
安装 caffe-tools-cpu(1.0.0-6 Ubuntu:18.04/bionic [amd64])
安装 python3-gflags(1.5.1-5 Ubuntu:18.04/bionic [全部])
安装 python3-leveldb(0~svn68-3build3 Ubuntu:18.04/bionic [amd64])
安装 python3-caffe-cpu(1.0.0-6 Ubuntu:18.04/bionic [amd64])
安装 caffe-cpu(1.0.0-6 Ubuntu:18.04/bionic [amd64])
配置 libboost-python1.65.1(1.65.1+dfsg-0ubuntu5 Ubuntu:18.04/bionic [amd64])
配置 libgflags2.2(2.2.1-1 Ubuntu:18.04/bionic [amd64])
配置 libgoogle-glog0v5(0.3.5-1 Ubuntu:18.04/bionic [amd64])
配置 libleveldb1v5(1.20-2 Ubuntu:18.04/bionic [amd64])
配置 liblmdb0(0.9.21-1 Ubuntu:18.04/bionic [amd64])
配置 libcaffe-cpu1(1.0.0-6 Ubuntu:18.04/bionic [amd64])
配置 caffe-tools-cpu(1.0.0-6 Ubuntu:18.04/bionic [amd64])
配置 python3-gflags(1.5.1-5 Ubuntu:18.04/bionic [全部])
配置 python3-leveldb(0~svn68-3build3 Ubuntu:18.04/bionic [amd64])
配置 python3-caffe-cpu(1.0.0-6 Ubuntu:18.04/bionic [amd64])
配置 caffe-cpu(1.0.0-6 Ubuntu:18.04/bionic [amd64])

答案2

我发现启动和运行的最佳方法是使用 conda。这种方式允许您拥有许多不同的 caffe 环境。首先安装 miniconda,然后创建一个环境

conda create -n caffe

然后

conda install caffe

或者

conda install caffe-gpu

conda 不仅可以解决所有依赖关系,还可以安装正确版本的 cudatoolkit 和 cudnn。如果你想要 Python 2,你可以

conda create -n python2Caffe-GPU python=2.7

conda install caffe-gpu=1.0=py27heda4471_3

变量 py27heda4471_3 是构建版本,你可以从多个版本中进行选择

conda search caffe-gpu

给出一个列表

相关内容