From 3e3ae398a57d92f386fc249a6e2d70b4e05119c8 Mon Sep 17 00:00:00 2001 From: HexToString <506181616@qq.com> Date: Mon, 17 May 2021 13:52:42 +0000 Subject: [PATCH] add batch_size --- python/examples/resnet_v2_50/benchmark.py | 8 ++++++-- python/examples/resnet_v2_50/benchmark.sh | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/python/examples/resnet_v2_50/benchmark.py b/python/examples/resnet_v2_50/benchmark.py index c0989b05..1d536443 100644 --- a/python/examples/resnet_v2_50/benchmark.py +++ b/python/examples/resnet_v2_50/benchmark.py @@ -56,9 +56,13 @@ def single_func(idx, resource): ]) image_file = "daisy.jpg" img = seq(image_file) + feed_data = np.array(img) + feed_data = np.expand_dims(feed_data, 0).repeat( + args.batch_size, axis=0) result = client.predict( - feed={"image": img}, - fetch=["save_infer_model/scale_0.tmp_0"]) + feed={"image": feed_data}, + fetch=["save_infer_model/scale_0.tmp_0"], + batch=True) l_end = time.time() if latency_flags: latency_list.append(l_end * 1000 - l_start * 1000) diff --git a/python/examples/resnet_v2_50/benchmark.sh b/python/examples/resnet_v2_50/benchmark.sh index 25ae62a2..bd4765da 100644 --- a/python/examples/resnet_v2_50/benchmark.sh +++ b/python/examples/resnet_v2_50/benchmark.sh @@ -20,7 +20,7 @@ python3.6 benchmark.py --thread 1 --batch_size 1 --model $2/serving_client_conf. echo -e "import psutil\nimport time\nwhile True:\n\tcpu_res = psutil.cpu_percent()\n\twith open('cpu.txt', 'a+') as f:\n\t\tf.write(f'{cpu_res}\\\n')\n\ttime.sleep(0.1)" > cpu.py for thread_num in 1 2 4 8 do -for batch_size in 1 +for batch_size in 1 4 8 16 32 64 do job_bt=`date '+%Y%m%d%H%M%S'` nvidia-smi --id=$gpu_id --query-compute-apps=used_memory --format=csv -lms 100 > gpu_memory_use.log 2>&1 & -- GitLab