在Ubuntu 18.04 LTS上安装Caffe

5
我将为您翻译以下内容:

我正在安装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 版本吗?感谢阅读我的问题。

我可能认为我不知道如何正确使用“make”命令。我找到了一些用法,它们说可以在任何目录中制作脚本文件,然后只需在相同的目录中输入“make all”命令。这是正确的吗? - Yang
3个回答

3

我按照以下步骤成功地使其工作起来:

  1. Get caffe source form here (https://github.com/BVLC/caffe.git)

  2. Install CUDA if you need GPS support (https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804)

  3. Install CUDNN, if you need GPS support (https://developer.nvidia.com/rdp/cudnn-download)

  4. Replace existing Makefile.config with this (https://gist.github.com/GPrathap/1f9d184c55779509860b8bf92cea416d) Here I have configured for cuda 9.2. If you have a different version please search 9.2 and change the version which you have instaled. Also, please recheck all the paths which are declared in Makefile.config.

  5. You may type make all followed by make test

  6. make distribute for creating the final lib, an include directory of caffe which can be found in (caffe/distribute).

  7. If you are using CMake type project add where to find caffe as bellow,

      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. Add include directory include_directories(${Caffe_INCLUDE_DIRS})

  9. Add library ${Caffe_LIBRARIES}

  10. If you want to have another way of building it add PATH appropriately


你好,请列出你已经安装的依赖项。 - Atinesh
如果您已经安装了CUDA,我猜您不需要安装任何依赖项。不能确定。尝试一下,如果您找不到任何依赖项,也无法安装,请告诉我。 - GPrathap
我有Ubuntu 18.04,CUDA 9.0和CuDNN 7.4。就官方网站(http://caffe.berkeleyvision.org/install_apt.html)而言,他们已经提到运行一个简单的命令来安装caffe(支持GPU),即 sudo apt install caffe-cudasudo apt build-dep caffe-cuda。但我没有找到任何人通过这种方式成功安装它,几乎每个人都使用类似于(https://gist.github.com/nikitametha/c54e1abecff7ab53896270509da80215)的步骤来在Ubuntu 18.04中安装caffe。 - Atinesh
你好,我尝试安装它,但遇到了错误,我正在使用这个caffe。出现了这个错误,其他文件的链接包括Makefile.configDependencies InstalledUbuntu 18.04CUDA 9.0CuDNN 7.4 - Atinesh
我在你的文件上添加了注释。 - GPrathap

1
关于问题的第一部分,即官方网站建议的依赖自动安装,一个简单的应对方法如下:
1. 在终端中输入
software-properties-gtk

在出现的窗口中,确保勾选了“源代码”框。这将向您的sources.list文件添加关键行。
然后,您就可以运行相应的命令了:
sudo apt build-dep caffe-cpu        # dependencies for CPU-only version
sudo apt build-dep caffe-cuda       # dependencies for CUDA version

提议在此处添加这些行上添加一种额外的 CLI 方法(然而建议在 Docker 镜像内进行修改,这可能会限制但也能防止破坏系统文件)。


1
你可以在你的源列表中添加这些 deb-src 行:
deb http://ftp2.cn.debian.org/debian sid main contrib non-free  
deb-src http://ftp2.cn.debian.org/debian sid main contrib non-free

如果出现公钥错误,这些命令将会帮助你。
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 04EE7237B7D453EC  
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接