Skip to content

Disable cudnn option #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions src/libtorch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class ModelState : public BackendModel {
return enable_jit_executor_pair_;
}
bool EnabledInferenceMode() { return enable_inference_mode_; }
bool EnabledCudnn() { return enable_cudnn_; }
bool EnabledCacheCleaning() { return enable_cache_cleaning_; }

bool EnabledWeightSharing() { return enable_weight_sharing_; }
Expand All @@ -119,6 +120,9 @@ class ModelState : public BackendModel {
// Flag to indicate whether inference mode is enabled. Defaults to false.
bool enable_inference_mode_;

// Flag to indicate whether cudnn is enabled. Defaults to true.
bool enable_cudnn_;

// Flag to indicate whether cache cleaning after each run is enabled.
// Defaults to false.
bool enable_cache_cleaning_;
Expand Down Expand Up @@ -221,8 +225,9 @@ ModelState::Create(TRITONBACKEND_Model* triton_model, ModelState** state)

ModelState::ModelState(TRITONBACKEND_Model* triton_model)
: BackendModel(triton_model), enable_optimized_execution_(true),
enable_inference_mode_(true), enable_cache_cleaning_(false),
enable_weight_sharing_(false), enable_tensor_fuser_pair_({false, true}),
enable_inference_mode_(true), enable_cudnn_(true),
enable_cache_cleaning_(false), enable_weight_sharing_(false),
enable_tensor_fuser_pair_({false, true}),
enable_jit_profiling_pair_({false, true}),
enable_jit_executor_pair_({false, true})
{
Expand Down Expand Up @@ -387,6 +392,24 @@ ModelState::ParseParameters()
" for model instance '" + Name() + "'")
.c_str());

// If 'DISABLE_CUDNN' is not present in 'parameters' then no update is made
// to 'enable_cudnn_'.
bool disable_cudnn = false;
err = ParseParameter(params, "DISABLE_CUDNN", &disable_cudnn);
if (err != nullptr) {
if (TRITONSERVER_ErrorCode(err) != TRITONSERVER_ERROR_NOT_FOUND) {
return err;
} else {
TRITONSERVER_ErrorDelete(err);
}
}
enable_cudnn_ = !disable_cudnn;
LOG_MESSAGE(
TRITONSERVER_LOG_INFO,
(std::string("cuDNN is ") + (enable_cudnn_ ? "enabled" : "disabled") +
" for model instance '" + Name() + "'")
.c_str());

// If 'ENABLE_TENSOR_FUSER' is not present in 'parameters' then no
// update is made to 'enable_tensor_fuser'.
bool enable_tensor_fuser = false;
Expand Down Expand Up @@ -1508,6 +1531,9 @@ ModelInstanceState::Execute(
// enable/disable inference mode - supersedes NoGradGuard
torch::InferenceMode infer_guard(model_state_->EnabledInferenceMode());

// enable/disable cudnn
at::globalContext().setUserEnabledCuDNN(model_state_->EnabledCudnn());

// JIT. No change is made unless parameter is explicitly set.
if (std::get<0>(model_state_->EnabledJitProfiling())) {
torch::jit::getProfilingMode() =
Expand Down