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

Tutorial about serverless functions #3124

Merged
merged 70 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
3e378ff
Initial version of the tutorial
Apr 23, 2021
7fbc77a
Merge remote-tracking branch 'origin/develop' into nm/serverless_tuto…
Apr 26, 2021
400f7b0
Implemented serverless function detectron2/retinanet
Apr 26, 2021
b2f6168
Add "DL model as a serverless function" section.
Apr 27, 2021
c04bd1d
Add code and links for readability.
Apr 27, 2021
d8b8047
Merge remote-tracking branch 'origin/develop' into nm/serverless_tuto…
Apr 28, 2021
18b45f2
Merge remote-tracking branch 'origin/develop' into nm/serverless_tuto…
May 6, 2021
543bfb2
Merge remote-tracking branch 'origin/develop' into nm/serverless_tuto…
May 6, 2021
617f234
Started "introduction" section.
May 6, 2021
fad5430
Initial version of "introduction" is ready.
May 6, 2021
14b45cd
Minor changes.
May 6, 2021
5cc915d
Started tutorial for SiamMask.
May 7, 2021
d8ab99c
Initial tutorial for siammask tracker.
May 7, 2021
db371d6
Merge remote-tracking branch 'origin/develop' into nm/serverless_tuto…
Jun 23, 2021
422b75f
Moved serverless documentation into the new place (cvat/site/...)
Jun 23, 2021
3baee46
Fix remark warnings.
Jun 23, 2021
5e5f174
Added a section how to debug serverless function using Boris's
Jun 25, 2021
4276750
Merge remote-tracking branch 'origin/develop' into nm/serverless_tuto…
Jul 6, 2021
f2088b2
Added troubleshooting guide for running serverless functions.
Jul 6, 2021
47b2c6b
Added troubleshooting guide
Jul 7, 2021
b649c38
Added optimized version of retinanet for GPU.
Jul 7, 2021
a931a10
Better support of functions optimized for GPU
Jul 8, 2021
ba4eb57
Added a section with optimizing serverless functions for GPU.
Jul 8, 2021
43010ff
Fixed a couple of typos and updated the CHANGELOG.md
Jul 12, 2021
487d36e
Merge remote-tracking branch 'origin/develop' into nm/serverless_tuto…
Jul 12, 2021
d2fcdae
Add a section about YOLO v3 detecton model.
Jul 12, 2021
f021c42
Added a section about Mask RCNN.
Jul 12, 2021
02a1eb0
Optimized images.
Jul 13, 2021
49e4875
Fix a couple of typos.
Jul 13, 2021
bed0691
Update serverless/deploy_gpu.sh
Jul 14, 2021
b69d1b6
Update serverless/deploy_gpu.sh
Jul 14, 2021
9b930c7
Update serverless/deploy_gpu.sh
Jul 14, 2021
e9996b3
Update serverless/pytorch/facebookresearch/detectron2/retinanet/nucli…
Jul 14, 2021
572d637
Update serverless/pytorch/facebookresearch/detectron2/retinanet/nucli…
Jul 14, 2021
187aa2a
Fixed review comments.
Jul 14, 2021
d4734e8
Removed unnecessary code and apply comments from the review.
Jul 14, 2021
f9a0029
Fix problems with retinanet function and apply Roman's suggestion.
Jul 16, 2021
deb82bd
Update site/content/en/docs/manual/advanced/serverless-tutorial.md
Jul 16, 2021
c6e5914
Update site/content/en/docs/manual/advanced/serverless-tutorial.md
Jul 16, 2021
e43b6ac
Update site/content/en/docs/manual/advanced/serverless-tutorial.md
Jul 16, 2021
62adeca
Update site/content/en/docs/manual/advanced/serverless-tutorial.md
Jul 16, 2021
c1f3085
Update site/content/en/docs/manual/advanced/serverless-tutorial.md
Jul 16, 2021
875f75f
Update site/content/en/docs/manual/advanced/serverless-tutorial.md
Jul 16, 2021
bb4011a
Update site/content/en/docs/manual/advanced/serverless-tutorial.md
Jul 16, 2021
a977fb8
Update site/content/en/docs/manual/advanced/serverless-tutorial.md
Jul 16, 2021
6fd4f70
Update site/content/en/docs/manual/advanced/serverless-tutorial.md
Jul 16, 2021
ed527c7
Update site/content/en/docs/manual/advanced/serverless-tutorial.md
Jul 16, 2021
b6baae4
Update site/content/en/docs/manual/advanced/serverless-tutorial.md
Jul 16, 2021
935fcb4
Update site/content/en/docs/manual/advanced/serverless-tutorial.md
Jul 16, 2021
8bc12b1
Update site/content/en/docs/manual/advanced/serverless-tutorial.md
Jul 16, 2021
cba2090
Update site/content/en/docs/manual/advanced/serverless-tutorial.md
Jul 16, 2021
5ce6abd
Update site/content/en/docs/manual/advanced/serverless-tutorial.md
Jul 16, 2021
9ca1f3a
Update site/content/en/docs/manual/advanced/serverless-tutorial.md
Jul 16, 2021
e0be95e
Update site/content/en/docs/manual/advanced/serverless-tutorial.md
Jul 16, 2021
0383bb0
minor changes
Jul 16, 2021
6305b05
Merge branch 'nm/serverless_tutorial' of github.com:openvinotoolkit/c…
Jul 16, 2021
76c9b08
nuclio --> Nuclio
Jul 16, 2021
5f45aa6
sh,bash -> console
Jul 16, 2021
a871783
Update site/content/en/docs/manual/advanced/serverless-tutorial.md
Jul 16, 2021
5352e01
sync deploy_cpu.sh and deploy_gpu.sh
Jul 16, 2021
28d5266
Merge branch 'nm/serverless_tutorial' of github.com:openvinotoolkit/c…
Jul 16, 2021
2177ab4
Removed unnecessary encode operation.
Jul 16, 2021
4d39303
Update site/content/en/docs/manual/advanced/serverless-tutorial.md
Jul 16, 2021
7e8768c
Fixed comments from review.
Jul 16, 2021
3651313
Merge branch 'nm/serverless_tutorial' of github.com:openvinotoolkit/c…
Jul 16, 2021
fab1f43
Add RetinaNet into README.md
Jul 16, 2021
21037ba
Reverted changes with nuclio update.
Jul 19, 2021
0f39814
Merge remote-tracking branch 'origin/develop' into nm/serverless_tuto…
Jul 19, 2021
d8c665b
Merge remote-tracking branch 'origin/develop' into nm/serverless_tuto…
Jul 20, 2021
7bd2403
Fix several pylint warnings
Jul 21, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Support of cloud storage without copying data into CVAT: server part (<https://github.com/openvinotoolkit/cvat/pull/2620>)
- Filter `is_active` for user list (<https://github.com/openvinotoolkit/cvat/pull/3235>)
- Ability to export/import tasks (<https://github.com/openvinotoolkit/cvat/pull/3056>)
- Add a tutorial for semi-automatic/automatic annotation (<https://github.com/openvinotoolkit/cvat/pull/3124>)

### Changed

Expand Down
25 changes: 10 additions & 15 deletions serverless/deploy_gpu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,19 @@
# Sample commands to deploy nuclio functions on GPU

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
FUNCTIONS_DIR=${1:-$SCRIPT_DIR}

nuctl create project cvat

nuctl deploy --project-name cvat \
--path "$SCRIPT_DIR/tensorflow/faster_rcnn_inception_v2_coco/nuclio" \
--platform local --base-image tensorflow/tensorflow:2.1.1-gpu \
--desc "GPU based Faster RCNN from Tensorflow Object Detection API" \
--image cvat/tf.faster_rcnn_inception_v2_coco_gpu \
--triggers '{"myHttpTrigger": {"maxWorkers": 1}}' \
--resource-limit nvidia.com/gpu=1 --verbose

nuctl deploy --project-name cvat \
--path "$SCRIPT_DIR/tensorflow/matterport/mask_rcnn/nuclio" \
--platform local --base-image tensorflow/tensorflow:1.15.5-gpu-py3 \
--desc "GPU based implementation of Mask RCNN on Python 3, Keras, and TensorFlow." \
--image cvat/tf.matterport.mask_rcnn_gpu\
--triggers '{"myHttpTrigger": {"maxWorkers": 1}}' \
--resource-limit nvidia.com/gpu=1 --verbose
shopt -s globstar

for func_config in "$FUNCTIONS_DIR"/**/function-gpu.yaml
do
func_root=$(dirname "$func_config")
echo "Deploying $(dirname "$func_root") function..."
nuctl deploy --project-name cvat --path "$func_root" \
--volume "$SCRIPT_DIR/common:/opt/nuclio/common" \
--file "$func_config" --platform local
done

nuctl get function
2 changes: 1 addition & 1 deletion serverless/openvino/dextr/nuclio/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def init_context(context):
context.logger.info("Init context... 0%")

model = ModelHandler()
setattr(context.user_data, 'model', model)
context.user_data.model = model

context.logger.info("Init context...100%")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def init_context(context):
context.logger.info("Init context... 0%")

model = ModelHandler()
setattr(context.user_data, 'model', model)
context.user_data.model = model

context.logger.info("Init context...100%")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ def init_context(context):
context.logger.info("Init context... 0%")

# Read labels
functionconfig = yaml.safe_load(open("/opt/nuclio/function.yaml"))
with open("/opt/nuclio/function.yaml", 'rb') as function_file:
functionconfig = yaml.safe_load(function_file)

labels_spec = functionconfig['metadata']['annotations']['spec']
labels = {item['id']: item['name'] for item in json.loads(labels_spec)}

# Read the DL model
model = ModelHandler(labels)
setattr(context.user_data, 'model', model)
context.user_data.model = model

context.logger.info("Init context...100%")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ def init_context(context):
context.logger.info("Init context... 0%")

# Read labels
functionconfig = yaml.safe_load(open("/opt/nuclio/function.yaml"))
with open("/opt/nuclio/function.yaml", 'rb') as function_file:
functionconfig = yaml.safe_load(function_file)
labels_spec = functionconfig['metadata']['annotations']['spec']
labels = {item['id']: item['name'] for item in json.loads(labels_spec)}

# Read the DL model
model = ModelHandler(labels)
setattr(context.user_data, 'model', model)
context.user_data.model = model

context.logger.info("Init context...100%")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ def init_context(context):
context.logger.info("Init context... 0%")

# Read labels
functionconfig = yaml.safe_load(open("/opt/nuclio/function.yaml"))
with open("/opt/nuclio/function.yaml", 'rb') as function_file:
functionconfig = yaml.safe_load(function_file)

labels_spec = functionconfig['metadata']['annotations']['spec']
labels = {item['id']: item['name'] for item in json.loads(labels_spec)}

# Read the DL model
model = ModelHandler(labels)
setattr(context.user_data, 'model', model)
context.user_data.model = model

context.logger.info("Init context...100%")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ def init_context(context):
context.logger.info("Init context... 0%")

# Read labels
functionconfig = yaml.safe_load(open("/opt/nuclio/function.yaml"))
with open("/opt/nuclio/function.yaml", 'rb') as function_file:
functionconfig = yaml.safe_load(function_file)

labels_spec = functionconfig['metadata']['annotations']['spec']
labels = {item['id']: item['name'] for item in json.loads(labels_spec)}

# Read the DL model
model = ModelHandler(labels)
setattr(context.user_data, 'model', model)
context.user_data.model = model

context.logger.info("Init context...100%")

Expand Down
6 changes: 4 additions & 2 deletions serverless/openvino/omz/public/yolo-v3-tf/nuclio/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ def init_context(context):
context.logger.info("Init context... 0%")

# Read labels
functionconfig = yaml.safe_load(open("/opt/nuclio/function.yaml"))
with open("/opt/nuclio/function.yaml", 'rb') as function_file:
functionconfig = yaml.safe_load(function_file)

labels_spec = functionconfig['metadata']['annotations']['spec']
labels = {item['id']: item['name'] for item in json.loads(labels_spec)}

# Read the DL model
model = ModelHandler(labels)
setattr(context.user_data, 'model', model)
context.user_data.model = model

context.logger.info("Init context...100%")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
metadata:
name: pth.facebookresearch.detectron2.retinanet_r101
namespace: cvat
annotations:
name: RetinaNet R101
type: detector
framework: pytorch
spec: |
[
{ "id": 1, "name": "person" },
{ "id": 2, "name": "bicycle" },
{ "id": 3, "name": "car" },
{ "id": 4, "name": "motorcycle" },
{ "id": 5, "name": "airplane" },
{ "id": 6, "name": "bus" },
{ "id": 7, "name": "train" },
{ "id": 8, "name": "truck" },
{ "id": 9, "name": "boat" },
{ "id":10, "name": "traffic_light" },
{ "id":11, "name": "fire_hydrant" },
{ "id":13, "name": "stop_sign" },
{ "id":14, "name": "parking_meter" },
{ "id":15, "name": "bench" },
{ "id":16, "name": "bird" },
{ "id":17, "name": "cat" },
{ "id":18, "name": "dog" },
{ "id":19, "name": "horse" },
{ "id":20, "name": "sheep" },
{ "id":21, "name": "cow" },
{ "id":22, "name": "elephant" },
{ "id":23, "name": "bear" },
{ "id":24, "name": "zebra" },
{ "id":25, "name": "giraffe" },
{ "id":27, "name": "backpack" },
{ "id":28, "name": "umbrella" },
{ "id":31, "name": "handbag" },
{ "id":32, "name": "tie" },
{ "id":33, "name": "suitcase" },
{ "id":34, "name": "frisbee" },
{ "id":35, "name": "skis" },
{ "id":36, "name": "snowboard" },
{ "id":37, "name": "sports_ball" },
{ "id":38, "name": "kite" },
{ "id":39, "name": "baseball_bat" },
{ "id":40, "name": "baseball_glove" },
{ "id":41, "name": "skateboard" },
{ "id":42, "name": "surfboard" },
{ "id":43, "name": "tennis_racket" },
{ "id":44, "name": "bottle" },
{ "id":46, "name": "wine_glass" },
{ "id":47, "name": "cup" },
{ "id":48, "name": "fork" },
{ "id":49, "name": "knife" },
{ "id":50, "name": "spoon" },
{ "id":51, "name": "bowl" },
{ "id":52, "name": "banana" },
{ "id":53, "name": "apple" },
{ "id":54, "name": "sandwich" },
{ "id":55, "name": "orange" },
{ "id":56, "name": "broccoli" },
{ "id":57, "name": "carrot" },
{ "id":58, "name": "hot_dog" },
{ "id":59, "name": "pizza" },
{ "id":60, "name": "donut" },
{ "id":61, "name": "cake" },
{ "id":62, "name": "chair" },
{ "id":63, "name": "couch" },
{ "id":64, "name": "potted_plant" },
{ "id":65, "name": "bed" },
{ "id":67, "name": "dining_table" },
{ "id":70, "name": "toilet" },
{ "id":72, "name": "tv" },
{ "id":73, "name": "laptop" },
{ "id":74, "name": "mouse" },
{ "id":75, "name": "remote" },
{ "id":76, "name": "keyboard" },
{ "id":77, "name": "cell_phone" },
{ "id":78, "name": "microwave" },
{ "id":79, "name": "oven" },
{ "id":80, "name": "toaster" },
{ "id":81, "name": "sink" },
{ "id":83, "name": "refrigerator" },
{ "id":84, "name": "book" },
{ "id":85, "name": "clock" },
{ "id":86, "name": "vase" },
{ "id":87, "name": "scissors" },
{ "id":88, "name": "teddy_bear" },
{ "id":89, "name": "hair_drier" },
{ "id":90, "name": "toothbrush" }
]

spec:
description: RetinaNet R101 from Detectron2 optimized for GPU
runtime: 'python:3.8'
handler: main:handler
eventTimeout: 30s

build:
image: cvat/pth.facebookresearch.detectron2.retinanet_r101
baseImage: ubuntu:20.04

directives:
preCopy:
- kind: ENV
value: DEBIAN_FRONTEND=noninteractive
- kind: RUN
value: apt-get update && apt-get -y install curl git python3 python3-pip
- kind: WORKDIR
value: /opt/nuclio
- kind: RUN
value: pip3 install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html
- kind: RUN
value: git clone --branch v0.4 https://github.com/facebookresearch/detectron2
- kind: RUN
value: pip3 install -e detectron2
- kind: RUN
value: curl -O https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/retinanet_R_101_FPN_3x/190397697/model_final_971ab9.pkl
- kind: RUN
value: ln -s /usr/bin/pip3 /usr/local/bin/pip

triggers:
myHttpTrigger:
maxWorkers: 1
kind: 'http'
workerAvailabilityTimeoutMilliseconds: 10000
attributes:
maxRequestBodySize: 33554432 # 32MB

resources:
limits:
nvidia.com/gpu: 1

platform:
attributes:
restartPolicy:
name: always
maximumRetryCount: 3
mountMode: volume
Loading