Skip to content

Commit 72624c9

Browse files
authored
Improve docs for the TF ResNet50 example (#1472)
1 parent 134ee1d commit 72624c9

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

build/lint.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ output=$(cd "$ROOT" && find . -type f \
8282
! -name "go.*" \
8383
! -name "*.md" \
8484
! -name ".*" \
85+
! -name "*.bin" \
8586
! -name "Dockerfile" \
8687
-exec grep -L "Copyright 2020 Cortex Labs, Inc" {} \;)
8788
if [[ $output ]]; then
@@ -101,6 +102,7 @@ if [ "$is_release_branch" = "true" ]; then
101102
! -path "./bin/*" \
102103
! -path "./.git/*" \
103104
! -name ".*" \
105+
! -name "*.bin" \
104106
-exec grep -R -A 5 -e "CORTEX_VERSION" {} \;)
105107
output=$(echo "$output" | grep -e "master" || true)
106108
if [[ $output ]]; then
@@ -119,6 +121,7 @@ if [ "$is_release_branch" = "true" ]; then
119121
! -path "./bin/*" \
120122
! -path "./.git/*" \
121123
! -name ".*" \
124+
! -name "*.bin" \
122125
-exec grep -l "WARNING: you are on the master branch" {} \;)
123126
if [[ $output ]]; then
124127
echo "file(s) have the master version warning:"
@@ -132,6 +135,7 @@ if [ "$is_release_branch" = "true" ]; then
132135
! -name "*.json" \
133136
! -name "*.txt" \
134137
! -name ".*" \
138+
! -name "*.bin" \
135139
-exec grep -L -e "this is an example for cortex release ${git_branch} and may not deploy correctly on other releases of cortex" {} \;)
136140
if [[ $output ]]; then
137141
echo "examples file(s) are missing appropriate version comment:"
@@ -148,6 +152,7 @@ else
148152
! -name "*.json" \
149153
! -name "*.txt" \
150154
! -name ".*" \
155+
! -name "*.bin" \
151156
-exec grep -L "WARNING: you are on the master branch, please refer to the docs on the branch that matches your \`cortex version\`" {} \;)
152157
if [[ $output ]]; then
153158
echo "docs file(s) are missing appropriate version comment:"
@@ -162,6 +167,7 @@ else
162167
! -name "*.json" \
163168
! -name "*.txt" \
164169
! -name ".*" \
170+
! -name "*.bin" \
165171
-exec grep -L "WARNING: you are on the master branch; please refer to examples on the branch corresponding to your \`cortex version\` (e\.g\. for version [0-9]*\.[0-9]*\.\*, run \`git checkout -b [0-9]*\.[0-9]*\` or switch to the \`[0-9]*\.[0-9]*\` branch on GitHub)" {} \;)
166172
if [[ $output ]]; then
167173
echo "example file(s) are missing version appropriate comment:"
@@ -178,6 +184,7 @@ output=$(cd "$ROOT" && find . -type f \
178184
! -path "./bin/*" \
179185
! -path "./.git/*" \
180186
! -name ".*" \
187+
! -name "*.bin" \
181188
-exec egrep -l " +$" {} \;)
182189
if [[ $output ]]; then
183190
echo "File(s) have lines with trailing whitespace:"
@@ -193,6 +200,7 @@ output=$(cd "$ROOT" && find . -type f \
193200
! -path "./bin/*" \
194201
! -path "./.git/*" \
195202
! -name ".*" \
203+
! -name "*.bin" \
196204
-print0 | \
197205
xargs -0 -L1 bash -c 'test "$(tail -c 1 "$0")" && echo "No new line at end of $0"' || true)
198206
if [[ $output ]]; then
@@ -208,6 +216,7 @@ output=$(cd "$ROOT" && find . -type f \
208216
! -path "./bin/*" \
209217
! -path "./.git/*" \
210218
! -name ".*" \
219+
! -name "*.bin" \
211220
-print0 | \
212221
xargs -0 -L1 bash -c 'test "$(tail -c 2 "$0")" || echo "Multiple new lines at end of $0"' || true)
213222
if [[ $output ]]; then
@@ -223,6 +232,7 @@ output=$(cd "$ROOT" && find . -type f \
223232
! -path "./bin/*" \
224233
! -path "./.git/*" \
225234
! -name ".*" \
235+
! -name "*.bin" \
226236
-print0 | \
227237
xargs -0 -L1 bash -c 'test "$(head -c 1 "$0")" || echo "New line at beginning of $0"' || true)
228238
if [[ $output ]]; then

examples/tensorflow/image-classifier-resnet50/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ Then, deploy each API one at a time and check the results:
5555
1. Running `python ../../utils/throughput_test.py -i 30 -p 4 -t 24` with the [cortex_gpu.yaml](cortex_gpu.yaml) API running on an `g4dn.xlarge` instance will get **~125 inferences/sec** with an average latency of **85 ms**. Optimizing the model with TensorRT to use FP16 on TF-serving only seems to achieve a 10% performance improvement - one thing to consider is that the TensorRT engines hadn't been built beforehand, so this might have affected the results negatively.
5656
1. Running `python ../../utils/throughput_test.py -i 30 -p 4 -t 60` with the [cortex_gpu_server_side_batching.yaml](cortex_gpu_batch_sized.yaml) API running on an `g4dn.xlarge` instance will get **~186 inferences/sec** with an average latency of **500 ms**. This achieves a 49% higher throughput than the [cortex_gpu.yaml](cortex_gpu.yaml) API, at the expense of increased latency.
5757

58+
Alternatively to [throughput_test.py](../../utils/throughput_test.py), the `ab` GNU utility can also be used to benchmark the API. This has the advantage that it's not as taxing on your local machine, but the disadvantage that it doesn't implement a cooldown period. You can run `ab` like this:
59+
60+
```bash
61+
# for making octet-stream requests, which is the default for throughput_test script
62+
ab -n <number-of-requests> -c <concurrency-level> -p sample.bin -T 'application/octet-stream' -rks 120 $ENDPOINT
63+
64+
# for making json requests, will will have lower performance because the API has to download the image every time
65+
ab -n <number-of-requests> -c <concurrency-level> -p sample.json -T 'application/json' -rks 120 $ENDPOINT
66+
```
67+
5868
*Note: `inf1.xlarge` isn't used because the major bottleneck with `inf` instances for this example is with the CPU, and `inf1.2xlarge` has twice the amount of CPU cores for same number of Inferentia ASICs (which is 1), which translates to almost double the throughput.*
5969

6070
## Exporting SavedModels
8.48 KB
Binary file not shown.

0 commit comments

Comments
 (0)