From c9bc3235a31afee9f6e218b15358927d65017fbe Mon Sep 17 00:00:00 2001 From: dengkaipeng Date: Thu, 23 Feb 2023 14:04:49 +0000 Subject: [PATCH 01/10] update ReBind stream. test=develop --- .../fluid/inference/tests/api/CMakeLists.txt | 8 ++ .../tests/api/trt_rebind_stream_test.cc | 84 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 paddle/fluid/inference/tests/api/trt_rebind_stream_test.cc diff --git a/paddle/fluid/inference/tests/api/CMakeLists.txt b/paddle/fluid/inference/tests/api/CMakeLists.txt index a5cdfda3243eb..3c81468ef4d37 100644 --- a/paddle/fluid/inference/tests/api/CMakeLists.txt +++ b/paddle/fluid/inference/tests/api/CMakeLists.txt @@ -952,6 +952,14 @@ if(WITH_GPU AND TENSORRT_FOUND) ${INFERENCE_C_EXTRA_DEPS} ARGS --infer_model=${TRT_MODEL_INSTALL_DIR}/trt_inference_test_models) + inference_analysis_test( + trt_rebind_stream_test + SRCS + trt_rebind_stream_test.cc + EXTRA_DEPS + paddle_inference_shared + ARGS + --infer_model=${TRT_MODEL_INSTALL_DIR}/trt_inference_test_models) if(WIN32) target_link_libraries(test_analyzer_capi_exp_gpu paddle_inference_c_shared) else() diff --git a/paddle/fluid/inference/tests/api/trt_rebind_stream_test.cc b/paddle/fluid/inference/tests/api/trt_rebind_stream_test.cc new file mode 100644 index 0000000000000..963b88474df3f --- /dev/null +++ b/paddle/fluid/inference/tests/api/trt_rebind_stream_test.cc @@ -0,0 +1,84 @@ +/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ + +#include +#include + +#include "gflags/gflags.h" +#include "paddle/fluid/inference/tests/api/trt_test_helper.h" + +namespace paddle { +namespace inference { + +TEST(ReBindStream_single, use_gpu) { + std::string model_dir = FLAGS_infer_model + "/mobilenet"; + AnalysisConfig config; + config.EnableUseGpu(100, 0); + config.SetModel(model_dir); + + cudaStream_t stream1, stream2, stream3; + cudaStreamCreateWithFlags(&stream1, cudaStreamNonBlocking); + cudaStreamCreateWithFlags(&stream2, cudaStreamNonBlocking); + cudaStreamCreateWithFlags(&stream3, cudaStreamNonBlocking); + + config.SetExecStream(stream1); + auto predictor = paddle_infer::CreatePredictor(config); + auto x_t = predictor->GetInputHandle("x"); + x_t->Reshape({1, 3, 224, 224}); + float x_data[3 * 224 * 224] = {0}; + x_t->CopyFromCpu(x_data); + ASSERT_TRUE(predictor->Run()); + ASSERT_TRUE(paddle_infer::experimental::InternalUtils::RunWithExternalStream(predictor.get(), stream2)); + ASSERT_TRUE(paddle_infer::experimental::InternalUtils::RunWithExternalStream(predictor.get(), stream3)); +} + +TEST(ReBindStream_multi, use_gpu) { + std::string model_dir = FLAGS_infer_model + "/mobilenet"; + AnalysisConfig config1; + config1.EnableUseGpu(100, 0); + config1.SetModel(model_dir); + AnalysisConfig config2; + config2.EnableUseGpu(100, 0); + config2.SetModel(model_dir); + + cudaStream_t stream1, stream2, stream3; + cudaStreamCreateWithFlags(&stream1, cudaStreamNonBlocking); + cudaStreamCreateWithFlags(&stream2, cudaStreamNonBlocking); + cudaStreamCreateWithFlags(&stream3, cudaStreamNonBlocking); + + config1.SetExecStream(stream1); + config2.SetExecStream(stream1); + auto predictor1 = paddle_infer::CreatePredictor(config1); + auto predictor2 = paddle_infer::CreatePredictor(config2); + + float x_data[3 * 224 * 224] = {0}; + auto x_t1 = predictor1->GetInputHandle("x"); + x_t1->Reshape({1, 3, 224, 224}); + x_t1->CopyFromCpu(x_data); + auto x_t2 = predictor2->GetInputHandle("x"); + x_t2->Reshape({1, 3, 224, 224}); + x_t2->CopyFromCpu(x_data); + + ASSERT_TRUE(predictor1->Run()); + ASSERT_TRUE(predictor2->Run()); + + ASSERT_TRUE(paddle_infer::experimental::InternalUtils::RunWithExternalStream(predictor1.get(), stream2)); + ASSERT_TRUE(paddle_infer::experimental::InternalUtils::RunWithExternalStream(predictor2.get(), stream2)); + + ASSERT_TRUE(paddle_infer::experimental::InternalUtils::RunWithExternalStream(predictor1.get(), stream3)); + ASSERT_TRUE(paddle_infer::experimental::InternalUtils::RunWithExternalStream(predictor2.get(), stream3)); +} + +} // namespace inference +} // namespace paddle From 6725f2fa58f78dcc527e885d5ab6ea8d73d9ac3f Mon Sep 17 00:00:00 2001 From: dengkaipeng Date: Thu, 9 Mar 2023 07:41:43 +0000 Subject: [PATCH 02/10] update rebind stream support parallel. test=develop --- .../fluid/inference/api/resource_manager.cc | 69 +++++++++++-------- .../tests/api/trt_rebind_stream_test.cc | 21 ++++-- 2 files changed, 57 insertions(+), 33 deletions(-) diff --git a/paddle/fluid/inference/api/resource_manager.cc b/paddle/fluid/inference/api/resource_manager.cc index 49d33d6750abe..3c649910ca62f 100644 --- a/paddle/fluid/inference/api/resource_manager.cc +++ b/paddle/fluid/inference/api/resource_manager.cc @@ -483,22 +483,18 @@ void ResourceManager::DestroyGPUResource(void* stream) { } void ResourceManager::Decrease(void* stream) { - PADDLE_ENFORCE_EQ(ref_count_.count(stream), - true, - platform::errors::InvalidArgument( - "The stream[%p] not found in ref_count.", stream)); + LOG(ERROR) << "Decrease enter, stream " << ref_count_.count(stream); + if (ref_count_.count(stream) == 0) return; --ref_count_[stream]; + if (ref_count_[stream] == 0) { ref_count_.erase(stream); - gpu_resources_.erase(stream); + if (gpu_resources_.count(stream) > 0) gpu_resources_.erase(stream); } + LOG(ERROR) << "Decrease finish"; } void ResourceManager::Increase(void* stream) { - PADDLE_ENFORCE_EQ(ref_count_.count(stream), - true, - platform::errors::InvalidArgument( - "The stream[%p] not found in ref_count.", stream)); ++ref_count_[stream]; } @@ -512,31 +508,50 @@ GPUContextResource* ResourceManager::GetGPUResource(void* stream) const { void ResourceManager::GpuResourceReBindStream(void* old_stream, void* new_stream) { + std::lock_guard lock_gurad(gpu_mutex_); + LOG(ERROR) << "GpuResourceReBindStream enter"; + PADDLE_ENFORCE_EQ( gpu_resources_.count(old_stream), true, platform::errors::InvalidArgument( "The stream[%p] not found in gpu_resources.", old_stream)); - auto gpu_resource = std::move(gpu_resources_.at(old_stream)); - DestroyGPUResource(old_stream); - PADDLE_ENFORCE_EQ( - ref_count_.count(old_stream), - 0, - platform::errors::Fatal("gpu resources rebind stream failed.")); - - gpu_resource->ReBindStream(static_cast(new_stream)); - gpu_resource->ReBindDnnHandle(static_cast(new_stream)); - gpu_resource->ReBindBlasHandle(static_cast(new_stream)); - gpu_resource->ReBindBlasTensorCoreHandle( - static_cast(new_stream)); - gpu_resource->ReBindBlasTF32Handle(static_cast(new_stream)); - gpu_resource->ReBindSolverDnHandle(static_cast(new_stream)); - gpu_resource->ReBindSparseHandle(static_cast(new_stream)); - gpu_resource->ReBindEigenDevice(static_cast(new_stream), - gpu_resource->Place()); + + bool new_stream_existed = gpu_resources_.count(new_stream) > 0; + LOG(ERROR) << "GpuResourceReBindStream new_stream_existed " << new_stream_existed; + if (not new_stream_existed) { + if (ref_count_[old_stream] == 1) { + LOG(ERROR) << "ReBind enter"; + auto gpu_resource = std::move(gpu_resources_.at(old_stream)); + gpu_resource->ReBindStream(static_cast(new_stream)); + gpu_resource->ReBindDnnHandle(static_cast(new_stream)); + gpu_resource->ReBindBlasHandle(static_cast(new_stream)); + gpu_resource->ReBindBlasTensorCoreHandle( + static_cast(new_stream)); + gpu_resource->ReBindBlasTF32Handle( + static_cast(new_stream)); + gpu_resource->ReBindSolverDnHandle( + static_cast(new_stream)); + gpu_resource->ReBindSparseHandle( + static_cast(new_stream)); + gpu_resource->ReBindEigenDevice(static_cast(new_stream), + gpu_resource->Place()); + gpu_resources_.emplace(new_stream, std::move(gpu_resource)); + LOG(ERROR) << "ReBind finish"; + } else { + LOG(ERROR) << "new resource enter"; + auto place = gpu_resources_.at(old_stream)->Place(); + std::unique_ptr resource{ + new GPUContextResource(place, new_stream)}; + gpu_resources_.emplace(new_stream, std::move(resource)); + LOG(ERROR) << "new resource finish"; + } + } + + Decrease(old_stream); ref_count_[new_stream]++; - gpu_resources_.emplace(new_stream, std::move(gpu_resource)); + LOG(ERROR) << "GpuResourceReBindStream finish"; } int ResourceManager::RefCount(void* stream) const { diff --git a/paddle/fluid/inference/tests/api/trt_rebind_stream_test.cc b/paddle/fluid/inference/tests/api/trt_rebind_stream_test.cc index 963b88474df3f..072eaef77c9bb 100644 --- a/paddle/fluid/inference/tests/api/trt_rebind_stream_test.cc +++ b/paddle/fluid/inference/tests/api/trt_rebind_stream_test.cc @@ -48,36 +48,45 @@ TEST(ReBindStream_multi, use_gpu) { AnalysisConfig config1; config1.EnableUseGpu(100, 0); config1.SetModel(model_dir); + config1.EnableTensorRtEngine(); AnalysisConfig config2; config2.EnableUseGpu(100, 0); + config2.EnableTensorRtEngine(); config2.SetModel(model_dir); cudaStream_t stream1, stream2, stream3; - cudaStreamCreateWithFlags(&stream1, cudaStreamNonBlocking); - cudaStreamCreateWithFlags(&stream2, cudaStreamNonBlocking); - cudaStreamCreateWithFlags(&stream3, cudaStreamNonBlocking); + cudaStreamCreate(&stream1); + cudaStreamCreate(&stream2); + cudaStreamCreate(&stream3); config1.SetExecStream(stream1); config2.SetExecStream(stream1); auto predictor1 = paddle_infer::CreatePredictor(config1); auto predictor2 = paddle_infer::CreatePredictor(config2); - float x_data[3 * 224 * 224] = {0}; + std::vector x1(3 * 224 * 224, 1.0); auto x_t1 = predictor1->GetInputHandle("x"); x_t1->Reshape({1, 3, 224, 224}); - x_t1->CopyFromCpu(x_data); + x_t1->CopyFromCpu(x1.data()); + std::vector x2(3 * 224 * 224, 2.0); auto x_t2 = predictor2->GetInputHandle("x"); x_t2->Reshape({1, 3, 224, 224}); - x_t2->CopyFromCpu(x_data); + x_t2->CopyFromCpu(x2.data()); ASSERT_TRUE(predictor1->Run()); + cudaStreamSynchronize(stream1); ASSERT_TRUE(predictor2->Run()); + cudaStreamSynchronize(stream1); ASSERT_TRUE(paddle_infer::experimental::InternalUtils::RunWithExternalStream(predictor1.get(), stream2)); + cudaDeviceSynchronize(); ASSERT_TRUE(paddle_infer::experimental::InternalUtils::RunWithExternalStream(predictor2.get(), stream2)); + cudaDeviceSynchronize(); ASSERT_TRUE(paddle_infer::experimental::InternalUtils::RunWithExternalStream(predictor1.get(), stream3)); + cudaStreamSynchronize(stream3); ASSERT_TRUE(paddle_infer::experimental::InternalUtils::RunWithExternalStream(predictor2.get(), stream3)); + cudaStreamSynchronize(stream3); } } // namespace inference From 3dcbf84c4bee57d985dd967aaf53b7618c2134a6 Mon Sep 17 00:00:00 2001 From: dengkaipeng Date: Thu, 9 Mar 2023 08:00:22 +0000 Subject: [PATCH 03/10] remove log and add comments. test=develop --- paddle/fluid/inference/api/resource_manager.cc | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/paddle/fluid/inference/api/resource_manager.cc b/paddle/fluid/inference/api/resource_manager.cc index 3c649910ca62f..3d9ea455de37d 100644 --- a/paddle/fluid/inference/api/resource_manager.cc +++ b/paddle/fluid/inference/api/resource_manager.cc @@ -483,7 +483,6 @@ void ResourceManager::DestroyGPUResource(void* stream) { } void ResourceManager::Decrease(void* stream) { - LOG(ERROR) << "Decrease enter, stream " << ref_count_.count(stream); if (ref_count_.count(stream) == 0) return; --ref_count_[stream]; @@ -491,7 +490,6 @@ void ResourceManager::Decrease(void* stream) { ref_count_.erase(stream); if (gpu_resources_.count(stream) > 0) gpu_resources_.erase(stream); } - LOG(ERROR) << "Decrease finish"; } void ResourceManager::Increase(void* stream) { @@ -508,8 +506,8 @@ GPUContextResource* ResourceManager::GetGPUResource(void* stream) const { void ResourceManager::GpuResourceReBindStream(void* old_stream, void* new_stream) { + // NOTE: add lock to support stream rebind in multi-thread std::lock_guard lock_gurad(gpu_mutex_); - LOG(ERROR) << "GpuResourceReBindStream enter"; PADDLE_ENFORCE_EQ( gpu_resources_.count(old_stream), @@ -517,11 +515,13 @@ void ResourceManager::GpuResourceReBindStream(void* old_stream, platform::errors::InvalidArgument( "The stream[%p] not found in gpu_resources.", old_stream)); + // NOTE: stream may be used by multiple predictor, skip resource + // operation if resource of new_stream is already exists bool new_stream_existed = gpu_resources_.count(new_stream) > 0; - LOG(ERROR) << "GpuResourceReBindStream new_stream_existed " << new_stream_existed; if (not new_stream_existed) { if (ref_count_[old_stream] == 1) { - LOG(ERROR) << "ReBind enter"; + // NOTE: if old_stream is ref_count is 1, old_stream is only + // used by current predictor, rebind resource for new_stream auto gpu_resource = std::move(gpu_resources_.at(old_stream)); gpu_resource->ReBindStream(static_cast(new_stream)); gpu_resource->ReBindDnnHandle(static_cast(new_stream)); @@ -537,21 +537,16 @@ void ResourceManager::GpuResourceReBindStream(void* old_stream, gpu_resource->ReBindEigenDevice(static_cast(new_stream), gpu_resource->Place()); gpu_resources_.emplace(new_stream, std::move(gpu_resource)); - LOG(ERROR) << "ReBind finish"; } else { - LOG(ERROR) << "new resource enter"; auto place = gpu_resources_.at(old_stream)->Place(); std::unique_ptr resource{ new GPUContextResource(place, new_stream)}; gpu_resources_.emplace(new_stream, std::move(resource)); - LOG(ERROR) << "new resource finish"; } } Decrease(old_stream); - ref_count_[new_stream]++; - LOG(ERROR) << "GpuResourceReBindStream finish"; } int ResourceManager::RefCount(void* stream) const { From adba8b0b5381f6fec13696db6c0b1c0c93683bb8 Mon Sep 17 00:00:00 2001 From: dengkaipeng Date: Thu, 9 Mar 2023 08:00:22 +0000 Subject: [PATCH 04/10] remove log and add comments. test=develop --- .../fluid/inference/api/resource_manager.cc | 30 +++++++------------ .../tests/api/trt_rebind_stream_test.cc | 18 +++++++---- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/paddle/fluid/inference/api/resource_manager.cc b/paddle/fluid/inference/api/resource_manager.cc index 3c649910ca62f..cf5786517ad63 100644 --- a/paddle/fluid/inference/api/resource_manager.cc +++ b/paddle/fluid/inference/api/resource_manager.cc @@ -483,7 +483,6 @@ void ResourceManager::DestroyGPUResource(void* stream) { } void ResourceManager::Decrease(void* stream) { - LOG(ERROR) << "Decrease enter, stream " << ref_count_.count(stream); if (ref_count_.count(stream) == 0) return; --ref_count_[stream]; @@ -491,12 +490,9 @@ void ResourceManager::Decrease(void* stream) { ref_count_.erase(stream); if (gpu_resources_.count(stream) > 0) gpu_resources_.erase(stream); } - LOG(ERROR) << "Decrease finish"; } -void ResourceManager::Increase(void* stream) { - ++ref_count_[stream]; -} +void ResourceManager::Increase(void* stream) { ++ref_count_[stream]; } GPUContextResource* ResourceManager::GetGPUResource(void* stream) const { PADDLE_ENFORCE_EQ(gpu_resources_.count(stream), @@ -508,8 +504,8 @@ GPUContextResource* ResourceManager::GetGPUResource(void* stream) const { void ResourceManager::GpuResourceReBindStream(void* old_stream, void* new_stream) { + // NOTE: add lock to support stream rebind in multi-thread std::lock_guard lock_gurad(gpu_mutex_); - LOG(ERROR) << "GpuResourceReBindStream enter"; PADDLE_ENFORCE_EQ( gpu_resources_.count(old_stream), @@ -517,41 +513,35 @@ void ResourceManager::GpuResourceReBindStream(void* old_stream, platform::errors::InvalidArgument( "The stream[%p] not found in gpu_resources.", old_stream)); + // NOTE: stream may be used by multiple predictor, skip resource + // operation if resource of new_stream is already exists bool new_stream_existed = gpu_resources_.count(new_stream) > 0; - LOG(ERROR) << "GpuResourceReBindStream new_stream_existed " << new_stream_existed; if (not new_stream_existed) { if (ref_count_[old_stream] == 1) { - LOG(ERROR) << "ReBind enter"; + // NOTE: if old_stream is ref_count is 1, old_stream is only + // used by current predictor, rebind resource for new_stream auto gpu_resource = std::move(gpu_resources_.at(old_stream)); gpu_resource->ReBindStream(static_cast(new_stream)); gpu_resource->ReBindDnnHandle(static_cast(new_stream)); gpu_resource->ReBindBlasHandle(static_cast(new_stream)); gpu_resource->ReBindBlasTensorCoreHandle( - static_cast(new_stream)); - gpu_resource->ReBindBlasTF32Handle( - static_cast(new_stream)); - gpu_resource->ReBindSolverDnHandle( - static_cast(new_stream)); - gpu_resource->ReBindSparseHandle( - static_cast(new_stream)); + static_cast(new_stream)); + gpu_resource->ReBindBlasTF32Handle(static_cast(new_stream)); + gpu_resource->ReBindSolverDnHandle(static_cast(new_stream)); + gpu_resource->ReBindSparseHandle(static_cast(new_stream)); gpu_resource->ReBindEigenDevice(static_cast(new_stream), gpu_resource->Place()); gpu_resources_.emplace(new_stream, std::move(gpu_resource)); - LOG(ERROR) << "ReBind finish"; } else { - LOG(ERROR) << "new resource enter"; auto place = gpu_resources_.at(old_stream)->Place(); std::unique_ptr resource{ new GPUContextResource(place, new_stream)}; gpu_resources_.emplace(new_stream, std::move(resource)); - LOG(ERROR) << "new resource finish"; } } Decrease(old_stream); - ref_count_[new_stream]++; - LOG(ERROR) << "GpuResourceReBindStream finish"; } int ResourceManager::RefCount(void* stream) const { diff --git a/paddle/fluid/inference/tests/api/trt_rebind_stream_test.cc b/paddle/fluid/inference/tests/api/trt_rebind_stream_test.cc index 072eaef77c9bb..f9025fd9bc09b 100644 --- a/paddle/fluid/inference/tests/api/trt_rebind_stream_test.cc +++ b/paddle/fluid/inference/tests/api/trt_rebind_stream_test.cc @@ -39,8 +39,10 @@ TEST(ReBindStream_single, use_gpu) { float x_data[3 * 224 * 224] = {0}; x_t->CopyFromCpu(x_data); ASSERT_TRUE(predictor->Run()); - ASSERT_TRUE(paddle_infer::experimental::InternalUtils::RunWithExternalStream(predictor.get(), stream2)); - ASSERT_TRUE(paddle_infer::experimental::InternalUtils::RunWithExternalStream(predictor.get(), stream3)); + ASSERT_TRUE(paddle_infer::experimental::InternalUtils::RunWithExternalStream( + predictor.get(), stream2)); + ASSERT_TRUE(paddle_infer::experimental::InternalUtils::RunWithExternalStream( + predictor.get(), stream3)); } TEST(ReBindStream_multi, use_gpu) { @@ -78,14 +80,18 @@ TEST(ReBindStream_multi, use_gpu) { ASSERT_TRUE(predictor2->Run()); cudaStreamSynchronize(stream1); - ASSERT_TRUE(paddle_infer::experimental::InternalUtils::RunWithExternalStream(predictor1.get(), stream2)); + ASSERT_TRUE(paddle_infer::experimental::InternalUtils::RunWithExternalStream( + predictor1.get(), stream2)); cudaDeviceSynchronize(); - ASSERT_TRUE(paddle_infer::experimental::InternalUtils::RunWithExternalStream(predictor2.get(), stream2)); + ASSERT_TRUE(paddle_infer::experimental::InternalUtils::RunWithExternalStream( + predictor2.get(), stream2)); cudaDeviceSynchronize(); - ASSERT_TRUE(paddle_infer::experimental::InternalUtils::RunWithExternalStream(predictor1.get(), stream3)); + ASSERT_TRUE(paddle_infer::experimental::InternalUtils::RunWithExternalStream( + predictor1.get(), stream3)); cudaStreamSynchronize(stream3); - ASSERT_TRUE(paddle_infer::experimental::InternalUtils::RunWithExternalStream(predictor2.get(), stream3)); + ASSERT_TRUE(paddle_infer::experimental::InternalUtils::RunWithExternalStream( + predictor2.get(), stream3)); cudaStreamSynchronize(stream3); } From 09a1f9492b87b50fb297646abbe7b27113905868 Mon Sep 17 00:00:00 2001 From: dengkaipeng Date: Thu, 9 Mar 2023 12:25:09 +0000 Subject: [PATCH 05/10] fix format. test=develop --- paddle/fluid/inference/api/resource_manager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paddle/fluid/inference/api/resource_manager.cc b/paddle/fluid/inference/api/resource_manager.cc index cf5786517ad63..5dbd6aae233b0 100644 --- a/paddle/fluid/inference/api/resource_manager.cc +++ b/paddle/fluid/inference/api/resource_manager.cc @@ -516,7 +516,7 @@ void ResourceManager::GpuResourceReBindStream(void* old_stream, // NOTE: stream may be used by multiple predictor, skip resource // operation if resource of new_stream is already exists bool new_stream_existed = gpu_resources_.count(new_stream) > 0; - if (not new_stream_existed) { + if (!new_stream_existed) { if (ref_count_[old_stream] == 1) { // NOTE: if old_stream is ref_count is 1, old_stream is only // used by current predictor, rebind resource for new_stream From 545b53405213f5289411372e7f8da436e8bb18cd Mon Sep 17 00:00:00 2001 From: dengkaipeng Date: Thu, 9 Mar 2023 12:31:33 +0000 Subject: [PATCH 06/10] update test. test=develop --- paddle/fluid/inference/tests/api/trt_rebind_stream_test.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/paddle/fluid/inference/tests/api/trt_rebind_stream_test.cc b/paddle/fluid/inference/tests/api/trt_rebind_stream_test.cc index f9025fd9bc09b..0f565be3d4cb3 100644 --- a/paddle/fluid/inference/tests/api/trt_rebind_stream_test.cc +++ b/paddle/fluid/inference/tests/api/trt_rebind_stream_test.cc @@ -26,6 +26,7 @@ TEST(ReBindStream_single, use_gpu) { AnalysisConfig config; config.EnableUseGpu(100, 0); config.SetModel(model_dir); + config1.EnableTensorRtEngine(); cudaStream_t stream1, stream2, stream3; cudaStreamCreateWithFlags(&stream1, cudaStreamNonBlocking); From d39de97047c87da5e9d10084fb09467a2a4eb4b4 Mon Sep 17 00:00:00 2001 From: dengkaipeng Date: Fri, 10 Mar 2023 09:17:53 +0000 Subject: [PATCH 07/10] fix unittest. test=develop --- paddle/fluid/inference/tests/api/trt_rebind_stream_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paddle/fluid/inference/tests/api/trt_rebind_stream_test.cc b/paddle/fluid/inference/tests/api/trt_rebind_stream_test.cc index 0f565be3d4cb3..2b5e1bb1d54b4 100644 --- a/paddle/fluid/inference/tests/api/trt_rebind_stream_test.cc +++ b/paddle/fluid/inference/tests/api/trt_rebind_stream_test.cc @@ -26,7 +26,7 @@ TEST(ReBindStream_single, use_gpu) { AnalysisConfig config; config.EnableUseGpu(100, 0); config.SetModel(model_dir); - config1.EnableTensorRtEngine(); + config.EnableTensorRtEngine(); cudaStream_t stream1, stream2, stream3; cudaStreamCreateWithFlags(&stream1, cudaStreamNonBlocking); From 577e6e0c574e45a3f7f13458135bb43f8593ab7f Mon Sep 17 00:00:00 2001 From: dengkaipeng Date: Sun, 12 Mar 2023 13:29:06 +0000 Subject: [PATCH 08/10] unittest timeout 120. test=develop --- paddle/fluid/inference/tests/api/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/paddle/fluid/inference/tests/api/CMakeLists.txt b/paddle/fluid/inference/tests/api/CMakeLists.txt index 3c81468ef4d37..1f9a5d56d11d3 100644 --- a/paddle/fluid/inference/tests/api/CMakeLists.txt +++ b/paddle/fluid/inference/tests/api/CMakeLists.txt @@ -1313,6 +1313,7 @@ if(WITH_GPU) endif() if(WITH_GPU AND TENSORRT_FOUND) set_tests_properties(trt_mobilenet_test PROPERTIES TIMEOUT 120) + set_tests_properties(trt_rebind_stream_test PROPERTIES TIMEOUT 120) if(WITH_MKLDNN) set_tests_properties(test_analyzer_bfloat16_resnet50 PROPERTIES TIMEOUT 120) endif() From 851802c74c282d83492f6e192da39dc62f468c34 Mon Sep 17 00:00:00 2001 From: dengkaipeng Date: Wed, 15 Mar 2023 11:20:15 +0000 Subject: [PATCH 09/10] set unittest EXCLUSIVE. test=develop --- paddle/fluid/inference/tests/api/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/inference/tests/api/CMakeLists.txt b/paddle/fluid/inference/tests/api/CMakeLists.txt index 1f9a5d56d11d3..4417654948a8d 100644 --- a/paddle/fluid/inference/tests/api/CMakeLists.txt +++ b/paddle/fluid/inference/tests/api/CMakeLists.txt @@ -1313,7 +1313,8 @@ if(WITH_GPU) endif() if(WITH_GPU AND TENSORRT_FOUND) set_tests_properties(trt_mobilenet_test PROPERTIES TIMEOUT 120) - set_tests_properties(trt_rebind_stream_test PROPERTIES TIMEOUT 120) + set_tests_properties(trt_rebind_stream_test PROPERTIES LABELS + "RUN_TYPE=EXCLUSIVE") if(WITH_MKLDNN) set_tests_properties(test_analyzer_bfloat16_resnet50 PROPERTIES TIMEOUT 120) endif() From a589bc95e0bcde9455555424c15ecc3f3604e344 Mon Sep 17 00:00:00 2001 From: dengkaipeng Date: Wed, 15 Mar 2023 14:16:31 +0000 Subject: [PATCH 10/10] fix format. test=develop --- paddle/fluid/inference/tests/api/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/inference/tests/api/CMakeLists.txt b/paddle/fluid/inference/tests/api/CMakeLists.txt index 4417654948a8d..e1ca6219677f4 100644 --- a/paddle/fluid/inference/tests/api/CMakeLists.txt +++ b/paddle/fluid/inference/tests/api/CMakeLists.txt @@ -1313,8 +1313,8 @@ if(WITH_GPU) endif() if(WITH_GPU AND TENSORRT_FOUND) set_tests_properties(trt_mobilenet_test PROPERTIES TIMEOUT 120) - set_tests_properties(trt_rebind_stream_test PROPERTIES LABELS - "RUN_TYPE=EXCLUSIVE") + set_tests_properties(trt_rebind_stream_test PROPERTIES LABELS + "RUN_TYPE=EXCLUSIVE") if(WITH_MKLDNN) set_tests_properties(test_analyzer_bfloat16_resnet50 PROPERTIES TIMEOUT 120) endif()