docker[caffe&&pycaffe]
0 引言
今天花了一天,完成了整个caffe的dockerfile编写,其支持python3.6.6,这里主要的注意点是protobuf的版本(在3.6.0之后,只支持c11),还有在制作镜像的时候注意,尽可能少的创建镜像层,并且及时在当前层删除不要的数据,以减少镜像本身大小。
FROM nvidia/cuda:9.0-cudnn7-devel-centos7
COPY ./caffe /caffe # 将官网github项目下下来,并只修改里面的Makefile.config(下面列出)
COPY ./Centos-7.repo /etc/yum.repos.d # 下载163或者阿里云的yum源,以方便加速
ENV LANG=en_US.UTF-8
ARG PYINSTALL=/usr/local/python3
ENV PATH=$PYINSTALL/bin:$PATH
ARG http_proxy=http://xxxxxxxx:xxxx # 记得修改成你的代理,我们机器需要代理才能上网
ARG https_proxy=https://xxxxxxx:xxxx
RUN rm -f /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-CR.repo /etc/yum.repos.d/CentOS-Debuginfo.repo /etc/yum.repos.d/CentOS-Media.repo /etc/yum.repos.d/CentOS-Sources.repo /etc/yum.repos.d/CentOS-Vault.repo /etc/yum.repos.d/CentOS-fasttrack.repo && \
yum clean all && yum makecache && \
yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && \
# 安装python numpy
yum -y install make zlib-devel openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel && \
yum -y install libSM libXrender libXext wget && \
wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz -O /home/Python-3.6.6.tgz && \
tar -xvf /home/Python-3.6.6.tgz -C /home && \
cd /home/Python-3.6.6 && \
./configure --prefix=$PYINSTALL && \
make -j32 && make install && \
ln -s $PYINSTALL/bin/python3 $PYINSTALL/bin/python && \
/usr/local/python3/bin/pip3 install -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com numpy && \
/usr/local/python3/bin/pip3 install -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com scikit-image && \
# 准备caffe依赖
yum -y install leveldb-devel snappy-devel opencv-devel boost-devel hdf5-devel gflags-devel glog-devel lmdb-devel && \
yum -y install gflags-devel glog-devel lmdb-devel && \
yum -y install openblas-devel python36-devel && \
yum -y groupinstall "Development Tools" "Development Libraries" && \
# 编译boost 修复libboost_python3.so找不到的问题
wget https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.gz -O /home/boost_1_67_0.tar.gz && \
tar -xvf /home/boost_1_67_0.tar.gz -C /home && \
cd /home/boost_1_67_0 && ./bootstrap.sh --with-libraries=python --with-toolset=gcc && \
./b2 cflags='-fPIC' cxxflags='-fPIC' --with-python include=/usr/include/python3.6m && \
./b2 install && \
ln -s /usr/local/lib/libboost_python36.so /usr/lib64/libboost_python3.so && \
echo /usr/local/lib >> /etc/ld.so.conf.d/caffe.conf && ldconfig && \
# 安装protobuf
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.5.1/protobuf-cpp-3.5.1.zip -O /home/protobuf-cpp-3.5.1.zip && \
cd /home && unzip protobuf-cpp-3.5.1.zip && \
cd /home/protobuf-3.5.1 && \
./configure && make -j32 && make install && ldconfig && \
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.5.1/protobuf-python-3.5.1.zip -O /home/protobuf-python-3.5.1.zip && \
cd /home && rm -rf protobuf-3.5.1 && \
unzip protobuf-python-3.5.1.zip && \
cd /home/protobuf-3.5.1 && \
cd python && /usr/local/python3/bin/python3 setup.py build && /usr/local/python3/bin/python3 setup.py install && \
# 安装caffe
cd /caffe && \
make -j32 && make pycaffe -j32 && \
# 清空缓存和无用数据
yum clean all &&\
rm -rf /home/*
# docker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --runtime=nvidia -tid --name zzc_caffe_demo ImageName /bin/bash
其中caffe中的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 := 1 # 支持cudnn
# CPU-only switch (uncomment to build without GPU support).
# CPU_ONLY := 1
# uncomment to disable IO dependencies and corresponding data layers
USE_OPENCV := 1 # 使用opencv
# USE_LEVELDB := 0
# USE_LMDB := 0
# This code is taken from https://github.com/sh1r0/caffe-android-lib
# USE_HDF5 := 0
# 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 := 1
# Uncomment if you're using OpenCV 3
# OPENCV_VERSION := 3
# 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 9.0,所以删除前面2个,让其从30开始
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 := open
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
BLAS_INCLUDE := /usr/include/openblas
BLAS_LIB := /usr/lib64
# 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.7 \
# /usr/lib/python2.7/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.7 \
# $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include
# Uncomment to use Python 3 (default is Python 2)
# 下面要注意你安装python的路径
PYTHON_LIBRARIES := boost_python3 python3.6m
PYTHON_INCLUDE := /usr/include/python3.6m \
/usr/local/python3/lib/python3.6/site-packages/numpy/core/include
# We need to be able to find libpythonX.X.so or .dylib.
PYTHON_LIB := /usr/lib64
# 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 := 1
# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
# 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 := 1
# 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 := 1
# 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 := 1
# The ID of the GPU that 'make runtest' will use to run unit tests.
TEST_GPUID := 0
# enable pretty build (comment to see full commands)
Q ?= @
renference:
docker[caffe&&pycaffe]的更多相关文章
- Docker Caffe部署
Caffe是一个清晰而高效的深度学习框架,纯粹的C++/CUDA架构,支持命令行.Python和MATLAB接口:可以在CPU和GPU直接无缝切换 Caffe的优势 上手快:模型与相应优化都是以文本形 ...
- 基于Anaconda编译caffe+pycaffe+matcaffe in Ubuntu[不用sudo权限]
目录 caffe 编译 环境 github下载caffe源码 依赖 修改源码的编译配置 报错 测试使用 pycaffe caffe matcaffe caffe 编译 环境 Ubuntu16.04 C ...
- [深度学习] centos7上搭建基于Anaconda3的caffe+pycaffe环境(python3.6)
本文记录从零开始在CentOS7.x系统上搭建Caffe深度学习平台,并配置pycaffe环境.(由于在虚拟机上搭建,所以为CPU_ONLY模式) 1.选择CentOS7 mini版镜像安装虚拟机 镜 ...
- Ubuntu 16.04 使用docker资料汇总与应用docker安装caffe并使用Classifier(ros kinetic+usb_cam+caffe)
Docker是开源的应用容器引擎.若想简单了解一下,可以参考百度百科词条Docker.好像只支持64位系统. Docker官网:https://www.docker.com/ Docker - 从入门 ...
- caffe 无GPU 环境搭建
root@k-Lenovo:/home/k# sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-d ...
- [转]caffe的配置过程
caffe的配置过程 转:http://blog.csdn.net/brightming/article/details/51106629 版权声明:本文为博主原创文章,欢迎转载!转载请写明原文链 ...
- 深度学习框架Caffe —— Deep learning in Practice
因工作交接需要, 要将caffe使用方法及整体结构描述清楚. 鉴于也有同学问过我相关内容, 决定在本文中写个简单的tutorial, 方便大家参考. 本文简单的讲几个事情: Caffe能做什么? 为什 ...
- Caffe —— Deep learning in Practice
因工作交接须要. 要将caffe用法及总体结构描写叙述清楚. 鉴于也有同学问过我相关内容, 决定在本文中写个简单的tutorial, 方便大家參考. 本文简单的讲几个事情: Caffe能做什么? 为什 ...
- CAFFE在win10+VS2017下的安装笔记
老版的caffe在BVLC的github上已经找不到,如果要想下载老版caffe可以下载微软的caffe版本:https://github.com/Microsoft/caffe 网上的大多安装caf ...
随机推荐
- Kubernetes 的几个重要概念
Cluster Cluster 是计算.存储和网络资源的集合,Kubernetes 利用这些资源运行各种基于容器的应用. Master Master 是 Cluster 的大脑,它的主要职责是调度,即 ...
- SQL Server: create table sql script
---摇奖observeh数据库设计 Function getSpace lottery /* -- Author:geovindu 涂聚文 -- Date: 20180427 为了自写生成代码.根据 ...
- python之递归与二分法
1. 递归 自己调用自己 递归的入口(参数) 和 出口(return) 树形结构的遍历 import os def func(lujing, n): lst = os.listdir(lujing) ...
- Kafka初入门简单配置与使用
一 Kafka概述 1.1 Kafka是什么 在流式计算中,Kafka一般用来缓存数据,Storm通过消费Kafka的数据进行计算. 1)Apache Kafka是一个开源消息系统,由Scala写成. ...
- 2014年GDG西安 -- DevFest Season1
今年9月21日,GDG西安组织了第一季以Android Wear为专题的活动,葡萄城则以超一流的办公环境和网络宣传,配合举行了本次活动.下面通过图文方式进行报道,希望未能如期参加的筒子们不要有太多的遗 ...
- linux定时任务调度定系统——opencron
linux定时任务调度定系统——opencron https://gitee.com/terrytan/opencron/#%E8%BF%90%E8%A1%8C%E7%8E%AF%E5%A2%83 一 ...
- Android 震动模式
震动类 public class VibratorUtil { private static final long DEFAULT_VIBRATOR = 100; private static Vib ...
- C# JObject和JArray 的分享
最近在调用别人的搜索引擎接口时遇到了一种返回类型为数组的情况,如 { "result": [ //根据用户输入搜索匹配到的标题数组 "我是一条新 ...
- 怎样让引用类库的类在HelpPage上显示Description
最近在做 web api 开发的时候遇到这样的问题,即 HelpPage 里只能显示 api 控制器上的注释,对于那些引用了外部类库的类(比如POST提交需要用到的类),就无法显示它们的备注, ...
- PLS-00306: 调用 'SYNCRN' 时参数个数或类型错误
System.Data.OracleClient.OracleException (0x80131938): ORA-00604: 递归 SQL 级别 1 出现错误 ORA-06550: 第 1 行, ...