docker打包darknet使用yolov4)

dockerfile编写

FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu16.04
LABEL maintainer "NVIDIA CORPORATION <cudatools@nvidia.com>"
ADD sources.list /etc/apt/
ADD default /etc/nginx/sites-available
ADD Shanghai /etc/
ADD requirements.txt /tmp/requirements.txt
ADD get-pip.py /tmp/get-pip.py
RUN apt-get update
RUN  apt-get install -y nginx
RUN  apt-get install -y libglib2.0-0
RUN  apt-get install -y libsm6
RUN  apt-get install -y libxrender1
RUN  apt-get install -y libxext-dev
RUN  apt-get install -y scrot
RUN  apt-get install -y python3
RUN apt-get install -y wget vim
RUN python3 /tmp/get-pip.py -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
RUN pip3 install --default-timeout=10000  -i https://mirrors.cloud.tencent.com/pypi/simple/  -r /tmp/requirements.txt
RUN  apt-get update
ADD darknet /opt/darknet
RUN cp /usr/include/cudnn.h /usr/local/cuda/include
RUN cp /usr/lib/x86_64-linux-gnu/libcudnn* /usr/local/cuda/lib64
RUN chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
WORKDIR /opt
RUN cd darknet \
&& make
WORKDIR /opt/darknet/
CMD nohup sh -c '/usr/sbin/nginx && python3 darknet.py'

说明

下载darknet网址为https://github.com/AlexeyAB/darknet
我采用的make安装,修改文件夹中的Makefilye,按自己的需求选取,readme中也有介绍。
其实主要是拉取的官方镜像中cudnn位置与物理机中不一致造成编译darknet失败,上述dockerfile中已经修改了cudnn.h及libcudnn*的相关位置,即可使用了,上面的get-pip.py我是离线下载的,如果在线的话,将上述的ADD get-pip.py /tmp/get-pip.py改成RUN wget -O /tmp/get-pip.py https://bootstrap.pypa.io/get-pip.py即可
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