Skip to content

Instantly share code, notes, and snippets.

@sayakpaul
Created July 27, 2022 13:24
Show Gist options
  • Save sayakpaul/d8b9876fad1421b7cb8301d0dcaf4946 to your computer and use it in GitHub Desktop.
Save sayakpaul/d8b9876fad1421b7cb8301d0dcaf4946 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"id": "04188740",
"metadata": {},
"source": [
"## Initial setup"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "5a5b62bd-68a3-429d-b4c9-c70588ebb7a5",
"metadata": {},
"outputs": [],
"source": [
"# Storage bucket\n",
"GCS_BUCKET = \"gs://hf-tf-vision\"\n",
"REGION = \"us-central1\""
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "c9309446-1c97-4b2e-9b1c-ca0f4ead7c34",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Creating gs://hf-tf-vision/...\n"
]
}
],
"source": [
"!gsutil mb -l $REGION $GCS_BUCKET"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "157f1ffe",
"metadata": {},
"outputs": [],
"source": [
"# # Install Vertex AI SDK\n",
"# !pip install --upgrade google-cloud-aiplatform -q\n",
"\n",
"# Install TensorFlow Serving API\n",
"# !pip install -q tensorflow-serving-api"
]
},
{
"cell_type": "markdown",
"id": "aba67801",
"metadata": {},
"source": [
"## Initial imports"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "354874fb-98e8-4fd7-891e-4c9ce1e6f75f",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2022-07-27 12:17:49.547428: I tensorflow/core/common_runtime/process_util.cc:146] Creating new thread pool with default inter op setting: 2. Tune using inter_op_parallelism_threads for best performance.\n"
]
}
],
"source": [
"from transformers import ViTFeatureExtractor, TFViTForImageClassification\n",
"import tensorflow as tf\n",
"import tempfile\n",
"import requests\n",
"import base64\n",
"import json\n",
"import os"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "57bd7259-5a06-40d3-9ef6-37e7380ca42e",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2.9.0-rc2\n",
"4.20.1\n"
]
}
],
"source": [
"import transformers\n",
"\n",
"print(tf.__version__)\n",
"print(transformers.__version__)"
]
},
{
"cell_type": "markdown",
"id": "dad72899",
"metadata": {},
"source": [
"## Save the model locally\n",
"\n",
"We will work with a [Vision Transformer B-16 model provided by 🤗 Transformers](https://huggingface.co/docs/transformers/main/en/model_doc/vit). We will first initialize it, load the model weights, and then save it locally as a [SavedModel](https://www.tensorflow.org/guide/saved_model) resource. "
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "a8f1ba75-a1f7-4ada-91bc-c3d07ec146f0",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"All model checkpoint layers were used when initializing TFViTForImageClassification.\n",
"\n",
"All the layers of TFViTForImageClassification were initialized from the model checkpoint at google/vit-base-patch16-224.\n",
"If your task is similar to the task the model of the checkpoint was trained on, you can already use TFViTForImageClassification for predictions without further training.\n",
"WARNING:absl:Found untraced functions such as embeddings_layer_call_fn, embeddings_layer_call_and_return_conditional_losses, encoder_layer_call_fn, encoder_layer_call_and_return_conditional_losses, layernorm_layer_call_fn while saving (showing 5 of 421). These functions will not be directly callable after loading.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Assets written to: vit/saved_model/1/assets\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Assets written to: vit/saved_model/1/assets\n"
]
}
],
"source": [
"# the saved_model parameter is a flag to create a saved model version of the model\n",
"LOCAL_MODEL_DIR = \"vit\"\n",
"model = TFViTForImageClassification.from_pretrained(\"google/vit-base-patch16-224\")\n",
"model.save_pretrained(LOCAL_MODEL_DIR, saved_model=True)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "215a0d0f-45e6-438c-b02f-152427da958b",
"metadata": {},
"outputs": [],
"source": [
"# # Inspect the input and output signatures of the model\n",
"# !saved_model_cli show --dir {LOCAL_MODEL_DIR}/saved_model/1 --all"
]
},
{
"cell_type": "markdown",
"id": "e7ae5a29",
"metadata": {
"tags": []
},
"source": [
"## Preprocessing utilities"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "c4862e37-9701-4782-9da1-e4fac4dd9d32",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"ViTFeatureExtractor {\n",
" \"do_normalize\": true,\n",
" \"do_resize\": true,\n",
" \"feature_extractor_type\": \"ViTFeatureExtractor\",\n",
" \"image_mean\": [\n",
" 0.5,\n",
" 0.5,\n",
" 0.5\n",
" ],\n",
" \"image_std\": [\n",
" 0.5,\n",
" 0.5,\n",
" 0.5\n",
" ],\n",
" \"resample\": 2,\n",
" \"size\": 224\n",
"}"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"feature_extractor = ViTFeatureExtractor()\n",
"feature_extractor"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "0bfc1d8f-94f2-4b4e-b117-9918fa25a233",
"metadata": {},
"outputs": [],
"source": [
"CONCRETE_INPUT = \"pixel_values\"\n",
"SIZE = feature_extractor.size\n",
"INPUT_SHAPE = (SIZE, SIZE, 3)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "06843d8c-db3e-4650-8358-f17b265818f9",
"metadata": {},
"outputs": [],
"source": [
"def normalize_img(img, mean=feature_extractor.image_mean, std=feature_extractor.image_std):\n",
" # Scale to the value range of [0, 1] first and then normalize.\n",
" img = img / 255\n",
" mean = tf.constant(mean)\n",
" std = tf.constant(std)\n",
" return (img - mean) / std\n",
"\n",
"def preprocess(image):\n",
" resized = tf.image.resize(image, (SIZE, SIZE))\n",
" normalized = normalize_img(resized)\n",
" normalized = tf.transpose(normalized, (2, 0, 1)) # Since HF models are channel-first.\n",
" return normalized"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "359fca61-995f-451b-a89c-d2fbf493e6cf",
"metadata": {},
"outputs": [],
"source": [
"# # To deploy the model on Vertex AI we must have the model in a storage bucket.\n",
"# tf.saved_model.save(\n",
"# model,\n",
"# os.path.join(GCS_BUCKET, LOCAL_MODEL_DIR),\n",
"# signatures={\"serving_default\": model_exporter(model)},\n",
"# )"
]
},
{
"cell_type": "markdown",
"id": "2d65d3af-d456-43f9-a9da-84e529c179d2",
"metadata": {},
"source": [
"## Export prediction requests for warmup"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "4c3ed3d1-1135-4b5d-9a57-70e96c2ada6b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'image': TensorSpec(shape=(None, None, 3), dtype=tf.uint8, name=None),\n",
" 'label': TensorSpec(shape=(), dtype=tf.int64, name=None)}"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import tensorflow_datasets as tfds\n",
"\n",
"validation_ds = tfds.load(\"imagenette\", split=\"validation\")\n",
"validation_ds.element_spec"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "15963b1b-0c3a-4a54-b30a-43bbeca0dba8",
"metadata": {},
"outputs": [],
"source": [
"!mkdir -p $LOCAL_MODEL_DIR/requests"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "8418f8bb-6f67-401d-bc49-f39a8f7927a6",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Serving function input: pixel_values\n"
]
}
],
"source": [
"loaded = tf.saved_model.load(os.path.join(LOCAL_MODEL_DIR, \"saved_model\", \"1\"))\n",
"serving_input = list(\n",
" loaded.signatures[\"serving_default\"].structured_input_signature[1].keys()\n",
")[0]\n",
"print(\"Serving function input:\", serving_input)\n",
"\n",
"SERVE_INP = serving_input"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "43487618-3cf7-4bf2-ba7b-a7b7fe712b6a",
"metadata": {},
"outputs": [],
"source": [
"def encode(images):\n",
" rows = []\n",
" for row in images.numpy().tolist():\n",
" rows.append(row)\n",
" return {SERVE_INP: rows}\n",
"\n",
"\n",
"def export_requests_jsonl(file_name, rows=2, batch_size=32):\n",
" with tf.io.gfile.GFile(file_name, mode=\"w\") as f:\n",
" for batch in validation_ds.map(lambda x: preprocess(x[\"image\"])).batch(batch_size).take(rows):\n",
" d = encode(batch)\n",
" f.write(json.dumps(d))\n",
" f.write(\"\\n\")"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "b40a3bf9-b90a-4601-a785-e032f26ffd16",
"metadata": {},
"outputs": [],
"source": [
"export_requests_jsonl(os.path.join(LOCAL_MODEL_DIR, \"requests\", \"requests_1_1.jsonl\"), rows=1, batch_size=1)\n",
"export_requests_jsonl(os.path.join(LOCAL_MODEL_DIR, \"requests\", \"requests_1_32.jsonl\"), rows=1, batch_size=32)\n",
"export_requests_jsonl(os.path.join(LOCAL_MODEL_DIR, \"requests\", \"requests_10_32.jsonl\"), rows=10, batch_size=32)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "9e9ba818-0029-4edc-bf5d-f14dded3166d",
"metadata": {},
"outputs": [],
"source": [
"!mkdir -p $LOCAL_MODEL_DIR/assets.extra"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "e4a9ba6e-86dc-4257-bd64-252a594fc99d",
"metadata": {},
"outputs": [],
"source": [
"from tensorflow_serving.apis import predict_pb2, prediction_log_pb2\n",
"\n",
"\n",
"def build_grpc_request(\n",
" row_dict, model_name=\"vit\", signature_name=\"serving_default\"\n",
"):\n",
" \"\"\"Generate gRPC inference request with payload.\"\"\"\n",
"\n",
" request = predict_pb2.PredictRequest()\n",
" request.model_spec.name = model_name\n",
" request.model_spec.signature_name = signature_name\n",
" for key, value in row_dict.items():\n",
" proto = tf.make_tensor_proto(value)\n",
" request.inputs[key].CopyFrom(proto)\n",
" return request\n",
"\n",
"\n",
"def export_warmup_file(\n",
" request_files, export_path, model_name=\"vit\", signature_name=\"serving_default\"\n",
"):\n",
" with tf.io.TFRecordWriter(export_path) as writer:\n",
" for request_file_path in request_files:\n",
" with open(request_file_path) as f:\n",
" row_dict = json.loads(f.readline())\n",
" request = build_grpc_request(row_dict, model_name, signature_name)\n",
" log = prediction_log_pb2.PredictionLog(\n",
" predict_log=prediction_log_pb2.PredictLog(request=request)\n",
" )\n",
" writer.write(log.SerializeToString())\n",
"\n",
"\n",
"# https://www.tensorflow.org/tfx/serving/saved_model_warmup\n",
"export_warmup_file(\n",
" [\n",
" os.path.join(LOCAL_MODEL_DIR, \"requests\", \"requests_1_1.jsonl\"),\n",
" os.path.join(LOCAL_MODEL_DIR, \"requests\", \"requests_1_32.jsonl\"),\n",
" ],\n",
" os.path.join(LOCAL_MODEL_DIR, \"assets.extra\", \"tf_serving_warmup_requests\"),\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "85870e22-c9ea-4e06-b8a2-7b2c385c470b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Copying file://vit/assets.extra/tf_serving_warmup_requests [Content-Type=application/octet-stream]...\n",
"/ [1/1 files][ 19.0 MiB/ 19.0 MiB] 100% Done \n",
"Operation completed over 1 objects/19.0 MiB. \n",
"Copying file://vit/saved_model/1/keras_metadata.pb [Content-Type=application/octet-stream]...\n",
"Copying file://vit/saved_model/1/saved_model.pb [Content-Type=application/octet-stream]...\n",
"Copying file://vit/saved_model/1/variables/variables.data-00000-of-00001 [Content-Type=application/octet-stream]...\n",
"Copying file://vit/saved_model/1/variables/variables.index [Content-Type=application/octet-stream]...\n",
"==> NOTE: You are uploading one or more large file(s), which would run \n",
"significantly faster if you enable parallel composite uploads. This\n",
"feature can be enabled by editing the\n",
"\"parallel_composite_upload_threshold\" value in your .boto\n",
"configuration file. However, note that if you do this large files will\n",
"be uploaded as `composite objects\n",
"<https://cloud.google.com/storage/docs/composite-objects>`_,which\n",
"means that any user who downloads such objects will need to have a\n",
"compiled crcmod installed (see \"gsutil help crcmod\"). This is because\n",
"without a compiled crcmod, computing checksums on composite objects is\n",
"so slow that gsutil disables downloads of composite objects.\n",
"\n",
"- [4/4 files][336.8 MiB/336.8 MiB] 100% Done \n",
"Operation completed over 4 objects/336.8 MiB. \n"
]
}
],
"source": [
"!gsutil -m cp -r $LOCAL_MODEL_DIR/assets.extra $GCS_BUCKET/\n",
"!gsutil -m cp -r $LOCAL_MODEL_DIR/saved_model/1/* $GCS_BUCKET/"
]
},
{
"cell_type": "markdown",
"id": "d5a46991",
"metadata": {},
"source": [
"## Deployment on Vertex AI\n",
"\n",
"[This resource](https://cloud.google.com/vertex-ai/docs/general/general-concepts) shows some relevant concepts on Vertex AI. "
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "5edb508a-80f4-4652-947b-f0d95b9a8ce3",
"metadata": {},
"outputs": [],
"source": [
"from google.cloud.aiplatform import gapic as aip"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "f8edaee9-1068-4ffb-bfc1-9e63a39c8bc5",
"metadata": {},
"outputs": [],
"source": [
"# Deployment hardware\n",
"DEPLOY_COMPUTE = \"n1-standard-16\"\n",
"DEPLOY_GPU = aip.AcceleratorType.NVIDIA_TESLA_T4\n",
"PROJECT_ID = \"fast-ai-exploration\""
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "4e8d6fcd-2e63-4e39-9c2e-2047308be3f0",
"metadata": {},
"outputs": [],
"source": [
"# Initialize clients.\n",
"API_ENDPOINT = f\"{REGION}-aiplatform.googleapis.com\"\n",
"PARENT = f\"projects/{PROJECT_ID}/locations/{REGION}\"\n",
"\n",
"client_options = {\"api_endpoint\": API_ENDPOINT}\n",
"model_service_client = aip.ModelServiceClient(client_options=client_options)\n",
"endpoint_service_client = aip.EndpointServiceClient(client_options=client_options)\n",
"prediction_service_client = aip.PredictionServiceClient(client_options=client_options)"
]
},
{
"cell_type": "markdown",
"id": "fb4ad9cf-8963-4b66-9e56-5005ac302ca8",
"metadata": {},
"source": [
"## Create Models"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "d5fb346f-bfce-43e7-9c0c-5463709d8c6f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'projects/29880397572/locations/us-central1/models/6743520317429252096'"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tf28_gpu_model_dict = {\n",
" \"display_name\": \"ViT Base TF2.8 GPU model\",\n",
" \"artifact_uri\": GCS_BUCKET,\n",
" \"container_spec\": {\n",
" \"image_uri\": \"us-docker.pkg.dev/vertex-ai/prediction/tf2-gpu.2-8:latest\",\n",
" },\n",
"}\n",
"tf28_gpu_model = (\n",
" model_service_client.upload_model(parent=PARENT, model=tf28_gpu_model_dict)\n",
" .result(timeout=180)\n",
" .model\n",
")\n",
"tf28_gpu_model"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "fc9e1ded-0e0b-46f4-9817-789a90d7f1dd",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'projects/29880397572/locations/us-central1/models/5242695741608034304'"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tf_opt_gpu_model_dict = {\n",
" \"display_name\": \"ViT Base optimized TensorFlow runtime GPU model\",\n",
" \"artifact_uri\": GCS_BUCKET,\n",
" \"container_spec\": {\n",
" \"image_uri\": \"us-docker.pkg.dev/vertex-ai-restricted/prediction/tf_opt-gpu.nightly:latest\",\n",
" \"args\": [\n",
" \"--allow_precompilation=true\",\n",
" \"--allow_precision_affecting_optimizations=false\",\n",
" ],\n",
" },\n",
"}\n",
"\n",
"tf_opt_gpu_model = (\n",
" model_service_client.upload_model(parent=PARENT, model=tf_opt_gpu_model_dict)\n",
" .result(timeout=180)\n",
" .model\n",
")\n",
"tf_opt_gpu_model"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "557a681a-4af8-4896-bada-a134d207c1eb",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'projects/29880397572/locations/us-central1/models/3847705757030023168'"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tf_opt_lossy_gpu_model_dict = {\n",
" \"display_name\": \"ViT Base optimized TensorFlow runtime GPU model with lossy optimizations\",\n",
" \"artifact_uri\": GCS_BUCKET,\n",
" \"container_spec\": {\n",
" \"image_uri\": \"us-docker.pkg.dev/vertex-ai-restricted/prediction/tf_opt-gpu.nightly:latest\",\n",
" \"args\": [\n",
" \"--allow_precompilation=true\",\n",
" \"--allow_precision_affecting_optimizations=true\",\n",
" ],\n",
" },\n",
"}\n",
"\n",
"tf_opt_lossy_gpu_model = (\n",
" model_service_client.upload_model(parent=PARENT, model=tf_opt_lossy_gpu_model_dict)\n",
" .result(timeout=180)\n",
" .model\n",
")\n",
"tf_opt_lossy_gpu_model"
]
},
{
"cell_type": "markdown",
"id": "ea120606-d72d-41a4-936a-bb8547e3d503",
"metadata": {},
"source": [
"## Create Endpoints"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "5a0dc3ef-6609-4374-b934-75c382f7fc6d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'projects/29880397572/locations/us-central1/endpoints/2991014675178586112'"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tf28_gpu_endpoint_dict = {\n",
" \"display_name\": \"ViT Base TF2.8 GPU endpoint\",\n",
"}\n",
"tf28_gpu_endpoint = (\n",
" endpoint_service_client.create_endpoint(\n",
" parent=PARENT, endpoint=tf28_gpu_endpoint_dict\n",
" )\n",
" .result(timeout=300)\n",
" .name\n",
")\n",
"tf28_gpu_endpoint"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "a88e56e2-14ff-412f-a4f2-35c7c8431f18",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'projects/29880397572/locations/us-central1/endpoints/4884778318487879680'"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tf_opt_gpu_endpoint_dict = {\n",
" \"display_name\": \"ViT Base optimized TensorFlow runtime GPU endpoint\",\n",
"}\n",
"tf_opt_gpu_endpoint = (\n",
" endpoint_service_client.create_endpoint(\n",
" parent=PARENT, endpoint=tf_opt_gpu_endpoint_dict\n",
" )\n",
" .result(timeout=300)\n",
" .name\n",
")\n",
"tf_opt_gpu_endpoint"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "c7a8c050-43d3-494f-8da3-a88c106ed50e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'projects/29880397572/locations/us-central1/endpoints/7156844330496294912'"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tf_opt_lossy_gpu_endpoint_dict = {\n",
" \"display_name\": \"ViT Base optimized TensorFlow runtime GPU with lossy optimizations endpoint\",\n",
"}\n",
"tf_opt_lossy_gpu_endpoint = (\n",
" endpoint_service_client.create_endpoint(\n",
" parent=PARENT, endpoint=tf_opt_lossy_gpu_endpoint_dict\n",
" )\n",
" .result(timeout=300)\n",
" .name\n",
")\n",
"tf_opt_lossy_gpu_endpoint"
]
},
{
"cell_type": "markdown",
"id": "14098bc5-beb6-4f49-a7ab-535f3c98907a",
"metadata": {},
"source": [
"## Deploy to Endpoints"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "6a5a98af-720e-4854-a97e-76cd02ed5f7a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"deployed_model {\n",
" id: \"7290522954201300992\"\n",
"}"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tf28_gpu_deployed_model_dict = {\n",
" \"model\": tf28_gpu_model,\n",
" \"display_name\": \"ViT Base TF2.8 GPU deployed model\",\n",
" \"dedicated_resources\": {\n",
" \"min_replica_count\": 1,\n",
" \"max_replica_count\": 1,\n",
" \"machine_spec\": {\n",
" \"machine_type\": DEPLOY_COMPUTE,\n",
" \"accelerator_type\": DEPLOY_GPU,\n",
" \"accelerator_count\": 1,\n",
" },\n",
" },\n",
"}\n",
"\n",
"tf28_gpu_deployed_model = endpoint_service_client.deploy_model(\n",
" endpoint=tf28_gpu_endpoint,\n",
" deployed_model=tf28_gpu_deployed_model_dict,\n",
" traffic_split={\"0\": 100},\n",
").result()\n",
"tf28_gpu_deployed_model"
]
},
{
"cell_type": "code",
"execution_count": 35,
"id": "5295d3d9-1925-4a33-80db-77f2950641b5",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# sample_batch = for batch in validation_ds.map(lambda x: preprocess(x[\"image\"])).batch(batch_size).take(rows)\n",
"prediction_samples = [\n",
" sample.numpy().tolist() for sample in validation_ds.map(lambda x: preprocess(x[\"image\"])).take(1)\n",
"]\n",
"len(prediction_samples)"
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "69d70050-58a5-419b-89db-ec04f75f9008",
"metadata": {},
"outputs": [
{
"ename": "FailedPrecondition",
"evalue": "400 The request size (1659946 bytes) exceeds 1.500MB limit.",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31m_InactiveRpcError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m/opt/conda/lib/python3.7/site-packages/google/api_core/grpc_helpers.py\u001b[0m in \u001b[0;36merror_remapped_callable\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 56\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 57\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mcallable_\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 58\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mgrpc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mRpcError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mexc\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/opt/conda/lib/python3.7/site-packages/grpc/_channel.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, request, timeout, metadata, credentials, wait_for_ready, compression)\u001b[0m\n\u001b[1;32m 945\u001b[0m wait_for_ready, compression)\n\u001b[0;32m--> 946\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0m_end_unary_response_blocking\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstate\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcall\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 947\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/opt/conda/lib/python3.7/site-packages/grpc/_channel.py\u001b[0m in \u001b[0;36m_end_unary_response_blocking\u001b[0;34m(state, call, with_call, deadline)\u001b[0m\n\u001b[1;32m 848\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 849\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0m_InactiveRpcError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstate\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 850\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31m_InactiveRpcError\u001b[0m: <_InactiveRpcError of RPC that terminated with:\n\tstatus = StatusCode.FAILED_PRECONDITION\n\tdetails = \"The request size (1659946 bytes) exceeds 1.500MB limit.\"\n\tdebug_error_string = \"{\"created\":\"@1658926563.663880441\",\"description\":\"Error received from peer ipv4:74.125.69.95:443\",\"file\":\"/home/conda/feedstock_root/build_artifacts/grpc-split_1656146941531/work/src/core/lib/surface/call.cc\",\"file_line\":966,\"grpc_message\":\"The request size (1659946 bytes) exceeds 1.500MB limit.\",\"grpc_status\":9}\"\n>",
"\nThe above exception was the direct cause of the following exception:\n",
"\u001b[0;31mFailedPrecondition\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m/tmp/ipykernel_3307/550173685.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m prediction_service_client.predict(\n\u001b[1;32m 2\u001b[0m \u001b[0mendpoint\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtf28_gpu_endpoint\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0minstances\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mprediction_samples\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m )\n",
"\u001b[0;32m/opt/conda/lib/python3.7/site-packages/google/cloud/aiplatform_v1/services/prediction_service/client.py\u001b[0m in \u001b[0;36mpredict\u001b[0;34m(self, request, endpoint, instances, parameters, retry, timeout, metadata)\u001b[0m\n\u001b[1;32m 583\u001b[0m \u001b[0mretry\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mretry\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 584\u001b[0m \u001b[0mtimeout\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtimeout\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 585\u001b[0;31m \u001b[0mmetadata\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmetadata\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 586\u001b[0m )\n\u001b[1;32m 587\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/opt/conda/lib/python3.7/site-packages/google/api_core/gapic_v1/method.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, timeout, retry, *args, **kwargs)\u001b[0m\n\u001b[1;32m 152\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"metadata\"\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmetadata\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 153\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 154\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mwrapped_func\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 155\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 156\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/opt/conda/lib/python3.7/site-packages/google/api_core/grpc_helpers.py\u001b[0m in \u001b[0;36merror_remapped_callable\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 57\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mcallable_\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 58\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mgrpc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mRpcError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mexc\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 59\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mexceptions\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfrom_grpc_error\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexc\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mexc\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 60\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 61\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0merror_remapped_callable\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mFailedPrecondition\u001b[0m: 400 The request size (1659946 bytes) exceeds 1.500MB limit."
]
}
],
"source": [
"prediction_service_client.predict(\n",
" endpoint=tf28_gpu_endpoint,\n",
" instances=prediction_samples,\n",
")\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "656715fa-e386-4ab7-8a2f-1e21084f2c0a",
"metadata": {},
"outputs": [],
"source": [
"# tf_opt_gpu_deployed_model_dict = {\n",
"# \"model\": tf_opt_gpu_model,\n",
"# \"display_name\": \"ViT Base optimized TensorFlow runtime GPU model\",\n",
"# \"dedicated_resources\": {\n",
"# \"min_replica_count\": 1,\n",
"# \"max_replica_count\": 1,\n",
"# \"machine_spec\": {\n",
"# \"machine_type\": DEPLOY_COMPUTE,\n",
"# \"accelerator_type\": DEPLOY_GPU,\n",
"# \"accelerator_count\": 1,\n",
"# },\n",
"# },\n",
"# }\n",
"\n",
"# tf_opt_gpu_deployed_model = endpoint_service_client.deploy_model(\n",
"# endpoint=tf_opt_gpu_endpoint,\n",
"# deployed_model=tf_opt_gpu_deployed_model_dict,\n",
"# traffic_split={\"0\": 100},\n",
"# ).result()\n",
"# tf_opt_gpu_deployed_model"
]
},
{
"cell_type": "code",
"execution_count": 37,
"id": "64e200db-c9e7-4ae4-b965-b29dbd1a554a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"deployed_model {\n",
" id: \"4163617437922623488\"\n",
"}"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# tf_opt_lossy_gpu_deployed_model_dict = {\n",
"# \"model\": tf_opt_lossy_gpu_model,\n",
"# \"display_name\": \"ViT Base optimized TensorFlow runtime GPU model with lossy optimizations\",\n",
"# \"dedicated_resources\": {\n",
"# \"min_replica_count\": 1,\n",
"# \"max_replica_count\": 1,\n",
"# \"machine_spec\": {\n",
"# \"machine_type\": DEPLOY_COMPUTE,\n",
"# \"accelerator_type\": DEPLOY_GPU,\n",
"# \"accelerator_count\": 1,\n",
"# },\n",
"# },\n",
"# }\n",
"\n",
"# tf_opt_lossy_gpu_deployed_model = endpoint_service_client.deploy_model(\n",
"# endpoint=tf_opt_lossy_gpu_endpoint,\n",
"# deployed_model=tf_opt_lossy_gpu_deployed_model_dict,\n",
"# traffic_split={\"0\": 100},\n",
"# ).result()\n",
"# tf_opt_lossy_gpu_deployed_model"
]
},
{
"cell_type": "code",
"execution_count": 44,
"id": "2de61a97-d898-4279-9474-16733157a1e4",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" % Total % Received % Xferd Average Speed Time Time Time Current\n",
" Dload Upload Total Spent Left Speed\n",
"100 4110 100 4110 0 0 97k 0 --:--:-- --:--:-- --:--:-- 100k\n"
]
}
],
"source": [
"!curl https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/vertex_endpoints/optimized_tensorflow_runtime/benchmark.py -o benchmark.py"
]
},
{
"cell_type": "markdown",
"id": "a6f739e7-df44-4fd6-96f3-9e3902b98954",
"metadata": {},
"source": [
"## Benchmarking"
]
},
{
"cell_type": "code",
"execution_count": 45,
"id": "ff7a96e0-5511-4541-8765-e9986ef10c74",
"metadata": {},
"outputs": [],
"source": [
"from benchmark import benchmark"
]
},
{
"cell_type": "code",
"execution_count": 47,
"id": "bcd17295-de82-4331-a56a-9b74b88593a8",
"metadata": {},
"outputs": [],
"source": [
"import subprocess\n",
"\n",
"def get_headers():\n",
" gcloud_access_token = (\n",
" subprocess.check_output(\"gcloud auth print-access-token\".split(\" \"))\n",
" .decode()\n",
" .rstrip(\"\\n\")\n",
" )\n",
" return {\"authorization\": \"Bearer \" + gcloud_access_token}"
]
},
{
"cell_type": "code",
"execution_count": 40,
"id": "1afee670-c4f3-431f-b81e-c705e2c54ac6",
"metadata": {},
"outputs": [],
"source": [
"def build_rest_request(row_dict, model_name):\n",
" payload = json.dumps({\"instances\": row_dict})\n",
" return payload"
]
},
{
"cell_type": "code",
"execution_count": 48,
"id": "08c38b25-3b2e-4992-88ac-13d6e7476c99",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:benchmarking at 1 QPS, sending 10 requests\n",
"INFO:tensorflow:Running benchmark at 1 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:received 10 responses.\n",
"INFO:tensorflow:num_qps:1 requests/second: 1.00 #success:0 #error:10 latencies: [avg:0.45ms p50:0.44ms p90:0.63ms p99:0.64ms]\n",
"INFO:tensorflow:benchmarking at 2 QPS, sending 10 requests\n",
"INFO:tensorflow:Running benchmark at 2 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:num_qps:2 requests/second: 2.00 #success:0 #error:10 latencies: [avg:0.33ms p50:0.27ms p90:0.61ms p99:0.63ms]\n",
"INFO:tensorflow:benchmarking at 3 QPS, sending 15 requests\n",
"INFO:tensorflow:Running benchmark at 3 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:num_qps:3 requests/second: 3.00 #success:0 #error:15 latencies: [avg:0.29ms p50:0.26ms p90:0.31ms p99:0.63ms]\n",
"INFO:tensorflow:benchmarking at 4 QPS, sending 20 requests\n",
"INFO:tensorflow:Running benchmark at 4 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:num_qps:4 requests/second: 3.99 #success:0 #error:20 latencies: [avg:0.28ms p50:0.26ms p90:0.29ms p99:0.61ms]\n",
"INFO:tensorflow:benchmarking at 5 QPS, sending 25 requests\n",
"INFO:tensorflow:Running benchmark at 5 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:num_qps:5 requests/second: 4.99 #success:0 #error:25 latencies: [avg:0.27ms p50:0.25ms p90:0.29ms p99:0.89ms]\n"
]
},
{
"data": {
"text/plain": [
"defaultdict(list,\n",
" {'reqested_qps': [1, 2, 3, 4, 5],\n",
" 'actual_qps': [0.9988986238060823,\n",
" 1.9975657562986389,\n",
" 2.9960220225706826,\n",
" 3.994268250049734,\n",
" 4.99237652464746],\n",
" 'avg_latency': [0.45332908630371094,\n",
" 0.33142566680908203,\n",
" 0.28967857360839844,\n",
" 0.28089284896850586,\n",
" 0.27065277099609375],\n",
" 'p50': [0.44035911560058594,\n",
" 0.26619434356689453,\n",
" 0.2598762512207031,\n",
" 0.26214122772216797,\n",
" 0.25081634521484375],\n",
" 'p90': [0.6313323974609375,\n",
" 0.6090879440307617,\n",
" 0.3138542175292969,\n",
" 0.287318229675293,\n",
" 0.2880096435546875],\n",
" 'p99': [0.6429195404052734,\n",
" 0.6278204917907715,\n",
" 0.6320953369140623,\n",
" 0.6146121025085444,\n",
" 0.8917045593261703],\n",
" 'success': [0, 0, 0, 0, 0],\n",
" 'error': [10, 10, 15, 20, 25]})"
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"headers = get_headers()\n",
"\n",
"\n",
"def send_rest_request(request):\n",
" res = r.post(\n",
" f\"https://{REGION}-aiplatform.googleapis.com/v1/{tf28_gpu_endpoint}:predict\",\n",
" data=request,\n",
" headers=headers,\n",
" verify=False,\n",
" )\n",
" assert res.status_code == 200\n",
" return res\n",
"\n",
"\n",
"tf28_gpu_results = benchmark(\n",
" send_rest_request,\n",
" build_rest_request,\n",
" f\"{LOCAL_MODEL_DIR}/requests/requests_10_32.jsonl\",\n",
" [1, 2, 3, 4, 5],\n",
" 5,\n",
")\n",
"\n",
"tf28_gpu_results"
]
},
{
"cell_type": "code",
"execution_count": 50,
"id": "4dc8ab23-1813-4301-ae92-b999d7979c0d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:benchmarking at 1 QPS, sending 10 requests\n",
"INFO:tensorflow:Running benchmark at 1 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:received 10 responses.\n",
"INFO:tensorflow:num_qps:1 requests/second: 1.00 #success:0 #error:10 latencies: [avg:0.34ms p50:0.27ms p90:0.60ms p99:0.63ms]\n",
"INFO:tensorflow:benchmarking at 2 QPS, sending 10 requests\n",
"INFO:tensorflow:Running benchmark at 2 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:num_qps:2 requests/second: 2.00 #success:0 #error:10 latencies: [avg:0.32ms p50:0.26ms p90:0.46ms p99:0.62ms]\n",
"INFO:tensorflow:benchmarking at 3 QPS, sending 15 requests\n",
"INFO:tensorflow:Running benchmark at 3 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:num_qps:3 requests/second: 3.00 #success:0 #error:15 latencies: [avg:0.32ms p50:0.26ms p90:0.52ms p99:0.62ms]\n",
"INFO:tensorflow:benchmarking at 4 QPS, sending 20 requests\n",
"INFO:tensorflow:Running benchmark at 4 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:num_qps:4 requests/second: 3.99 #success:0 #error:20 latencies: [avg:0.30ms p50:0.26ms p90:0.39ms p99:0.64ms]\n",
"INFO:tensorflow:benchmarking at 5 QPS, sending 25 requests\n",
"INFO:tensorflow:Running benchmark at 5 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:num_qps:5 requests/second: 4.99 #success:0 #error:25 latencies: [avg:0.30ms p50:0.25ms p90:0.78ms p99:1.14ms]\n",
"INFO:tensorflow:benchmarking at 6 QPS, sending 30 requests\n",
"INFO:tensorflow:Running benchmark at 6 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:num_qps:6 requests/second: 5.99 #success:0 #error:30 latencies: [avg:0.18ms p50:0.12ms p90:0.29ms p99:0.67ms]\n",
"INFO:tensorflow:benchmarking at 7 QPS, sending 35 requests\n",
"INFO:tensorflow:Running benchmark at 7 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:num_qps:7 requests/second: 6.99 #success:0 #error:35 latencies: [avg:0.17ms p50:0.18ms p90:0.29ms p99:0.65ms]\n",
"INFO:tensorflow:benchmarking at 8 QPS, sending 40 requests\n",
"INFO:tensorflow:Running benchmark at 8 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:num_qps:8 requests/second: 7.99 #success:0 #error:40 latencies: [avg:0.34ms p50:0.27ms p90:0.61ms p99:0.70ms]\n",
"INFO:tensorflow:benchmarking at 9 QPS, sending 45 requests\n",
"INFO:tensorflow:Running benchmark at 9 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:num_qps:9 requests/second: 8.98 #success:0 #error:45 latencies: [avg:0.36ms p50:0.27ms p90:0.60ms p99:0.64ms]\n",
"INFO:tensorflow:benchmarking at 10 QPS, sending 50 requests\n",
"INFO:tensorflow:Running benchmark at 10 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:num_qps:10 requests/second: 9.98 #success:0 #error:50 latencies: [avg:0.22ms p50:0.26ms p90:0.30ms p99:0.89ms]\n"
]
},
{
"data": {
"text/plain": [
"defaultdict(list,\n",
" {'reqested_qps': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],\n",
" 'actual_qps': [0.9988864200088217,\n",
" 1.997598293144067,\n",
" 2.9961337389353244,\n",
" 3.994600917672566,\n",
" 4.992526275163532,\n",
" 5.990180757336857,\n",
" 6.988187586700395,\n",
" 7.985983843454074,\n",
" 8.984993107148929,\n",
" 9.980267438456147],\n",
" 'avg_latency': [0.3353595733642578,\n",
" 0.3162384033203125,\n",
" 0.31762123107910156,\n",
" 0.29555559158325195,\n",
" 0.29839515686035156,\n",
" 0.17777283986409506,\n",
" 0.1730987003871373,\n",
" 0.33721923828125,\n",
" 0.35749541388617617,\n",
" 0.2232217788696289],\n",
" 'p50': [0.2655982971191406,\n",
" 0.26428699493408203,\n",
" 0.2636909484863281,\n",
" 0.26285648345947266,\n",
" 0.2543926239013672,\n",
" 0.12433528900146484,\n",
" 0.18072128295898438,\n",
" 0.2690553665161133,\n",
" 0.2715587615966797,\n",
" 0.2554655075073242],\n",
" 'p90': [0.5975961685180664,\n",
" 0.458693504333496,\n",
" 0.5248546600341796,\n",
" 0.39420127868652377,\n",
" 0.7801532745361331,\n",
" 0.2889633178710938,\n",
" 0.2853870391845703,\n",
" 0.6131887435913086,\n",
" 0.5972385406494141,\n",
" 0.3047466278076172],\n",
" 'p99': [0.6313920021057129,\n",
" 0.6207203865051271,\n",
" 0.6157016754150391,\n",
" 0.6397843360900879,\n",
" 1.1397552490234375,\n",
" 0.6668758392333985,\n",
" 0.6463527679443357,\n",
" 0.6954407691955566,\n",
" 0.6371402740478516,\n",
" 0.8882355690002433],\n",
" 'success': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
" 'error': [10, 10, 15, 20, 25, 30, 35, 40, 45, 50]})"
]
},
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"headers = get_headers()\n",
"\n",
"\n",
"def send_rest_request(request):\n",
" res = r.post(\n",
" f\"https://{REGION}-aiplatform.googleapis.com/v1/{tf_opt_gpu_endpoint}:predict\",\n",
" data=request,\n",
" headers=headers,\n",
" verify=False,\n",
" )\n",
" assert res.status_code == 200\n",
" return res\n",
"\n",
"\n",
"tf_opt_gpu_results = benchmark(\n",
" send_rest_request,\n",
" build_rest_request,\n",
" f\"{LOCAL_MODEL_DIR}/requests/requests_10_32.jsonl\",\n",
" [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],\n",
" 5,\n",
")\n",
"\n",
"tf_opt_gpu_results"
]
},
{
"cell_type": "code",
"execution_count": 51,
"id": "4467d381-a19b-4c33-98d1-8f8b0ea000a5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:benchmarking at 1 QPS, sending 10 requests\n",
"INFO:tensorflow:Running benchmark at 1 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:received 10 responses.\n",
"INFO:tensorflow:num_qps:1 requests/second: 1.00 #success:0 #error:10 latencies: [avg:0.30ms p50:0.27ms p90:0.33ms p99:0.58ms]\n",
"INFO:tensorflow:benchmarking at 5 QPS, sending 25 requests\n",
"INFO:tensorflow:Running benchmark at 5 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:num_qps:5 requests/second: 4.99 #success:0 #error:25 latencies: [avg:0.23ms p50:0.24ms p90:0.52ms p99:1.00ms]\n",
"INFO:tensorflow:benchmarking at 10 QPS, sending 50 requests\n",
"INFO:tensorflow:Running benchmark at 10 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:num_qps:10 requests/second: 9.98 #success:0 #error:50 latencies: [avg:0.14ms p50:0.04ms p90:0.27ms p99:0.87ms]\n",
"INFO:tensorflow:benchmarking at 15 QPS, sending 75 requests\n",
"INFO:tensorflow:Running benchmark at 15 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:num_qps:15 requests/second: 14.96 #success:0 #error:75 latencies: [avg:0.14ms p50:0.04ms p90:0.29ms p99:0.86ms]\n",
"INFO:tensorflow:benchmarking at 20 QPS, sending 100 requests\n",
"INFO:tensorflow:Running benchmark at 20 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:num_qps:20 requests/second: 19.94 #success:0 #error:100 latencies: [avg:0.12ms p50:0.04ms p90:0.28ms p99:0.63ms]\n",
"INFO:tensorflow:benchmarking at 21 QPS, sending 105 requests\n",
"INFO:tensorflow:Running benchmark at 21 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:num_qps:21 requests/second: 20.94 #success:0 #error:105 latencies: [avg:0.33ms p50:0.04ms p90:0.29ms p99:0.65ms]\n",
"INFO:tensorflow:benchmarking at 22 QPS, sending 110 requests\n",
"INFO:tensorflow:Running benchmark at 22 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:num_qps:22 requests/second: 21.94 #success:0 #error:110 latencies: [avg:0.17ms p50:0.04ms p90:0.48ms p99:0.67ms]\n",
"INFO:tensorflow:benchmarking at 23 QPS, sending 115 requests\n",
"INFO:tensorflow:Running benchmark at 23 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:num_qps:23 requests/second: 22.93 #success:0 #error:115 latencies: [avg:0.17ms p50:0.04ms p90:0.54ms p99:0.68ms]\n",
"INFO:tensorflow:benchmarking at 24 QPS, sending 120 requests\n",
"INFO:tensorflow:Running benchmark at 24 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:num_qps:24 requests/second: 23.93 #success:0 #error:120 latencies: [avg:0.16ms p50:0.04ms p90:0.52ms p99:0.68ms]\n",
"INFO:tensorflow:benchmarking at 25 QPS, sending 125 requests\n",
"INFO:tensorflow:Running benchmark at 25 qps\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"name 'r' is not defined\n",
"INFO:tensorflow:num_qps:25 requests/second: 24.91 #success:0 #error:125 latencies: [avg:0.15ms p50:0.04ms p90:0.29ms p99:0.72ms]\n"
]
},
{
"data": {
"text/plain": [
"defaultdict(list,\n",
" {'reqested_qps': [1, 5, 10, 15, 20, 21, 22, 23, 24, 25],\n",
" 'actual_qps': [0.9988656052532046,\n",
" 4.992522234158652,\n",
" 9.980418477122322,\n",
" 14.964420512409697,\n",
" 19.94308691664755,\n",
" 20.940827726828378,\n",
" 21.937771123476345,\n",
" 22.93165397167941,\n",
" 23.925615780406833,\n",
" 24.912406629199157],\n",
" 'avg_latency': [0.30303001403808594,\n",
" 0.2335071563720703,\n",
" 0.1437520980834961,\n",
" 0.14041900634765625,\n",
" 0.12353658676147461,\n",
" 0.3323078155517578,\n",
" 0.16604553569446912,\n",
" 0.167896436608356,\n",
" 0.16114115715026855,\n",
" 0.1512012481689453],\n",
" 'p50': [0.26869773864746094,\n",
" 0.23937225341796875,\n",
" 0.04029273986816406,\n",
" 0.040531158447265625,\n",
" 0.03993511199951172,\n",
" 0.04076957702636719,\n",
" 0.04470348358154297,\n",
" 0.04172325134277344,\n",
" 0.042438507080078125,\n",
" 0.039577484130859375],\n",
" 'p90': [0.33054351806640614,\n",
" 0.5188941955566412,\n",
" 0.27430057525634766,\n",
" 0.28672218322753923,\n",
" 0.2783775329589844,\n",
" 0.2945423126220703,\n",
" 0.48184394836425837,\n",
" 0.5406379699707037,\n",
" 0.5233764648437501,\n",
" 0.28672218322753906],\n",
" 'p99': [0.5843019485473634,\n",
" 1.00111961364746,\n",
" 0.8677244186401358,\n",
" 0.8563232421875013,\n",
" 0.6256604194641141,\n",
" 0.6508445739746094,\n",
" 0.6688451766967772,\n",
" 0.680384635925293,\n",
" 0.6778383255004884,\n",
" 0.7153034210205081],\n",
" 'success': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
" 'error': [10, 25, 50, 75, 100, 105, 110, 115, 120, 125]})"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"headers = get_headers()\n",
"\n",
"\n",
"def send_rest_request(request):\n",
" res = r.post(\n",
" f\"https://{REGION}-aiplatform.googleapis.com/v1/{tf_opt_lossy_gpu_endpoint}:predict\",\n",
" data=request,\n",
" headers=headers,\n",
" verify=False,\n",
" )\n",
" assert res.status_code == 200\n",
" return res\n",
"\n",
"\n",
"tf_opt_lossy_gpu_results = benchmark(\n",
" send_rest_request,\n",
" build_rest_request,\n",
" f\"{LOCAL_MODEL_DIR}/requests/requests_10_32.jsonl\",\n",
" [1, 5, 10, 15, 20, 21, 22, 23, 24, 25],\n",
" 5,\n",
")\n",
"\n",
"tf_opt_lossy_gpu_results"
]
},
{
"cell_type": "code",
"execution_count": 55,
"id": "001e74a9-b717-4263-8c82-a3e4e8826e60",
"metadata": {},
"outputs": [],
"source": [
"import matplotlib\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"\n",
"def build_graph(x_key, y_key, results_dict, axis):\n",
" matplotlib.rcParams[\"figure.figsize\"] = [10.0, 7.0]\n",
"\n",
" fig, ax = plt.subplots(facecolor=(1, 1, 1))\n",
" ax.set_xlabel(\"QPS\")\n",
" ax.set_ylabel(\"Latency(ms)\")\n",
" for title, results in results_dict.items():\n",
" x = np.array(results[x_key])\n",
" y = np.array(results[y_key])\n",
" ax.plot(x, y, label=title)\n",
" ax.legend()\n",
" ax.axis(axis)\n",
" ax.set_title(f\"BERT base model {y_key} latency, batch size 32\")\n",
" return fig"
]
},
{
"cell_type": "code",
"execution_count": 56,
"id": "8932b151-ed51-4f6e-910a-5f979e710bbc",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAnEAAAG5CAYAAADh3mJ8AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAA9h0lEQVR4nO3deVxVdf7H8fdlCVBQBBFQEFFIARdU3EtcBlt0cDRzNEsszcqpbLOYdEbblBybtHSaNCtLHUxTMWs0sxxzl1JLUEMFE2RcMURFWc7vD3/ekQS8InA59no+Hj6Ge873nPM5X67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qVveOOO9StWzfrq4IAeyPEAddw+cm3OnXqaPz48Zo3b16J0ZmpU6eWeDKufv36Ze6rb9++qlevnubMmXPddfTv31+LFi1SvXr19PHHH2vp0qVydnZWeHi4nn32WXXp0kW+vr768ccf1a1bN+t227dvV6dOneTu7q7Y2FjNmDFDwcHB8vDw0JdffqnExEQ1bNhQfn5+euGFF3ThwoXrru3XvL29tXLlSr3xxhvy9vbW1KlTtXLlSmvfLFy4UFu3bpWXl5deeuklDR8+3LptYGCgkpKSNHnyZPn4+CgwMFB/+9vfVFxcfEP9VFBQoAkTJsjHx0f169fX22+/reXLl1vfFefj46NPP/1U48ePV7169bR161YlJibadMyJEyfq+++/V926ddW3b18NHDiwxPo///nPevXVV+Xp6alp06bd0Dk2btxYX3zxhd544w15eXkpMjKyxAjigAEDdOjQIQ0YMKDEJevDhw+rS5cu5e77vvvuU58+fdS0aVM1bdrU+vTnU089pfPnz6t+/frq3Lmz7rzzzhLbjR07VkuWLFG9evX05JNPysPDQ2vWrNFnn30mPz8/hYaG6ptvvrnmuf1abm6uHn74YdWrV09BQUHy9vbWc889d1W7f/3rX9qyZYvq1atn/Xu4YMGC6/6OL1u2zPqU9/33368nnnjC+kqhZcuWafv27frggw9K/H2/chQZqG4W48oxfwAwsUmTJmn//v2aP3++vUuxq2bNmundd9/V7373O+uyUaNG6d5777WOPAIwPyd7FwAAqDyffvqpLBaLevXqVWL5zTRFGIBLquxy6kMPPaQGDRqoZcuW1mWnTp1STEyMQkNDFRMTo5ycHOu6KVOmKCQkRM2bN9fq1auty7/77ju1atVKISEhevLJJ8XAIQCUrkePHnrsscc0a9YsOThwtwxws6uyy6nr16+Xu7u7hg8fbr3J+vnnn5eXl5fi4+OVkJCgnJwcvf7660pNTdXQoUO1bds2HTlyRL/73e/0008/ydHRUR07dtSMGTPUuXNn3X333XryySd11113VUXJAAAAplFl/6nWvXt3eXl5lViWlJSkuLg4SVJcXJyWL19uXT5kyBC5uLgoODhYISEh2rZtm7Kzs5Wbm6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UsGHDSuzrwIED2rZtm1599VU5OFyKLD4+PnrhhReuOq6Tk5O6du2q/fv3V7j2tWvXqm3btmrVqpUeeughXbhwQZIUHx+v8PBwtW7d2hpmFy9erJYtW6pNmzbq3r27JOn2228vEXC7deumH374ocL1XAsjcQAA1GCvb3tde0/trdR9tvBqoRc6Xh2EbHE5cElScHCwli1bVmL90qVLtXPnTu3atUsnTpxQhw4drCFn27ZtSk1NVVBQkO68804tXbpUCQkJmjlzZqmjeykpKWrTpo01wJXn3LlzWrt2rV5++eUKnVd+fr5GjBihtWvX6tZbb9Xw4cP1zjvvaPjw4Vq2bJn27t0ri8Wi06dPS5JefvllrV69Wo0aNbIuGzVqlD788ENNnz5dP/30ky5cuKDWrVtXqB5bMBIHAABs5ubmpp07d2rnzp1XBThJ2rBhg4YOHSpHR0f5+voqOjpa27dvlyR17NhRTZs2laOjo4YOHaoNGzZc17Ffe+01RUZGqmHDhtZlBw4cUGRkpLp166a+ffvqrrvuksViKXX7spZL0r59+xQcHKxbb71VkhQXF6f169erTp06cnV11ahRo7R06VLVqlVL0qVRthEjRmjOnDkqKiqSJN17771auXKlCgoK9P7772vEiBHXdX7Xi5E4AABqsIqOmNlLeVOy/zpElReqJCk8PFy7du1ScXGxHBwcNH78eI0fP17u7u7WNpfvibuSt7e3cnJySiw7deqU6tevf911Ozk5adu2bVq7dq0SExM1c+ZMff311/rnP/+prVu36vPPP1dkZKR27twpb29vxcTEKCkpSZ988kmVz+HOSBwAAKg03bt316JFi1RUVKTjx49r/fr16tixo6RLl1PT09NVXFysRYsW6bbbbpMkOTs7q6Cg4Kp9hYSEKCoqShMmTLCOduXn55cbFCUpNDRUR44c0Z49eyRJhw4d0q5du6yXgUvTokULZWRkWO+p+/jjjxUdHa28vDz98ssvuvvuuzV9+nRrYDxw4IA6deqkl19+WfXr19fhw4clXbqk+uSTT6pDhw5V/oAFI3EAAKDSDBgwQJs3b1abNm1ksVg0depU+fn5ae/everSpYvi4+P1448/Wh9ykKTRo0erdev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ccf15kzZxQTE6PIyEg9+uij9i6zRiqt7yqKabcAAABM6KYaiQMAAPitIMQBAACYECEOAADAhAhxAAAAJkSIAwAAMCFCHAD8v8zMTPXv31+hoaFq2rSpHn/8cV24cEHr1q1T3bp11bZtW4WFhemll16SdOlN68OGDVOrVq3UsmVL3XbbbcrLy7PzWQD4rSDEAYAuvex64MCB+sMf/qC0tDSlpaXp/Pnzev755yVJt99+u3bs2KHk5GTNnz9f3333nWbMmCFfX1/9+OOP2r17t+bOnStnZ2c7nwmA3wonexcAADXB119/LVdXVz344IOSJEdHR7355psKCgpSTEyMtV3t2rXVvn17HThwQNnZ2QoKCrKua968ebXXDeC3i5E4AJCUkpKi9u3bl1hWp04dNWnSRPv377cuO3nypLZs2aKIiAg99NBDev3119WlSxdNmDBBaWlp1V02gN8wRuIAQJcup5Y2YfflSW2+/fZbtW3bVg4ODoqPj7dO6Xfw4EF9+eWX+uqrr9ShQwdt3ryZeUsBVAtCHABIioiI0KefflpiWW5uro4eParmzZvr9ttv18qVK6/azt3dXQMHDtTAgQPl4OCgL774ghAHoFpwORUAJPXu3Vvnzp3TRx99JEkqKirSs88+q8cff1xubm6lbrNx40bl5ORIki5evKjU1NQS98gBQFUixAGAJIvFomXLlmnJkiUKDQ2Vt7e3HBwcNH78+DK3OXDggKKjo9WqVSu1bdtWUVFRuueee6qxagC/ZRbj8g0fAACrTZs2aejQoVq6dOlVDzwAQE1AiAMAADAhLqcCAACYECEOAADAhAhxAAAAJkSIAwAAMCFCHAAAgAkR4gAAAEzo/wARkj4eatHhRwAAAABJRU5ErkJggg==\n",
"text/plain": [
"<Figure size 720x504 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig = build_graph(\n",
" \"actual_qps\",\n",
" \"p50\",\n",
" {\n",
" \"TF2.8 GPU\": tf28_gpu_results,\n",
" \"TF opt GPU\": tf_opt_gpu_results,\n",
" \"TF opt GPU lossy\": tf_opt_lossy_gpu_results,\n",
" },\n",
" (0, 14, 0, 1000),\n",
")\n",
"fig.savefig(\"vit_p50_latency_32.png\", bbox_inches=\"tight\")"
]
},
{
"cell_type": "code",
"execution_count": 57,
"id": "a9d565f6-4f1c-45a3-a9cc-71c4d41bfac9",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAnEAAAG5CAYAAADh3mJ8AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAA9/0lEQVR4nO3deVxVdf7H8fcVCEkQBRFQEFFIARdUxK3UdDBLR0czR9PE0qxssc1isvnZquTolI1OZVmZZpimYtpoZjnmllIuiUu4Jsi4gSEqyvL9/eF4RxQQUbgcez0fD3twzznfcz7ny/XR2+9ZvjZjjBEAAAAspYqjCwAAAMDVI8QBAABYECEOAADAgghxAAAAFkSIAwAAsCBCHAAAgAUR4gALeOmllzR48GBHl1Furub8OnfurA8++KCcK7JOHddL/fr19c0335T7ca7Xd/nhhx/Wq6++eh0qAqyLEAeUoH79+nJzc5O7u7tq1qypHj166ODBg/b1Q4cO1U033SR3d3f7n+bNm0uS9u/fL5vNZl9ev359xcfHS5IiIiLsy52cnFS1alX753HjxjnkXH8PduzYoS5dusjT01MhISFasGBBofUffPCBQkJC5O7uru7du+vQoUPX5bgVFZAcxRGB9t1339Vf//rX67rP5557ToGBgapevbqCgoL0+uuv29f98ssv6t27t3x8fOTl5aU77rhDu3btuq7HB64WIQ64gi+//FLZ2dlKT0+Xr6+vHn/88ULrn3vuOWVnZ9v/bNmypdD6EydOKDs7W/PmzdOrr76q5cuXKzk52b79bbfdpilTptg/v/DCCxV5er8beXl56t27t3r27KmMjAxNmzZNgwcP1i+//CJJ+ve//60XXnhBiYmJysjIUHBwsAYOHOjgqlGRhg0bpp07dyorK0tr167V7NmzNX/+fEnn/x736tVLu3bt0uHDhxUdHa3evXs7uG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cAULFy7UiRMndPbsWU2ZMkWdOnXSf/7zH/v6Z599VidOnLD/mTFjRqH2x44dU3Z2tiZOnKiVK1cqNze3THUEBgbaf65SpYoCAgLsN95/8sknioyMVI0aNVSjRg1t27bNfvltwoQJMsYoOjpaERER+vDDDyVJBw4c0A8//GBvU6NGDX366aeFzu1Svr6+9p/d3Nwu+5ydnS1JOnTokIKCggq1DQoKUlpamg4dOqSaNWsWumx18bYHDhzQ3LlzC9W1evVqpaenX1M/ubi4aOHChVqyZIn8/Pw0adIk9e/fXwEBAZKkrl276uWXX9bdd9+toKAg1a9fXx4eHvb1JTly5IgGDBigunXrqnr16ho8ePBll4gvVppz9PPzs/9888032/v24MGDatiwYZH7HTx4sP0ezs8//1y33Xab/P39r1j/BRf3XVBQkP37dfr0aT300EMKCgpS9erV1bFjR504cUL5+flF7qekGos6t5ycnEKXgS/o0qWLHnvsMT366KPy9fXViBEjlJWVVeQ+f/vtN/Xu3VuvvvqqbrvtNkll+45Lks1mU4sWLeTm5qaxY8cWWnf06FF169ZNI0eO5J5JOBwhDiglJycn9e3bV05OTlq9evVVt33mmWdUtWpV/fOf/yzT8S9+KragoECpqamqU6eODhw4oAcffFBTpkzR8ePHdeLECTVp0kTGGEnn/4f5/vvv69ChQ3rvvfc0cuRI7d69W4GBgerUqVOhAJqdna133nmnTPVd7EJdF/v1119Vt25d+fv7KzMzU6dOnSq07oLAwEDdd999heo6deqU4uLiSnXs4vpJkpo1a6Z///vfOn78uJYtW6a9e/cqOjravv2jjz6qlJQUHTlyRHfffbfy8vLUpEmTKx7zL3/5i2w2m7Zu3aqsrCzNmjXL3v/S+VBwsWs5x8DAwGLv06tbt67atWunBQsWaObMmbrvvvuuuL+LXdx3v/76q73fJk2apF27dumHH35QVlaWVq1aJUn2cyzq/EpzL2FpPPHEE/rxxx+VnJysX375RX/7298u26agoED33nuvbr/9dj300EOF6riW73heXl6h88jMzFS3bt3Uq1cvjRkz5tpPDrhGhDiglIwxSkxMVGZmpsLCwsq0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VrpxdffFEpKSkVXTaA3zFG4gBA5y+nFjVh94VJbb7//nu1aNFCVapUUVxcnH1Kv7179+rrr7/WN998o9atW2vdunXMWwqgQhDiAEBSRESEvvjii0LLsrKydPjwYTVq1Ei33XabFi9efFk7d3d39e3bV3379lWVKlX01VdfEeIAVAgupwKApK5du+r06dP65JNPJEn5+fl65pln9Nhjj8nNza3INmvWrFFmZqYk6dy5c9q+fXuhe+QAoDwR4gBAks1m04IFCzRv3jyFhobK29tbVapU0ZgxY4pts2fPHnXq1ElNmzZVixYtFBUVpbvvvrsCqwbwe2YzF274AADYrV27VgMHDtT8+fMve+ABACoDQhwAAIAFcTkVAADAgghxAAAAFkSIAwAAsCBCHAAAgAUR4gAAACyIEAcAAGBB/w8ATarConr3ngAAAABJRU5ErkJggg==\n",
"text/plain": [
"<Figure size 720x504 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig = build_graph(\n",
" \"actual_qps\",\n",
" \"p99\",\n",
" {\n",
" \"TF2.7 GPU\": tf28_gpu_results,\n",
" \"TF opt GPU\": tf_opt_gpu_results,\n",
" \"TF opt GPU lossy\": tf_opt_lossy_gpu_results,\n",
" },\n",
" (0, 14, 0, 1000),\n",
")\n",
"fig.savefig(\"vit_p99_latency_32.png\", bbox_inches=\"tight\")"
]
},
{
"cell_type": "markdown",
"id": "791fcd11",
"metadata": {},
"source": [
"## Cleaning up of resources"
]
},
{
"cell_type": "code",
"execution_count": 58,
"id": "bf18cd91-29af-4bc3-8cb9-ded65aba40e6",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"running undeploy_model operation: projects/29880397572/locations/us-central1/endpoints/4481143201884798976/operations/1548701229104758784\n",
"\n",
"running delete_endpoint operation: projects/29880397572/locations/us-central1/operations/6826919992382980096\n",
"\n",
"running delete_model operation: projects/29880397572/locations/us-central1/operations/54350577747886080\n",
"\n",
"running undeploy_model operation: projects/29880397572/locations/us-central1/endpoints/4848186571515494400/operations/4032436423599587328\n",
"\n",
"running delete_endpoint operation: projects/29880397572/locations/us-central1/operations/6160387247532146688\n",
"\n",
"running delete_model operation: projects/29880397572/locations/us-central1/operations/3931949856913883136\n",
"\n",
"running undeploy_model operation: projects/29880397572/locations/us-central1/endpoints/7782176175631106048/operations/3733791473309581312\n",
"\n",
"running delete_endpoint operation: projects/29880397572/locations/us-central1/operations/5858646072498323456\n",
"\n",
"running delete_model operation: projects/29880397572/locations/us-central1/operations/4994799368973320192\n",
"\n"
]
}
],
"source": [
"def cleanup(endpoint, model_name, deployed_model_id):\n",
" response = endpoint_service_client.undeploy_model(\n",
" endpoint=endpoint, deployed_model_id=deployed_model_id\n",
" )\n",
" print(\"running undeploy_model operation:\", response.operation.name)\n",
" print(response.result())\n",
"\n",
" response = endpoint_service_client.delete_endpoint(name=endpoint)\n",
" print(\"running delete_endpoint operation:\", response.operation.name)\n",
" print(response.result())\n",
"\n",
" response = model_service_client.delete_model(name=model_name)\n",
" print(\"running delete_model operation:\", response.operation.name)\n",
" print(response.result())\n",
"\n",
"\n",
"cleanup(tf28_gpu_endpoint, tf28_gpu_model, tf28_gpu_deployed_model.deployed_model.id)\n",
"\n",
"cleanup(\n",
" tf_opt_gpu_endpoint, tf_opt_gpu_model, tf_opt_gpu_deployed_model.deployed_model.id\n",
")\n",
"cleanup(\n",
" tf_opt_lossy_gpu_endpoint,\n",
" tf_opt_lossy_gpu_model,\n",
" tf_opt_lossy_gpu_deployed_model.deployed_model.id,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 59,
"id": "d33a0d9f-4f56-408f-8fb5-d7e327b66029",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Removing gs://hf-tf-vision/keras_metadata.pb#1658220109884993...\n",
"Removing gs://hf-tf-vision/saved_model.pb#1658220109970261... \n",
"Removing gs://hf-tf-vision/assets.extra/tf_serving_warmup_requests#1658220107785769...\n",
"Removing gs://hf-tf-vision/variables/variables.data-00000-of-00001#1658220112658544...\n",
"/ [4 objects] \n",
"==> NOTE: You are performing a sequence of gsutil operations that may\n",
"run significantly faster if you instead use gsutil -m rm ... Please\n",
"see the -m section under \"gsutil help options\" for further information\n",
"about when gsutil -m can be advantageous.\n",
"\n",
"Removing gs://hf-tf-vision/variables/variables.index#1658220109910689...\n",
"/ [5 objects] \n",
"Operation completed over 5 objects. \n",
"Removing gs://hf-tf-vision/...\n"
]
}
],
"source": [
"!gsutil rm -r $GCS_BUCKET"
]
}
],
"metadata": {
"environment": {
"kernel": "python3",
"name": "tf2-gpu.2-9.m94",
"type": "gcloud",
"uri": "gcr.io/deeplearning-platform-release/tf2-gpu.2-9:m94"
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment