|
| 1 | +# Copyright 2021 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +import re |
| 16 | + |
| 17 | +from collections import defaultdict |
| 18 | + |
| 19 | +# [region]-docker.pkg.dev/vertex-ai/prediction/[framework]-[accelerator].[version]:latest |
| 20 | +CONTAINER_URI_PATTERN = re.compile( |
| 21 | + r"(?P<region>[\w]+)\-docker\.pkg\.dev\/vertex\-ai\/prediction\/" |
| 22 | + r"(?P<framework>[\w]+)\-(?P<accelerator>[\w]+)\.(?P<version>[\d-]+):latest" |
| 23 | +) |
| 24 | + |
| 25 | +SKLEARN = "sklearn" |
| 26 | +TF = "tf" |
| 27 | +TF2 = "tf2" |
| 28 | +XGBOOST = "xgboost" |
| 29 | + |
| 30 | +XGBOOST_CONTAINER_URIS = [ |
| 31 | + "us-docker.pkg.dev/vertex-ai/prediction/xgboost-cpu.1-4:latest", |
| 32 | + "europe-docker.pkg.dev/vertex-ai/prediction/xgboost-cpu.1-4:latest", |
| 33 | + "asia-docker.pkg.dev/vertex-ai/prediction/xgboost-cpu.1-4:latest", |
| 34 | + "us-docker.pkg.dev/vertex-ai/prediction/xgboost-cpu.1-3:latest", |
| 35 | + "europe-docker.pkg.dev/vertex-ai/prediction/xgboost-cpu.1-3:latest", |
| 36 | + "asia-docker.pkg.dev/vertex-ai/prediction/xgboost-cpu.1-3:latest", |
| 37 | + "us-docker.pkg.dev/vertex-ai/prediction/xgboost-cpu.1-2:latest", |
| 38 | + "europe-docker.pkg.dev/vertex-ai/prediction/xgboost-cpu.1-2:latest", |
| 39 | + "asia-docker.pkg.dev/vertex-ai/prediction/xgboost-cpu.1-2:latest", |
| 40 | + "us-docker.pkg.dev/vertex-ai/prediction/xgboost-cpu.1-1:latest", |
| 41 | + "europe-docker.pkg.dev/vertex-ai/prediction/xgboost-cpu.1-1:latest", |
| 42 | + "asia-docker.pkg.dev/vertex-ai/prediction/xgboost-cpu.1-1:latest", |
| 43 | + "us-docker.pkg.dev/vertex-ai/prediction/xgboost-cpu.0-90:latest", |
| 44 | + "europe-docker.pkg.dev/vertex-ai/prediction/xgboost-cpu.0-90:latest", |
| 45 | + "asia-docker.pkg.dev/vertex-ai/prediction/xgboost-cpu.0-90:latest", |
| 46 | + "us-docker.pkg.dev/vertex-ai/prediction/xgboost-cpu.0-82:latest", |
| 47 | + "europe-docker.pkg.dev/vertex-ai/prediction/xgboost-cpu.0-82:latest", |
| 48 | + "asia-docker.pkg.dev/vertex-ai/prediction/xgboost-cpu.0-82:latest", |
| 49 | +] |
| 50 | + |
| 51 | +SKLEARN_CONTAINER_URIS = [ |
| 52 | + "us-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.1-0:latest", |
| 53 | + "europe-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.1-0:latest", |
| 54 | + "asia-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.1-0:latest", |
| 55 | + "us-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.0-24:latest", |
| 56 | + "europe-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.0-24:latest", |
| 57 | + "asia-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.0-24:latest", |
| 58 | + "us-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.0-23:latest", |
| 59 | + "europe-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.0-23:latest", |
| 60 | + "asia-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.0-23:latest", |
| 61 | + "us-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.0-22:latest", |
| 62 | + "europe-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.0-22:latest", |
| 63 | + "asia-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.0-22:latest", |
| 64 | + "us-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.0-20:latest", |
| 65 | + "europe-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.0-20:latest", |
| 66 | + "asia-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.0-20:latest", |
| 67 | +] |
| 68 | + |
| 69 | +TF_CONTAINER_URIS = [ |
| 70 | + "us-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-7:latest", |
| 71 | + "europe-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-7:latest", |
| 72 | + "asia-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-7:latest", |
| 73 | + "us-docker.pkg.dev/vertex-ai/prediction/tf2-gpu.2-7:latest", |
| 74 | + "europe-docker.pkg.dev/vertex-ai/prediction/tf2-gpu.2-7:latest", |
| 75 | + "asia-docker.pkg.dev/vertex-ai/prediction/tf2-gpu.2-7:latest", |
| 76 | + "us-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-6:latest", |
| 77 | + "europe-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-6:latest", |
| 78 | + "asia-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-6:latest", |
| 79 | + "us-docker.pkg.dev/vertex-ai/prediction/tf2-gpu.2-6:latest", |
| 80 | + "europe-docker.pkg.dev/vertex-ai/prediction/tf2-gpu.2-6:latest", |
| 81 | + "asia-docker.pkg.dev/vertex-ai/prediction/tf2-gpu.2-6:latest", |
| 82 | + "us-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-5:latest", |
| 83 | + "europe-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-5:latest", |
| 84 | + "asia-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-5:latest", |
| 85 | + "us-docker.pkg.dev/vertex-ai/prediction/tf2-gpu.2-5:latest", |
| 86 | + "europe-docker.pkg.dev/vertex-ai/prediction/tf2-gpu.2-5:latest", |
| 87 | + "asia-docker.pkg.dev/vertex-ai/prediction/tf2-gpu.2-5:latest", |
| 88 | + "us-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-4:latest", |
| 89 | + "europe-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-4:latest", |
| 90 | + "asia-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-4:latest", |
| 91 | + "us-docker.pkg.dev/vertex-ai/prediction/tf2-gpu.2-4:latest", |
| 92 | + "europe-docker.pkg.dev/vertex-ai/prediction/tf2-gpu.2-4:latest", |
| 93 | + "asia-docker.pkg.dev/vertex-ai/prediction/tf2-gpu.2-4:latest", |
| 94 | + "us-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-3:latest", |
| 95 | + "europe-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-3:latest", |
| 96 | + "asia-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-3:latest", |
| 97 | + "us-docker.pkg.dev/vertex-ai/prediction/tf2-gpu.2-3:latest", |
| 98 | + "europe-docker.pkg.dev/vertex-ai/prediction/tf2-gpu.2-3:latest", |
| 99 | + "asia-docker.pkg.dev/vertex-ai/prediction/tf2-gpu.2-3:latest", |
| 100 | + "us-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-2:latest", |
| 101 | + "europe-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-2:latest", |
| 102 | + "asia-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-2:latest", |
| 103 | + "us-docker.pkg.dev/vertex-ai/prediction/tf2-gpu.2-2:latest", |
| 104 | + "europe-docker.pkg.dev/vertex-ai/prediction/tf2-gpu.2-2:latest", |
| 105 | + "asia-docker.pkg.dev/vertex-ai/prediction/tf2-gpu.2-2:latest", |
| 106 | + "us-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-1:latest", |
| 107 | + "europe-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-1:latest", |
| 108 | + "asia-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-1:latest", |
| 109 | + "us-docker.pkg.dev/vertex-ai/prediction/tf-cpu.1-15:latest", |
| 110 | + "europe-docker.pkg.dev/vertex-ai/prediction/tf-cpu.1-15:latest", |
| 111 | + "asia-docker.pkg.dev/vertex-ai/prediction/tf-cpu.1-15:latest", |
| 112 | + "us-docker.pkg.dev/vertex-ai/prediction/tf-gpu.1-15:latest", |
| 113 | + "europe-docker.pkg.dev/vertex-ai/prediction/tf-gpu.1-15:latest", |
| 114 | + "asia-docker.pkg.dev/vertex-ai/prediction/tf-gpu.1-15:latest", |
| 115 | +] |
| 116 | + |
| 117 | +SERVING_CONTAINER_URIS = ( |
| 118 | + SKLEARN_CONTAINER_URIS + TF_CONTAINER_URIS + XGBOOST_CONTAINER_URIS |
| 119 | +) |
| 120 | + |
| 121 | +# Map of all first-party prediction containers |
| 122 | +d = defaultdict(lambda: defaultdict(lambda: defaultdict(lambda: defaultdict(str)))) |
| 123 | + |
| 124 | +for container_uri in SERVING_CONTAINER_URIS: |
| 125 | + m = CONTAINER_URI_PATTERN.match(container_uri) |
| 126 | + region, framework, accelerator, version = m[1], m[2], m[3], m[4] |
| 127 | + version = version.replace("-", ".") |
| 128 | + |
| 129 | + if framework in (TF2, TF): # Store both `tf`, `tf2` as `tensorflow` |
| 130 | + framework = "tensorflow" |
| 131 | + |
| 132 | + d[region][framework][accelerator][version] = container_uri |
| 133 | + |
| 134 | +_SERVING_CONTAINER_URI_MAP = d |
| 135 | + |
| 136 | +_SERVING_CONTAINER_DOCUMENTATION_URL = ( |
| 137 | + "https://cloud.google.com/vertex-ai/docs/predictions/pre-built-containers" |
| 138 | +) |
0 commit comments