Skip to content

Commit bb1e7d1

Browse files
authored
Replace default predictor images with the slim versions (#1884)
1 parent 6613e62 commit bb1e7d1

File tree

39 files changed

+143
-408
lines changed

39 files changed

+143
-408
lines changed

CONTRIBUTING.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -177,23 +177,23 @@ instance_type: m5.large
177177
min_instances: 1
178178
max_instances: 5
179179

180-
image_operator: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/operator:latest
181-
image_manager: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/manager:latest
182-
image_downloader: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/downloader:latest
183-
image_request_monitor: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/request-monitor:latest
184-
image_cluster_autoscaler: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/cluster-autoscaler:latest
185-
image_metrics_server: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/metrics-server:latest
186-
image_inferentia: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/inferentia:latest
187-
image_neuron_rtd: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/neuron-rtd:latest
188-
image_nvidia: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/nvidia:latest
189-
image_fluent_bit: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/fluent-bit:latest
190-
image_istio_proxy: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/istio-proxy:latest
191-
image_istio_pilot: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/istio-pilot:latest
192-
image_prometheus: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/prometheus:latest
193-
image_prometheus_config_reloader: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/prometheus-config-reloader:latest
194-
image_prometheus_operator: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/prometheus-operator:latest
195-
image_prometheus_statsd_exporter: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/prometheus-statsd-exporter:latest
196-
image_grafana: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/grafana:latest
180+
image_operator: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/operator:master
181+
image_manager: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/manager:master
182+
image_downloader: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/downloader:master
183+
image_request_monitor: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/request-monitor:master
184+
image_cluster_autoscaler: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/cluster-autoscaler:master
185+
image_metrics_server: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/metrics-server:master
186+
image_inferentia: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/inferentia:master
187+
image_neuron_rtd: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/neuron-rtd:master
188+
image_nvidia: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/nvidia:master
189+
image_fluent_bit: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/fluent-bit:master
190+
image_istio_proxy: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/istio-proxy:master
191+
image_istio_pilot: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/istio-pilot:master
192+
image_prometheus: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/prometheus:master
193+
image_prometheus_config_reloader: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/prometheus-config-reloader:master
194+
image_prometheus_operator: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/prometheus-operator:master
195+
image_prometheus_statsd_exporter: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/prometheus-statsd-exporter:master
196+
image_grafana: <account_id>.dkr.ecr.<region>.amazonaws.com/cortexlabs/grafana:master
197197
```
198198
199199
Create `dev/config/cluster-gcp.yaml`. Paste the following config, and update `project`, `zone`, and all registry URLs (replace `<project_id>` with your project ID, and update `gcr.io` if you are using a different host):
@@ -210,18 +210,18 @@ min_instances: 1
210210
max_instances: 5
211211
# accelerator_type: nvidia-tesla-k80 # optional
212212
213-
image_operator: /cortexlabs/operator:latest
214-
image_manager: gcr.io/<project_id>/cortexlabs/manager:latest
215-
image_downloader: gcr.io/<project_id>/cortexlabs/downloader:latest
216-
image_request_monitor: gcr.io/<project_id>/cortexlabs/request-monitor:latest
217-
image_istio_proxy: gcr.io/<project_id>/cortexlabs/istio-proxy:latest
218-
image_istio_pilot: gcr.io/<project_id>/cortexlabs/istio-pilot:latest
219-
image_google_pause: gcr.io/<project_id>/cortexlabs/google-pause:latest
220-
image_prometheus: gcr.io/<project_id>/cortexlabs/prometheus:latest
221-
image_prometheus_config_reloader: gcr.io/<project_id>/cortexlabs/prometheus-config-reloader:latest
222-
image_prometheus_operator: gcr.io/<project_id>/cortexlabs/prometheus-operator:latest
223-
image_prometheus_statsd_exporter: gcr.io/<project_id>/cortexlabs/prometheus-statsd-exporter:latest
224-
image_grafana: gcr.io/<project_id>/cortexlabs/grafana:latest
213+
image_operator: /cortexlabs/operator:master
214+
image_manager: gcr.io/<project_id>/cortexlabs/manager:master
215+
image_downloader: gcr.io/<project_id>/cortexlabs/downloader:master
216+
image_request_monitor: gcr.io/<project_id>/cortexlabs/request-monitor:master
217+
image_istio_proxy: gcr.io/<project_id>/cortexlabs/istio-proxy:master
218+
image_istio_pilot: gcr.io/<project_id>/cortexlabs/istio-pilot:master
219+
image_google_pause: gcr.io/<project_id>/cortexlabs/google-pause:master
220+
image_prometheus: gcr.io/<project_id>/cortexlabs/prometheus:master
221+
image_prometheus_config_reloader: gcr.io/<project_id>/cortexlabs/prometheus-config-reloader:master
222+
image_prometheus_operator: gcr.io/<project_id>/cortexlabs/prometheus-operator:master
223+
image_prometheus_statsd_exporter: gcr.io/<project_id>/cortexlabs/prometheus-statsd-exporter:master
224+
image_grafana: gcr.io/<project_id>/cortexlabs/grafana:master
225225
```
226226

227227
### Building

Makefile

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -193,38 +193,20 @@ images-all-aws:
193193
@./dev/registry.sh update all -p aws
194194
images-all-gcp:
195195
@./dev/registry.sh update all -p gcp
196-
images-all-slim-skip-push:
197-
@./dev/registry.sh update all --include-slim
198-
images-all-slim-aws:
199-
@./dev/registry.sh update all -p aws --include-slim
200-
images-all-slim-gcp:
201-
@./dev/registry.sh update all -p gcp --include-slim
202196

203197
images-dev-skip-push:
204198
@./dev/registry.sh update dev
205199
images-dev-aws:
206200
@./dev/registry.sh update dev -p aws
207201
images-dev-gcp:
208202
@./dev/registry.sh update dev -p gcp
209-
images-dev-slim-skip-push:
210-
@./dev/registry.sh update dev --include-slim
211-
images-dev-slim-aws:
212-
@./dev/registry.sh update dev -p aws --include-slim
213-
images-dev-slim-gcp:
214-
@./dev/registry.sh update dev -p gcp --include-slim
215203

216204
images-api-skip-push:
217205
@./dev/registry.sh update api
218206
images-api-aws:
219207
@./dev/registry.sh update api -p aws
220208
images-api-gcp:
221209
@./dev/registry.sh update api -p gcp
222-
images-api-slim-skip-push:
223-
@./dev/registry.sh update api --include-slim
224-
images-api-slim-aws:
225-
@./dev/registry.sh update api -p aws --include-slim
226-
images-api-slim-gcp:
227-
@./dev/registry.sh update api -p gcp --include-slim
228210

229211
images-manager-skip-push:
230212
@./dev/registry.sh update-single manager

build/build-image.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,20 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. >/dev/null && pwd)"
2222
CORTEX_VERSION=master
2323

