From ea4f126cea650507713de8483f1547f14dcf0c0d Mon Sep 17 00:00:00 2001 From: mhwahdan <61120913+mhwahdan@users.noreply.github.com> Date: Sat, 26 Aug 2023 02:49:28 +0300 Subject: [PATCH] Added docker support + 1 command installation using docker-compose (#8578) * Added cpu docker support * add gpu docker support + docker compose for ease of use --- Dockerfile.cpu | 49 ++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile.gpu | 47 ++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 20 +++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 Dockerfile.cpu create mode 100644 Dockerfile.gpu create mode 100644 docker-compose.yml diff --git a/Dockerfile.cpu b/Dockerfile.cpu new file mode 100644 index 00000000..7a15cfb4 --- /dev/null +++ b/Dockerfile.cpu @@ -0,0 +1,49 @@ +FROM ubuntu:latest AS builder + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get update -y + +RUN apt-get install -y g++ make pkg-config libopencv-dev + +COPY . /darknet + +WORKDIR /darknet + +RUN rm Dockerfile.cpu + +RUN rm Dockerfile.gpu + +RUN rm Docker-compose.yml + +RUN make + +FROM ubuntu:latest + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get update -y + +RUN apt-get install -y sudo libgomp1 + +RUN useradd -U -m yolo + +RUN usermod -aG sudo yolo + +RUN usermod --shell /bin/bash yolo + +RUN echo "yolo:yolo" | chpasswd + +COPY --from=builder /darknet /home/yolo/darknet + +RUN cp /home/yolo/darknet/libdarknet.so /usr/local/lib/libdarknet.so || echo "libso not used" + +RUN cp /home/yolo/darknet/include/darknet.h /usr/local/include/darknet.h + +RUN ldconfig + +WORKDIR /home/yolo/darknet + +USER yolo + + diff --git a/Dockerfile.gpu b/Dockerfile.gpu new file mode 100644 index 00000000..c4a9effb --- /dev/null +++ b/Dockerfile.gpu @@ -0,0 +1,47 @@ +FROM nvidia/cuda:11.6.0-cudnn8-devel-ubuntu20.04 AS builder + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get update -y + +RUN apt-get install -y g++ make pkg-config libopencv-dev + +COPY . /darknet + +WORKDIR /darknet + +RUN rm Dockerfile.cpu + +RUN rm Dockerfile.gpu + +RUN rm Docker-compose.yml + +RUN make + +FROM nvidia/cuda:11.6.0-cudnn8-devel-ubuntu20.04 + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get update -y + +RUN apt-get install -y sudo libgomp1 + +RUN useradd -U -m yolo + +RUN usermod -aG sudo yolo + +RUN usermod --shell /bin/bash yolo + +RUN echo "yolo:yolo" | chpasswd + +COPY --from=builder /darknet /home/yolo/darknet + +RUN cp /home/yolo/darknet/libdarknet.so /usr/local/lib/libdarknet.so || echo "libso not used" + +RUN cp /home/yolo/darknet/include/darknet.h /usr/local/include/darknet.h + +RUN ldconfig + +WORKDIR /home/yolo/darknet + +USER yolo \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..968fbcca --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ +version: '2' + +services: + yolo-gpu: + build: + context: . + dockerfile: Dockerfile.gpu + image: yolo:gpu + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] + yolo-cpu: + build: + context: . + dockerfile: Dockerfile.cpu + image: yolo:cpu \ No newline at end of file