From ecb7909f054c4a83ec4a56aeae44274d946708cc Mon Sep 17 00:00:00 2001 From: mhwahdab Date: Wed, 22 Jun 2022 03:12:36 +0200 Subject: [PATCH 1/3] Added cpu docker support --- Dockerfile.cpu | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Dockerfile.cpu diff --git a/Dockerfile.cpu b/Dockerfile.cpu new file mode 100644 index 00000000000..852f7677fca --- /dev/null +++ b/Dockerfile.cpu @@ -0,0 +1,45 @@ +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 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/ + +USER yolo + + From d9c9a204eda707682a89bcc3744c2084f43d6993 Mon Sep 17 00:00:00 2001 From: mhwahdab Date: Wed, 22 Jun 2022 20:59:43 +0200 Subject: [PATCH 2/3] add gpu docker support + docker compose for ease of use --- Dockerfile.cpu | 3 +-- Dockerfile.gpu | 45 +++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 20 ++++++++++++++++++++ 3 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 Dockerfile.gpu create mode 100644 docker-compose.yml diff --git a/Dockerfile.cpu b/Dockerfile.cpu index 852f7677fca..b22827a3367 100644 --- a/Dockerfile.cpu +++ b/Dockerfile.cpu @@ -10,7 +10,6 @@ COPY . /darknet WORKDIR /darknet -RUN rm Dockerfile.cpu RUN make @@ -38,7 +37,7 @@ RUN cp /home/yolo/darknet/include/darknet.h /usr/local/include/darknet.h RUN ldconfig -WORKDIR /home/yolo/ +WORKDIR /home/yolo/darknet USER yolo diff --git a/Dockerfile.gpu b/Dockerfile.gpu new file mode 100644 index 00000000000..a0199da5f7c --- /dev/null +++ b/Dockerfile.gpu @@ -0,0 +1,45 @@ +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 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 00000000000..968fbccaaf9 --- /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 From 3f6ad44a8c6bbf9534bdd842132e924accef14a8 Mon Sep 17 00:00:00 2001 From: mhwahdab Date: Thu, 23 Jun 2022 14:37:14 +0200 Subject: [PATCH 3/3] Minor enhcancment --- Dockerfile.cpu | 5 +++++ Dockerfile.gpu | 2 ++ 2 files changed, 7 insertions(+) diff --git a/Dockerfile.cpu b/Dockerfile.cpu index b22827a3367..7a15cfb499e 100644 --- a/Dockerfile.cpu +++ b/Dockerfile.cpu @@ -10,6 +10,11 @@ COPY . /darknet WORKDIR /darknet +RUN rm Dockerfile.cpu + +RUN rm Dockerfile.gpu + +RUN rm Docker-compose.yml RUN make diff --git a/Dockerfile.gpu b/Dockerfile.gpu index a0199da5f7c..c4a9effbbcc 100644 --- a/Dockerfile.gpu +++ b/Dockerfile.gpu @@ -14,6 +14,8 @@ 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