2424
image=$1
25-
dir="${ROOT}/images/${image/-slim}"
2625

2726
if [ "$image" == "inferentia" ]; then
2827
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin 790709498068.dkr.ecr.us-west-2.amazonaws.com
2928
fi
3029

3130
build_args=""
32-
if [[ "$image" == *"-slim" ]]; then
33-
build_args="--build-arg SLIM=true"
34-
fi
3531

36-
if [ "${image}" == "python-predictor-gpu-slim" ]; then
32+
if [ "${image}" == "python-predictor-gpu" ]; then
3733
cuda=("10.0" "10.1" "10.1" "10.2" "10.2" "11.0" "11.1")
3834
cudnn=("7" "7" "8" "7" "8" "8" "8")
3935
for i in ${!cudnn[@]}; do
4036
build_args="${build_args} --build-arg CUDA_VERSION=${cuda[$i]} --build-arg CUDNN=${cudnn[$i]}"
41-
docker build "$ROOT" -f $dir/Dockerfile $build_args -t quay.io/cortexlabs/${image}:${CORTEX_VERSION}-cuda${cuda[$i]}-cudnn${cudnn[$i]}
37+
docker build "$ROOT" -f $ROOT/images/$image/Dockerfile $build_args -t quay.io/cortexlabs/${image}:${CORTEX_VERSION}-cuda${cuda[$i]}-cudnn${cudnn[$i]}
4238
done
4339
else
44-
docker build "$ROOT" -f $dir/Dockerfile $build_args -t quay.io/cortexlabs/${image}:${CORTEX_VERSION}
40+
docker build "$ROOT" -f $ROOT/images/$image/Dockerfile $build_args -t quay.io/cortexlabs/${image}:${CORTEX_VERSION}
4541
fi

build/images.sh

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,6 @@ api_images_gcp=(
3434
# includes api_images_cluster
3535
)
3636

