首页 > 解决方案 > 在 ubuntu 18.04 LTS 上安装 caffe

问题描述

我在 Ubuntu 18.04 LTS 版本上安装 caffe-cpu 和 anaconda。

无论如何,我成功地在我的系统上安装了 Anaconda,但是我在安装 caffe 时遇到了麻烦。

我找到了很多页面,例如 youtube,但它没有帮助,所以我多次阅读官方安装手册页面(我认为这里是官方页面)。在这个页面中,

Installing Caffe from source

We may install the dependencies by merely one line
sudo apt build-dep caffe-cpu        # dependencies for CPU-only version
sudo apt build-dep caffe-cuda       # dependencies for CUDA version

它需要在你的sources.list 中有一个deb-src 行。继续编译

我不知道结束线的意思。我试图修复/etc/apt/sources.list为禁用
的 '#' 部分,但它失败了。我在互联网上找不到正确的方法。当我只是按照编译链接时,他们会说使用 Make 或 CMake 进行编译。我也不知道如何关注这些信息。我发现了一些makefile.config Github 页面make all,当我使用命令时它失败了。

你能给我一些建议来帮助安装 caffe-cpu 版本吗?感谢您阅读我的问题。

标签: makefilecaffeubuntu-18.04

解决方案


我能够按照这些步骤让它工作,

  1. 在此处获取 caffe 源表单 ( https://github.com/BVLC/caffe.git )

  2. 如果您需要 GPS 支持,请安装 CUDA ( https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804 )

  3. 如果您需要 GPS 支持,请安装 CUDNN ( https://developer.nvidia.com/rdp/cudnn-download )

  4. 用这个替换现有的 Makefile.config ( https://gist.github.com/GPrathap/1f9d184c55779509860b8bf92cea416d ) 这里我已经为 cuda 9.2 配置了。如果您有不同的版本,请搜索 9.2 并更改您安装的版本。另外,请重新检查 Makefile.config 中声明的所有路径。

  5. 您可以键入make all后跟make test

  6. make distribute为了创建最终的库,一个包含目录的 caffe 可以在 (caffe/distribute) 中找到。

  7. 如果您使用的是 CMake 类型的项目,请添加在哪里可以找到 caffe,如下所示,

      set(Caffe_DIR "/home/software/caffe/distribute")   
      set(Caffe_INCLUDE_DIRS "/home/software/caffe/distribute/include")  
      set(Caffe_LIBRARIES "/home/software/caffe/distribute/lib/libcaffe.so")
    
  8. 添加包含目录include_directories(${Caffe_INCLUDE_DIRS})

  9. 添加库${Caffe_LIBRARIES}

  10. 如果您想有另一种构建方式,请适当添加 PATH


推荐阅读