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/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..2381966 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) @@ -61,14 +61,19 @@ 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 build -t gluoncv_segmentation_inference_api_gpu -f ./GPU/dockerfile . +docker login nvcr.io +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 . ``` @@ -77,14 +82,19 @@ docker build -t gluoncv_segmentation_inference_api_cpu -f ./CPU/dockerfile . - 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 build --build-arg http_proxy='' --build-arg https_proxy='' -t gluoncv_segmentation_inference_api_gpu -f ./GPU/dockerfile . +docker login nvcr.io +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..24293ba --- /dev/null +++ b/docker/GPU/dockerfile @@ -0,0 +1,33 @@ +FROM nvcr.io/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 + +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