37-
api_slim_images_cluster=(
38-
"python-predictor-cpu-slim"
39-
"python-predictor-gpu-slim"
40-
"tensorflow-predictor-slim"
41-
"onnx-predictor-cpu-slim"
42-
"onnx-predictor-gpu-slim"
43-
)
44-
api_slim_images_aws=(
45-
# includes api_slim_images_cluster
46-
"python-predictor-inf-slim"
47-
)
48-
api_slim_images_gcp=(
49-
# includes api_slim_images_cluster
50-
)
51-
5237
dev_images_cluster=(
5338
"downloader"
5439
"manager"
@@ -92,9 +77,6 @@ all_images=(
9277
"${api_images_cluster[@]}"
9378
"${api_images_aws[@]}"
9479
"${api_images_gcp[@]}"
95-
"${api_slim_images_cluster[@]}"
96-
"${api_slim_images_aws[@]}"
97-
"${api_slim_images_gcp[@]}"
9880
"${dev_images_cluster[@]}"
9981
"${dev_images_aws[@]}"
10082
"${dev_images_gcp[@]}"
@@ -106,8 +88,6 @@ all_images=(
10688
aws_images=(
10789
"${api_images_cluster[@]}"
10890
"${api_images_aws[@]}"
109-
"${api_slim_images_cluster[@]}"
110-
"${api_slim_images_aws[@]}"
11191
"${dev_images_cluster[@]}"
11292
"${dev_images_aws[@]}"
11393
"${non_dev_images_cluster[@]}"
@@ -117,8 +97,6 @@ aws_images=(
11797
gcp_images=(
11898
"${api_images_cluster[@]}"
11999
"${api_images_gcp[@]}"
120-
"${api_slim_images_cluster[@]}"
121-
"${api_slim_images_gcp[@]}"
122100
"${dev_images_cluster[@]}"
123101
"${dev_images_gcp[@]}"
124102
"${non_dev_images_cluster[@]}"

build/push-image.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ image=$1
2323

2424
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
2525

26-
if [ "$image" == "python-predictor-gpu-slim" ]; then
26+
if [ "$image" == "python-predictor-gpu" ]; then
2727
cuda=("10.0" "10.1" "10.1" "10.2" "10.2" "11.0" "11.1")
2828
cudnn=("7" "7" "8" "7" "8" "8" "8")
2929
for i in ${!cudnn[@]}; do

charts/charts/networking/charts/api-ingress/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ global:
186186
hub: quay.io/cortexlabs
187187

188188
# Default tag for Istio images.
189-
tag: latest # CORTEX_VERSION
189+
tag: master # CORTEX_VERSION
190190

191191
# Specify image pull policy if default behavior isn't desired.
192192
# Default behavior: latest images will be Always else IfNotPresent.

charts/charts/networking/charts/operator-ingress/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ global:
186186
hub: quay.io/cortexlabs
187187

188188
# Default tag for Istio images.
189-
tag: latest # CORTEX_VERSION
189+
tag: master # CORTEX_VERSION
190190

191191
# Specify image pull policy if default behavior isn't desired.
192192
# Default behavior: latest images will be Always else IfNotPresent.

dev/registry.sh

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
CORTEX_VERSION=master
1718

1819
set -eo pipefail
1920

@@ -32,7 +33,6 @@ AWS_ACCOUNT_ID=${AWS_ACCOUNT_ID:-}
3233
AWS_REGION=${AWS_REGION:-}
3334

3435
provider="undefined"
35-
include_slim="false"
3636
positional_args=()
3737
while [[ $# -gt 0 ]]; do
3838
key="$1"
@@ -42,10 +42,6 @@ while [[ $# -gt 0 ]]; do
4242
shift
4343
shift
4444
;;
45-
--include-slim)
46-
include_slim="true"
47-
shift
48-
;;
4945
*)
5046
positional_args+=("$1")
5147
shift
@@ -112,12 +108,9 @@ function create_aws_registry() {
112108
function build() {
113109
local image=$1
114110
local tag=$2
115-
local dir="${ROOT}/images/${image/-slim}"
111+
local dir="${ROOT}/images/${image}"
116112

117113
build_args=""
118-
if [[ "$image" == *"-slim" ]]; then
119-
build_args="--build-arg SLIM=true"
120-
fi
121114

122115
tag_args=""
123116
if [ -n "$GCP_PROJECT_ID" ]; then
@@ -134,10 +127,10 @@ function build() {
134127

135128
function cache_builder() {
136129
local image=$1
137-
local dir="${ROOT}/images/${image/-slim}"
130+
local dir="${ROOT}/images/${image}"
138131

139132
blue_echo "Building $image-builder..."
140-
docker build $ROOT -f $dir/Dockerfile -t cortexlabs/$image-builder:latest --target builder
133+
docker build $ROOT -f $dir/Dockerfile -t cortexlabs/$image-builder:$CORTEX_VERSION --target builder
141134
green_echo "Built $image-builder\n"
142135
}
143136

@@ -158,10 +151,14 @@ function push() {
158151

159152
function build_and_push() {
160153
local image=$1
161-
local tag=$2
162154

163155
set -euo pipefail # necessary since this is called in a new shell by parallel
164156

157+
tag=$CORTEX_VERSION
158+
if [ "${image}" == "python-predictor-gpu" ]; then
159+
tag="${CORTEX_VERSION}-cuda10.2-cudnn8"
160+
fi
161+
165162
build $image $tag
166163
push $image $tag
167164
}
@@ -176,18 +173,28 @@ function cleanup_ecr() {
176173
echo "cleaning ECR repositories..."
177174
repos=$(aws ecr describe-repositories --output text | awk '{print $6}' | grep -P "\S")
178175
echo "$repos" |
179-
while IFS= read -r line; do
180-
imageIDs=$(aws ecr list-images --repository-name "$line" --filter tagStatus=UNTAGGED --query "imageIds[*]" --output text)
176+
while IFS= read -r repo; do
177+
imageIDs=$(aws ecr list-images --repository-name "$repo" --filter tagStatus=UNTAGGED --query "imageIds[*]" --output text)
181178
echo "$imageIDs" |
182179
while IFS= read -r imageId; do
183180
if [ ! -z "$imageId" ]; then
184-
echo "Removing from ECR: $line/$imageId"
185-
aws ecr batch-delete-image --repository-name "$line" --image-ids imageDigest="$imageId" >/dev/null;
181+
echo "Removing from ECR: $repo/$imageId"
182+
aws ecr batch-delete-image --repository-name "$repo" --image-ids imageDigest="$imageId" >/dev/null;
186183
fi
187184
done
188185
done
189186
}
190187

188+
function delete_ecr() {
189+
echo "deleting ECR repositories..."
190+
repos=$(aws ecr describe-repositories --output text | awk '{print $6}' | grep -P "\S")
191+
echo "$repos" |
192+
while IFS= read -r repo; do
193+
imageIDs=$(aws ecr delete-repository --force --repository-name "$repo")
194+
echo "deleted: $repo"
195+
done
196+
}
197+
191198
function validate_env() {
192199
local provider=$1
193200

@@ -218,7 +225,8 @@ validate_env "$provider"
218225
# usage: registry.sh clean --provider aws|gcp
219226
if [ "$cmd" = "clean" ]; then
220227
if [ "$provider" = "aws" ]; then
221-
cleanup_ecr
228+
delete_ecr
229+
create_aws_registry
222230
fi
223231

224232
# usage: registry.sh create --provider/-p aws|gcp
@@ -233,9 +241,9 @@ elif [ "$cmd" = "update-single" ]; then
233241
if [ "$image" = "operator" ] || [ "$image" = "request-monitor" ]; then
234242
cache_builder $image
235243
fi
236-
build_and_push $image latest
244+
build_and_push $image
237245

238-
# usage: registry.sh update all|dev|api --provider/-p aws|gcp [--include-slim]
246+
# usage: registry.sh update all|dev|api --provider/-p aws|gcp
239247
# if parallel utility is installed, the docker build commands will be parallelized
240248
elif [ "$cmd" = "update" ]; then
241249
images_to_build=()
@@ -271,17 +279,6 @@ elif [ "$cmd" = "update" ]; then
271279
images_to_build+=( "${api_images_aws[@]}" "${api_images_gcp[@]}" )
272280
fi
273281

274-
if [ "$include_slim" == "true" ]; then
275-
images_to_build+=( "${api_slim_images_cluster[@]}" )
276-
if [ "$provider" == "aws" ]; then
277-
images_to_build+=( "${api_slim_images_aws[@]}" )
278-
elif [ "$provider" == "gcp" ]; then
279-
images_to_build+=( "${api_slim_images_gcp[@]}" )
280-
elif [ "$provider" == "undefined" ]; then
281-
images_to_build+=( "${api_slim_images_aws[@]}" "${api_slim_images_gcp[@]}" )
282-
fi
283-
fi
284-
285282
if [[ " ${images_to_build[@]} " =~ " operator " ]]; then
286283
cache_builder operator
287284
fi
@@ -290,10 +287,10 @@ elif [ "$cmd" = "update" ]; then
290287
fi
291288

292289
if command -v parallel &> /dev/null && [ -n "${NUM_BUILD_PROCS+set}" ] && [ "$NUM_BUILD_PROCS" != "1" ]; then
293-
provider=$provider is_registry_logged_in=$is_registry_logged_in ROOT=$ROOT registry_push_url=$registry_push_url SHELL=$(type -p /bin/bash) parallel --will-cite --halt now,fail=1 --eta --jobs $NUM_BUILD_PROCS build_and_push "{} latest" ::: "${images_to_build[@]}"
290+
provider=$provider is_registry_logged_in=$is_registry_logged_in ROOT=$ROOT registry_push_url=$registry_push_url SHELL=$(type -p /bin/bash) parallel --will-cite --halt now,fail=1 --eta --jobs $NUM_BUILD_PROCS build_and_push "{}" ::: "${images_to_build[@]}"
294291
else
295292
for image in "${images_to_build[@]}"; do
296-
build_and_push $image latest
293+
build_and_push $image
297294
done
298295
fi
299296

0 commit comments

Comments
 (0)