diff --git a/benchmark/cpp/flags.h b/benchmark/cpp/flags.h index 049c066ac..b6e77cea5 100755 --- a/benchmark/cpp/flags.h +++ b/benchmark/cpp/flags.h @@ -63,7 +63,10 @@ DEFINE_int32(device_id, -1, DEFINE_bool(enable_log_info, false, "Optional, whether to enable log info for paddle backend," "default false."); - +DEFINE_int32(max_workspace_size, -1, + "Optional, set max workspace size for tensorrt, default -1." + "will force to override the value in config file " + "eg, 2147483647(2GB)"); static void PrintUsage() { std::cout << "Usage: infer_demo --model model_path --image img_path " "--config_path config.txt[Path of benchmark config.] " diff --git a/benchmark/cpp/option.h b/benchmark/cpp/option.h index 18054587c..fbecdfe9a 100755 --- a/benchmark/cpp/option.h +++ b/benchmark/cpp/option.h @@ -34,6 +34,11 @@ static void UpdateBaseCustomFlags( if (FLAGS_xpu_l3_cache >= 0) { config_info["xpu_l3_cache"] = std::to_string(FLAGS_xpu_l3_cache); } + if (FLAGS_max_workspace_size > 0) { + config_info["max_workspace_size"] = std::to_string(FLAGS_max_workspace_size); + } else { + config_info["max_workspace_size"] = "-1"; + } // update custom options for paddle backend if (FLAGS_enable_log_info) { config_info["enable_log_info"] = "true"; @@ -60,6 +65,11 @@ static bool CreateRuntimeOption(fastdeploy::RuntimeOption* option, if (config_info["enable_log_info"] == "true") { option->paddle_infer_option.enable_log_info = true; } + if (config_info["max_workspace_size"] != "-1") { + int max_workspace_size = std::stoi(config_info["max_workspace_size"]); + option->paddle_infer_option.trt_option.max_workspace_size = max_workspace_size; + option->trt_option.max_workspace_size = max_workspace_size; + } if (config_info["device"] == "gpu") { option->UseGpu(std::stoi(config_info["device_id"])); if (config_info["backend"] == "ort") { diff --git a/benchmark/paddlex/benchmark_gpu_trt.sh b/benchmark/paddlex/benchmark_gpu_trt.sh index 4a677bedb..82942c974 100755 --- a/benchmark/paddlex/benchmark_gpu_trt.sh +++ b/benchmark/paddlex/benchmark_gpu_trt.sh @@ -19,7 +19,7 @@ fi # PaddleDetection ./benchmark_ppdet --model rt_detr_hgnetv2_l --image ppdet_det_img.jpg --config_path $CONFIG_PATH -./benchmark_ppdet --model dino_r50_4scale --image ppdet_det_img_800x800.jpg --config_path $CONFIG_PATH --trt_shape 1,3,800,800:1,3,800,800:1,3,800,800 +./benchmark_ppdet --model dino_r50_4scale --image ppdet_det_img_800x800.jpg --config_path $CONFIG_PATH --trt_shape 1,3,800,800:1,3,800,800:1,3,800,800 --max_workspace_size 2147483647 ./benchmark_ppdet --model PP-PicoDet_s_320_lcnet --image ppdet_det_img.jpg --config_path $CONFIG_PATH --trt_shape 1,3,320,320:1,3,320,320:1,3,320,320 ./benchmark_ppdet --model PP-PicoDet_s_320_lcnet_with_nms --image ppdet_det_img.jpg --config_path $CONFIG_PATH --trt_shape 1,3,320,320:1,3,320,320:1,3,320,320 ./benchmark_ppdet --model PP-PicoDet_s_320_lcnet_without_nms --image ppdet_det_img.jpg --config_path $CONFIG_PATH --trt_shape 1,3,320,320:1,3,320,320:1,3,320,320 --no_nms