# home下,基于centos的caffe-ssd镜像制作
FROM nvidia/cuda:10.0-cudnn7-devel-centos7
RUN yum update -y
# 基本开发工具
RUN yum -y groupinstall "Development Tools" && \
# 安装通用依赖项
yum -y install python-devel && \
yum -y install protobuf-devel && \
yum -y install epel-release && \
yum -y install leveldb-devel && \
yum -y install snappy-devel && \
yum -y install gcc && \
yum -y install make && \
yum -y install gcc-c++ && \
#yum -y install opencv-devel-3.4.2 && \
yum -y install boost-devel && \
yum -y install hdf5-devel && \
yum -y install atlas-devel && \
yum -y install openblas-devel && \
# 安装其他依赖
yum -y install gflags-devel && \
yum -y install glog-devel && \
yum -y install lmdb-devel && \
yum -y install wget && \
# 安装python依赖包
yum -y install python-pip && \
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip && \
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple networkx==2.2 && \
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple scikit-image==0.14.0 && \
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple protobuf==2.5.0 && \
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple numpy==1.15.1 &&\
wget https://cmake.org/files/v3.10/cmake-3.10.2.tar.gz && \
tar -zxvf cmake-3.10.2.tar.gz && \
cd cmake-3.10.2 && \
./bootstrap --prefix=/usr/local && \
gmake && make install && \
# 清除缓存包
cd .. && \
rm -r cmake-3.10.2* && \
yum clean all && \
rm -rf /var/cache/yum && \
mkdir soft
#WORKDIR /soft
COPY opencv-3.3.0 opencv-3.3
RUN cd opencv-3.3 && \
mkdir build && cd build && \
cmake -D CMAKE_BUILD_TYPE=Release -D WITH_CUDA=0 -D CMAKE_INSTALL_PREFIX=/usr/local .. && \
make -j8 && make install && \
echo "/usr/local/lib" >> /etc/ld.so.conf.d/opencv.conf && \
ldconfig && \
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig" >> ~/.bashrc && \
echo "export PKG_CONFIG_PATH" >> ~/.bashrc && \
source ~/.bashrc && \
cd ../.. && \
rm -r opencv-3.3
# 下载caffe,切换ssd分支
RUN cp /etc/hosts /etc/hosts.temp && \
sed -i 2a\199.232.5.194\ github.global.ssl.fastly.net /etc/hosts.temp && \
sed -i 3a\140.82.113.4\ github.com /etc/hosts.temp && \
cp /etc/hosts.temp /etc/hosts && \
cd /home/ && \
git clone https://github.com/weiliu89/caffe.git && \
cd caffe/ && \
git checkout ssd && \
# 修改配置文件Makefile.config
# 打开 USE_CUDNN := 1
# 打开BLAS_INCLUDE=/path/to/your/blas 并修改为 BLAS_INCLUDE:=/usr/include
# 打开BLAS_lIB=/path/to/your/blas 并修改为 BLAS_lIB:=/usr/lib64/atlas
# 更改CUDA_ARCH设置,删除前两行
# 修改numpy路径:lib为lib64,dist-packages为site-packages
mv Makefile.config.example Makefile.config && \
sed -i 's/^# USE_CUDNN := 1/USE_CUDNN := 1/' Makefile.config && \
sed -i 's%^# BLAS_INCLUDE := /path/to/your/blas%BLAS_INCLUDE := /usr/include%' Makefile.config && \
sed -i 's%^# BLAS_LIB := /path/to/your/blas%BLAS_LIB := /usr/lib64/atlas%' Makefile.config && \
sed -i 's/^CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \\//' Makefile.config && \
sed -i 's/-gencode arch=compute_20,code=sm_21 \\$//' Makefile.config && \
sed -i 's/^[ \t]*-gencode arch=compute_30,code=sm_30 \\$/CUDA_ARCH := -gencode arch=compute_30,code=sm_30 \\/' Makefile.config && \
sed -i 's%/usr/lib/python2.7/dist-packages/numpy/core/include%/usr/lib64/python2.7/site-packages/numpy/core/include%' Makefile.config && \
sed -i 's/^# OPENCV_VERSION := 3/OPENCV_VERSION := 3/' Makefile.config && \
# 修改配置文件Makefile
# LIBRARIES += cblas atlas 修改为 LIBRARIES +=satlas tatlas
sed -i 's/LIBRARIES += cblas atlas$/LIBRARIES += satlas tatlas/' Makefile && \
# 编译安装
make all -j8 && \
make test -j8 && \
# make runtest -j32 && \
make pycaffe -j8 && \
# 添加python环境变量
# vim ~/.bashrc
# 加入 export PYTHONPATH=/SSD所在目录/caffe/python
# source ~/.bashrc
# 或者如下将编译好的文件放到系统对应目录
cp -r python/caffe/ /usr/lib/python2.7/site-packages/ && \
cp /home/caffe/.build_release/lib/* /usr/lib64
基于cuda10 cudnn centos搭建caffe-ssd环境的Dockerfile
最新推荐文章于 2021-03-06 19:18:34 发布