Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #3

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions GPU/dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

FROM nvidia/cuda:10.2-cudnn7-runtime-ubuntu18.04


Expand All @@ -16,13 +17,13 @@ COPY src/main /main

# Fix Nvidia/Cuda repository key rotation
RUN sed -i '/developer\.download\.nvidia\.com\/compute\/cuda\/repos/d' /etc/apt/sources.list.d/*
RUN sed -i '/developer\.download\.nvidia\.com\/compute\/machine-learning\/repos/d' /etc/apt/sources.list.d/*
RUN sed -i '/developer\.download\.nvidia\.com\/compute\/machine-learning\/repos/d' /etc/apt/sources.list.d/*
RUN apt-key del 7fa2af80 &&\
apt-get update && \
apt-get install -y wget && \
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-keyring_1.0-1_all.deb && \
dpkg -i cuda-keyring_1.0-1_all.deb

RUN apt-get update && apt-get upgrade -y && apt-get install -y \
locales \
software-properties-common \
Expand All @@ -31,7 +32,7 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y \
cuda-cufft-10-2 \
cuda-curand-10-2 \
cuda-cusolver-10-2 \
cuda-cusparse-10-2
cuda-cusparse-10-2
RUN apt-get -y install python-opencv
RUN pip3 install --upgrade pip

Expand All @@ -49,9 +50,9 @@ 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
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"]

CMD ["uvicorn", "start:app", "--host", "0.0.0.0", "--port", "4343"]
5 changes: 0 additions & 5 deletions GPU/requirements.txt

This file was deleted.

20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 .
```


Expand All @@ -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 .
```


Expand Down
23 changes: 11 additions & 12 deletions CPU/dockerfile → docker/CPU/dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7
FROM python:3.8


RUN apt-get update && apt-get install --fix-missing -y \
Expand All @@ -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

Expand Down
8 changes: 8 additions & 0 deletions docker/CPU/requirements.txt
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions docker/GPU/dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
9 changes: 9 additions & 0 deletions docker/GPU/requirements.txt
Original file line number Diff line number Diff line change
@@ -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