最全caffe安装踩坑记录(Anaconda,nvidia-docker,Linux编译)
Anaconda,nvidia-docker,Linux三种方式安装caffe
1.Anaconda安装caffe
1.首先安装anaconda
2.创建虚拟环境(python2.7)
conda create -n caffe python=2.7 anaconda
3.安装caffe
# 然后下面二选一即可,安装caffe
conda install -c conda-forge caffe
conda install -c conda-forge/label/broken caffe
4.注意:
# 如果出现numpy导入错误,是因为 conda-forge中的numpy版本过低,可再输入下面命令
pip install numpy --upgrade
5.测试
# 测试是否成功
source activate caffe
python
import caffe
2.nvidia-docker安装caffe-gpu
注意:docker仅支持cpu
nvidia-docker支持GPU
1.安装nvidia-docker
wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.1/nvidia-docker_1.0.1-1_amd64.deb
sudo dpkg -i /tmp/nvidia-docker*.deb
# 测试
nvidia-docker run --rm nvidia/cuda nvidia-smi
2.拉取caffe-gpu镜像
nvidia-docker pull bvlc/caffe:gpu
3.启动一个容器
nvidia-docker run --rm -ti <镜像名字>
docker attach <容器id> # 已打开的容器
# 退出容器 ctrl + d (容器不运行)或者ctrl q+p(容器后台运行)
# 进入未运行的容器
docker ps -a # 查看容器id
docker start <id>
docker attach <id>
# 容器改名
dockers rename 原id 新id
4.更新源
apt uptate
5.测试
#caffe安装目录默认在/opt/caffe,若想支持opencv,多gpu,请自行编译,可参看第三种方式编译安装caffe
python
import caffe
3.Linux编译caffe,并支持多GPU
1.linux安装git
# Centos
yum install git
# Ubuntu
sudo apt-get install git
git clone https://github.com/BVLC/caffe.git
2.编译前的Makefile.config配置
# 新建Makefile.config
mv Makefile.config.example Makefile.config
注意:
## Refer to http://caffe.berkeleyvision.org/installation.html
# Contributions simplifying and improving our build system are welcome! # cuDNN acceleration switch (uncomment to build with cuDNN).
USE_CUDNN := # CPU-only switch (uncomment to build without GPU support).
# CPU_ONLY := # uncomment to disable IO dependencies and corresponding data layers
# USE_OPENCV :=
# USE_LEVELDB :=
# USE_LMDB := # uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)
# You should not set this flag if you will be reading LMDBs with any
# possibility of simultaneous read and write
# ALLOW_LMDB_NOLOCK := # Uncomment if you're using OpenCV 3
OPENCV_VERSION := # To customize your choice of compiler, uncomment and set the following.
# N.B. the default for Linux is g++ and the default for OSX is clang++
# CUSTOM_CXX := g++ # CUDA directory contains bin/ and lib/ directories that we need.
CUDA_DIR := /usr/local/cuda
# On Ubuntu 14.04, if cuda tools are installed via
# "sudo apt-get install nvidia-cuda-toolkit" then use this instead:
# CUDA_DIR := /usr # CUDA architecture setting: going with all of them.
# For CUDA < 6.0, comment the *_50 through *_61 lines for compatibility.
# For CUDA < 8.0, comment the *_60 and *_61 lines for compatibility.
# For CUDA >= 9.0, comment the *_20 and *_21 lines for compatibility.
CUDA_ARCH := -gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_60,code=sm_60 \
-gencode arch=compute_61,code=sm_61 \
-gencode arch=compute_61,code=compute_61 # BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
BLAS := atlas
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
# BLAS_INCLUDE := /path/to/your/blas
# BLAS_LIB := /path/to/your/blas # Homebrew puts openblas in a directory that is not on the standard search path
# BLAS_INCLUDE := $(shell brew --prefix openblas)/include
# BLAS_LIB := $(shell brew --prefix openblas)/lib # This is required only if you will compile the matlab interface.
# MATLAB directory should contain the mex binary in /bin.
# MATLAB_DIR := /usr/local
# MATLAB_DIR := /Applications/MATLAB_R2012b.app # NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
PYTHON_INCLUDE := /usr/include/python2. \
/usr/lib/python2./dist-packages/numpy/core/include
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location, sometimes it's in root.
# ANACONDA_HOME := $(HOME)/anaconda
# PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
# $(ANACONDA_HOME)/include/python2. \
# $(ANACONDA_HOME)/lib/python2./site-packages/numpy/core/include # Uncomment to use Python (default is Python )
# PYTHON_LIBRARIES := boost_python3 python3.5m
# PYTHON_INCLUDE := /usr/include/python3.5m \
# /usr/lib/python3./dist-packages/numpy/core/include # We need to be able to find libpythonX.X.so or .dylib.
PYTHON_LIB := /usr/lib
# PYTHON_LIB := $(ANACONDA_HOME)/lib # Homebrew installs numpy in a non standard path (keg only)
# PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include
# PYTHON_LIB += $(shell brew --prefix numpy)/lib # Uncomment to support layers written in Python (will link against Python libs)
WITH_PYTHON_LAYER := # Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial # If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
# INCLUDE_DIRS += $(shell brew --prefix)/include
# LIBRARY_DIRS += $(shell brew --prefix)/lib # NCCL acceleration switch (uncomment to build with NCCL)
# https://github.com/NVIDIA/nccl (last tested version: v1.2.3-1+cuda8.0)
USE_NCCL := # Uncomment to use `pkg-config` to specify OpenCV library paths.
# (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
# USE_PKG_CONFIG := # N.B. both build and distribute dirs are cleared on `make clean`
BUILD_DIR := build
DISTRIBUTE_DIR := distribute # Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171
# DEBUG := # The ID of the GPU that 'make runtest' will use to run unit tests.
TEST_GPUID := # enable pretty build (comment to see full commands)
Q ?= @
1.第5行USE_CUDNN := 1(安装和cuda匹配的cudnn)
2.第21行 OPENCV_VERSION := 3(安装opencv)
sudo apt install git
git clone https://github.com/jayrambhia/Install-OpenCV
cd Install-OpenCV/Ubuntu/
chmod +x *
./opencv_latest.sh make -j8 && make pycaffe
3.第28行CUDA_DIR := /usr/local/cuda(安装cuda的目录)
4.第49行BLAS := atlas
5.第67,68行
PYTHON_INCLUDE := /usr/include/python2. \
/usr/lib/python2./dist-packages/numpy/core/include
6.第93,94行
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial
7.第102行USE_NCCL := 1(支持多gpu)
git clone https://github.com/NVIDIA/nccl.git
cd nccl
sudo make install
sudo gedit ~/.bashrc
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/XXX/nccl/build/lib/" #XXX为用户名
source .bashrc 使用多个gpu
我们在使用caffe的工具训练网络时,在语句的最后加上以下内容即可 -gpu all #运行所有的gpu
-gpu , #运行1号2号gpu
3.开始编译
sudo make all
sudo make test
sudo make pycaffe
sudo make runtest
4.测试
python
import caffe
最全caffe安装踩坑记录(Anaconda,nvidia-docker,Linux编译)的更多相关文章
- Linux mint 安装踩坑记录
记得之前电脑上的那个Ubuntu是去年寒假的时候安装的,算下来自己用Linux也快一年了.虽然在去年暑假的时候我也曾经想过要把Ubuntu升级到18.04可是当时安装了几次都没有成功,自己也就放弃了. ...
- opencv c++安装踩坑记录 file cannot create directory: /usr/local/include/opencv2. Maybe need administrative privileges
前言 最近深度学习Ultra-Fast-Lane-Detection/INSTALL.md at master · cfzd/Ultra-Fast-Lane-Detection (github.com ...
- Ubuntu18.04 显卡驱动+Cuda安装踩坑记录 以及Ubuntu虚拟内存的添加
前几天买了张亮机卡,终于把主显卡成功直连到Unraid OS的虚拟机上了.然后就开始安装ubuntu系统开始配置环境,遇到了不少坑,特此记录. gcc版本问题 在安装显卡驱动的时候,不要修改gcc版本 ...
- Win10自带Ubuntu子系统下Mysql安装踩坑记录
linux系统为win10自带Ubuntu子系统 错误的安装过程 我按照一般的方法安装mysql,安装步骤如下 1.升级源 $ sudo apt-get update 2.安装mysql $ sudo ...
- docker安装踩坑记录
.docker安装包安装很顺利, yum安装安装源在官网或镜像网站下载, fedora/centos分别下载不同的, 在/etc/yum.repos.d/doccker-ce.repo, 把网址改为镜 ...
- pyltp安装踩坑记录
LTP(Language Technology Platform)由哈工大社会计算与信息检索研究中心开发,提供包括中文分词.词性标注.命名实体识别.依存句法分析.语义角色标注等丰富. 高效.精准的自然 ...
- VNPY - windows 安装踩坑记录
twisted requires PyHamcrest>=, which is not ins grin requires argparse>=1.1, which is not inst ...
- Manjaro (KDE)安装踩坑记录
1.如果双显卡无法安装系统可以进如BIOS屏蔽显卡后进入安装 2.如果安装kde版本后容易冻屏.死机,可以尝试安装闭源驱动 3.如果出现resolving time out 10000ms 这样的问题 ...
- 全文搜索引擎 Elasticsearch 安装踩坑记录
一.安装 Elastic 需要 Java 8 环境.如果你的机器还没安装 Java 安装完 Java,就可以跟着官方文档安装 Elastic.直接下载压缩包比较简单. $ wget https://a ...
随机推荐
- Delphi xe5调用外部扫描程序——谷歌 zxing
unit uZXing; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Va ...
- HTML5 拖放并删除效果的简单实现
Html5 支持元素drag drop的功能需求,以后实现这类效果会简单很多.. 详细的文档说明在这里 代码如下所示:
- Mariadb的安装与使用
一.安装Mariadb 参考博客:https://www.cnblogs.com/pyyu/p/9467289.html 安装软件的三中方式 yum原码编译安装下载rpm安装 yum与原码编译安装安装 ...
- 3013C语言_输入输出
第三章 输入输出 3.1输入输出概念及其实现 (1)数据从计算机内部向外部输出设备(如显示器.打印机等)输送的操作称为 “输出”,数据从计算机外部向输入设备(如键盘.鼠标.扫描仪等)送入的操作称为 “ ...
- 使用 Python 识别并提取图像中的文字
1. 介绍 介绍使用 python 进行图像的文字识别,将图像中的文字提取出来,可以帮助我们完成很多有趣的事情. 2. 必备工具 tesseract-ocr 下载地址: https://github. ...
- C语言之父Dennis Ritchie告诉你:如何成为世界上最好的程序员?
文/Ohans Emmanuel 译/网易云信 想要阅读更多技术干货文章,欢迎关注网易云信博客. 了解网易云信,来自网易核心架构的通信与视频云服务. 我不知道如何成为世界上最好的程序员.但是,我们可以 ...
- 如何成长为一名合格的web架构师?
写代码要经历下面几个阶段. 一 .你必须学习面向对象的基础知识,如果连这个都忘了,那你的编程之路注定是在做原始初级的重复! 很多程序员都知道类.方法.抽象类.接口等概念,但是为什么要面向对象,好处在 ...
- resolv.conf 的超时(timeout)与重试(attempts)机制
/etc/resolv.conf 有两个默认的值至关重要,一个是超时的 timeout,一个是重试的 attempts,默认情况下,前者是 5s 后者是 2 次.这个估计很多工程师都不是很在意,一般情 ...
- .NET开发框架(五)-IIS上部署ASP.NET Core项目教程
系列教程:从初学者到架构师的一步步蜕变 本篇经验将和大家介绍如何在IIS上部署ASP.NET Core项目,希望对初学.NET CORE的童靴入门有所帮助! 1.打开VS,创建项目,选择ASP.NET ...
- java虚拟机-简介
一.什么是JVM JVM是Java Virtual Machine(Java虚拟机)的缩写,JVM是一种用于计算设备的规范,它是一个虚构出来的计算机,是通过在实际的计算机上仿真模拟各种计算机功能来实现 ...