From 0fe5a4ab2e6d12840fdb434d8603c07dfa247c40 Mon Sep 17 00:00:00 2001 From: hadikoub <123.hadikoubeissy@gmail.com> Date: Wed, 9 Feb 2022 19:41:37 +0100 Subject: [PATCH 1/4] Add support for Cuda 11 --- GPU/dockerfile | 48 ---------------------------------- GPU/requirements.txt | 5 ---- README.md | 8 +++--- {CPU => docker/CPU}/dockerfile | 23 ++++++++-------- docker/CPU/requirements.txt | 8 ++++++ docker/GPU/dockerfile | 34 ++++++++++++++++++++++++ docker/GPU/requirements.txt | 9 +++++++ 7 files changed, 66 insertions(+), 69 deletions(-) delete mode 100644 GPU/dockerfile delete mode 100644 GPU/requirements.txt rename {CPU => docker/CPU}/dockerfile (73%) create mode 100644 docker/CPU/requirements.txt create mode 100644 docker/GPU/dockerfile create mode 100644 docker/GPU/requirements.txt diff --git a/GPU/dockerfile b/GPU/dockerfile deleted file mode 100644 index 6ab5be8..0000000 --- a/GPU/dockerfile +++ /dev/null @@ -1,48 +0,0 @@ -FROM nvidia/cuda:10.2-cudnn7-runtime-ubuntu18.04 - - -ENV CUDA_PKG_VERSION=10-2=10.2.130-1 -ENV CUDA_VERSION=10.2.130 -ENV PATH=/usr/local/nvidia/bin:/usr/local/cuda-10.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin -ENV LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64 -ENV NVIDIA_VISIBLE_DEVICES=all -ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility -ENV NVIDIA_REQUIRE_CUDA=cuda>=10.2 brand=tesla,driver>=384,driver<385 brand=tesla,driver>=410,driver<411 -ENV NCCL_VERSION=2.4.8 -ENV CUDNN_VERSION=7.6.5.32 - -COPY src/main /main - -RUN apt-get update && apt-get upgrade -y && apt-get install -y \ - locales \ - software-properties-common \ - python3-pip python3-dev \ - cuda-command-line-tools-10-2 \ - cuda-cufft-10-2 \ - cuda-curand-10-2 \ - cuda-cusolver-10-2 \ - cuda-cusparse-10-2 -ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get -y install python-opencv -RUN pip3 install --upgrade pip - - -RUN pip3 install Pillow \ - pytest \ - # fastapi dependencies - fastapi[all] \ - # project dependencies - numpy \ - gluoncv \ - opencv-python -RUN pip3 install jsonschema -RUN pip3 install mxnet-cu102mkl -RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \ - dpkg-reconfigure --frontend=noninteractive locales && \ - update-locale LANG=en_US.UTF-8 -ENV LANG en_US.UTF-8 -COPY /gluoncv /usr/local/lib/python3.6/dist-packages/gluoncv - -WORKDIR /main - -CMD ["uvicorn", "start:app", "--host", "0.0.0.0", "--port", "4343"] diff --git a/GPU/requirements.txt b/GPU/requirements.txt deleted file mode 100644 index 7c29bb4..0000000 --- a/GPU/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -# all needed libraries with version -fastapi==0.39.0 -uvicorn==0.9.0 -jsonschema==3.2.0 - diff --git a/README.md b/README.md index fd146e5..7c28a24 100755 --- a/README.md +++ b/README.md @@ -62,13 +62,13 @@ To build the docker environment, run the following command in the project's dire - For GPU Build: ```sh -docker build -t gluoncv_segmentation_inference_api_gpu -f ./GPU/dockerfile . +docker build -t gluoncv_segmentation_inference_api_gpu -f ./docker/GPU/dockerfile . ``` - For CPU Build: ``` -docker build -t gluoncv_segmentation_inference_api_cpu -f ./CPU/dockerfile . +docker build -t gluoncv_segmentation_inference_api_cpu -f ./docker/CPU/dockerfile . ``` @@ -78,13 +78,13 @@ docker build -t gluoncv_segmentation_inference_api_cpu -f ./CPU/dockerfile . - For GPU Build: ```sh -docker build --build-arg http_proxy='' --build-arg https_proxy='' -t gluoncv_segmentation_inference_api_gpu -f ./GPU/dockerfile . +docker build --build-arg http_proxy='' --build-arg https_proxy='' -t gluoncv_segmentation_inference_api_gpu -f ./docker/GPU/dockerfile . ``` - For CPU Build: ```sh -docker build --build-arg http_proxy='' --build-arg https_proxy='' -t gluoncv_segmentation_inference_api_cpu -f ./CPU/dockerfile . +docker build --build-arg http_proxy='' --build-arg https_proxy='' -t gluoncv_segmentation_inference_api_cpu -f ./docker/CPU/dockerfile . ``` diff --git a/CPU/dockerfile b/docker/CPU/dockerfile similarity index 73% rename from CPU/dockerfile rename to docker/CPU/dockerfile index 356c743..b465c65 100644 --- a/CPU/dockerfile +++ b/docker/CPU/dockerfile @@ -1,4 +1,4 @@ -FROM python:3.7 +FROM python:3.8 RUN apt-get update && apt-get install --fix-missing -y \ @@ -12,24 +12,23 @@ RUN apt-get update && apt-get install --fix-missing -y \ libopencv-dev \ graphviz \ libssl-dev -RUN pip install --upgrade pip + + + RUN wget https://github.com/Kitware/CMake/releases/download/v3.16.5/cmake-3.16.5.tar.gz && tar -zxvf cmake-3.16.5.tar.gz && cd cmake-3.16.5 && ./bootstrap && make && make install RUN git clone --recursive https://github.com/apache/incubator-mxnet.git -b v1.7.x RUN cd incubator-mxnet && mkdir build && cd build && cmake -DUSE_CUDA=OFF -DUSE_MKL_IF_AVAILABLE=ON -DUSE_MKLDNN=ON -DUSE_OPENMP=ON -DUSE_OPENCV=ON .. && make -j $(nproc) && cd ../python && python setup.py install -RUN pip install Pillow \ - pytest \ - # fastapi dependencies - fastapi[all] \ - # project dependencies - numpy \ - gluoncv \ - opencv-python -RUN pip install jsonschema +# copy package requirements +COPY docker/CPU/requirements.txt . +# install packages +RUN pip3 install --upgrade pip +RUN pip3 install -r requirements.txt + +COPY /gluoncv /usr/local/lib/python3.8/site-packages/gluoncv/ -COPY /gluoncv /usr/local/lib/python3.6/site-packages/gluoncv/ WORKDIR /main diff --git a/docker/CPU/requirements.txt b/docker/CPU/requirements.txt new file mode 100644 index 0000000..93ba6fe --- /dev/null +++ b/docker/CPU/requirements.txt @@ -0,0 +1,8 @@ +# all needed libraries with version +fastapi[all]==0.73.0 +jsonschema==4.0.0 +Pillow==8.4.0 +pytest==7.0.0 +numpy==1.22.2 +opencv-python==4.5.5.62 +gluoncv==0.10.4.post4 \ No newline at end of file diff --git a/docker/GPU/dockerfile b/docker/GPU/dockerfile new file mode 100644 index 0000000..81559c3 --- /dev/null +++ b/docker/GPU/dockerfile @@ -0,0 +1,34 @@ +FROM nvidia/cuda:11.2.1-cudnn8-runtime-ubuntu18.04 + +LABEL maintainer "BMW InnovationLab" +ARG DEBIAN_FRONTEND=noninteractive + + +COPY src/main /main + +RUN apt-get update && apt-get upgrade -y && apt-get install -y \ + locales \ + software-properties-common \ + python3-pip \ + python3-dev \ + pkg-config \ + ffmpeg + +# copy package requirements +COPY docker/GPU/requirements.txt . + +# install packages +RUN pip3 install --upgrade pip +RUN pip3 install -r requirements.txt + +# configure uvicorn +RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \ + dpkg-reconfigure --frontend=noninteractive locales && \ + update-locale LANG=en_US.UTF-8 + +ENV LANG en_US.UTF-8 +COPY /gluoncv /usr/local/lib/python3.6/dist-packages/gluoncv + +WORKDIR /main + +CMD ["uvicorn", "start:app", "--host", "0.0.0.0", "--port", "4343"] diff --git a/docker/GPU/requirements.txt b/docker/GPU/requirements.txt new file mode 100644 index 0000000..9052f94 --- /dev/null +++ b/docker/GPU/requirements.txt @@ -0,0 +1,9 @@ +# all needed libraries with version +fastapi[all]==0.73.0 +jsonschema==4.0.0 +Pillow==8.4.0 +pytest==7.0.0 +numpy==1.19.5 +opencv-python==4.5.5.62 +gluoncv==0.10.4.post4 +mxnet-cu112==1.9.0 \ No newline at end of file From e1f2bd862abf2bfdcd298395e33d2563a8d9b324 Mon Sep 17 00:00:00 2001 From: Hadi Koubeissy <31547256+hadikoub@users.noreply.github.com> Date: Wed, 9 Feb 2022 20:47:34 +0200 Subject: [PATCH 2/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7c28a24..f57ab9d 100755 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ This repository can be deployed using **docker**. - Ubuntu 18.04 or 20.04 LTS - Windows 10 pro with **hyper-v** enabled and **docker** desktop -- NVIDIA Drivers (410.x or higher) +- NVIDIA Drivers (418.x or higher) - Docker CE latest stable release - NVIDIA Docker 2 - Git lfs (large file storage) : [installation](https://github.com/git-lfs/git-lfs/wiki/Installation) From 40a2bbe3acf860bb1b3b759054471f1f1d8c2ef1 Mon Sep 17 00:00:00 2001 From: joumaaAli Date: Tue, 29 Oct 2024 09:46:01 +0100 Subject: [PATCH 3/4] (Fix): adjusted docker image and removed the hard copy of the gluoncv library to the docker container --- .idea/.gitignore | 8 ++++++++ docker/GPU/dockerfile | 5 ++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 .idea/.gitignore diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/docker/GPU/dockerfile b/docker/GPU/dockerfile index 81559c3..24293ba 100644 --- a/docker/GPU/dockerfile +++ b/docker/GPU/dockerfile @@ -1,4 +1,4 @@ -FROM nvidia/cuda:11.2.1-cudnn8-runtime-ubuntu18.04 +FROM nvcr.io/nvidia/cuda:11.2.1-cudnn8-runtime-ubuntu18.04 LABEL maintainer "BMW InnovationLab" ARG DEBIAN_FRONTEND=noninteractive @@ -26,8 +26,7 @@ RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \ dpkg-reconfigure --frontend=noninteractive locales && \ update-locale LANG=en_US.UTF-8 -ENV LANG en_US.UTF-8 -COPY /gluoncv /usr/local/lib/python3.6/dist-packages/gluoncv +ENV LANG en_US.UTF-8 WORKDIR /main From aa68a5c9829a04c09394ddadd6de6da9629cd2a0 Mon Sep 17 00:00:00 2001 From: joumaaAli Date: Fri, 15 Nov 2024 15:48:29 +0100 Subject: [PATCH 4/4] added documentation for docker login nvcr --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index f57ab9d..2381966 100755 --- a/README.md +++ b/README.md @@ -61,7 +61,12 @@ To build the docker environment, run the following command in the project's dire - For GPU Build: +> **_NOTE:_** Follow this link to acquire nvcr private key: +> https://docs.nvidia.com/launchpad/ai/base-command-coe/latest/bc-coe-docker-basics-step-02.html + + ```sh +docker login nvcr.io docker build -t gluoncv_segmentation_inference_api_gpu -f ./docker/GPU/dockerfile . ``` @@ -77,7 +82,12 @@ docker build -t gluoncv_segmentation_inference_api_cpu -f ./docker/CPU/dockerfil - For GPU Build: +> **_NOTE:_** Follow this link to acquire nvcr private key: +> https://docs.nvidia.com/launchpad/ai/base-command-coe/latest/bc-coe-docker-basics-step-02.html + + ```sh +docker login nvcr.io docker build --build-arg http_proxy='' --build-arg https_proxy='' -t gluoncv_segmentation_inference_api_gpu -f ./docker/GPU/dockerfile . ```