disable somas when variable_memory_max_size is set

This commit is contained in:
laiyongqiang 2020-11-05 20:02:01 +08:00
parent a5b0d13141
commit 6b57cc705f
3 changed files with 10 additions and 9 deletions

View File

@ -675,13 +675,16 @@ void KernelRuntime::AssignDynamicMemory(session::KernelGraph *graph) {
if (is_enable_mem_reuse) {
MS_LOG(INFO) << "Memory Reuse is enable...";
#ifdef MEM_REUSE_DEBUG
mem_manager_->MallocReusedDynamicMem(graph);
mem_type = kReuseDynamicMem;
#else
mem_manager_->MallocSomasDynamicMem(graph);
mem_type = kSomasReuseDynamicMem;
#endif
auto context = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(context);
auto variable_memory_max_size = context->get_param<std::string>(MS_CTX_VARIABLE_MEMORY_MAX_SIZE);
if (variable_memory_max_size == "0") {
mem_manager_->MallocSomasDynamicMem(graph);
mem_type = kSomasReuseDynamicMem;
} else {
mem_manager_->MallocReusedDynamicMem(graph);
mem_type = kReuseDynamicMem;
}
} else {
MS_LOG(INFO) << "Memory Reuse is disable...";
}

View File

@ -145,7 +145,6 @@ def run_pretrain():
context.set_context(mode=context.GRAPH_MODE, device_target=args_opt.device_target,
device_id=args_opt.device_id, save_graphs=False)
context.set_context(reserve_class_name_in_scope=False)
context.set_context(variable_memory_max_size="30GB")
context.set_context(max_call_depth=3000)
ckpt_save_dir = args_opt.save_checkpoint_path
if args_opt.distribute == "true":

View File

@ -70,7 +70,6 @@ def run_general_distill():
raise Exception("Target error, GPU or Ascend is supported.")
context.set_context(reserve_class_name_in_scope=False)
context.set_context(variable_memory_max_size="30GB")
save_ckpt_dir = os.path.join(args_opt.save_ckpt_path,
datetime.datetime.now().strftime('%Y-%m-%d_time_%H_%M_%S'))