Skip to content

Commit

Permalink
fix potential out of vram in directory processing
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed Mar 18, 2022
1 parent 3fe2504 commit f1271a2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,7 @@ int main(int argc, char** argv)
}

int total_jobs_proc = 0;
int jobs_proc_per_gpu[16] = {0};
for (int i=0; i<use_gpu_count; i++)
{
if (gpuid[i] == -1)
Expand All @@ -819,6 +820,7 @@ int main(int argc, char** argv)
else
{
total_jobs_proc += jobs_proc[i];
jobs_proc_per_gpu[gpuid[i]] += jobs_proc[i];
}
}

Expand All @@ -836,6 +838,12 @@ int main(int argc, char** argv)

uint32_t heap_budget = ncnn::get_gpu_device(gpuid[i])->get_heap_budget();

if (path_is_directory(inputpath) && path_is_directory(outputpath))
{
// multiple gpu jobs share the same heap
heap_budget /= jobs_proc_per_gpu[gpuid[i]];
}

// more fine-grained tilesize policy here
if (model.find(PATHSTR("models-nose")) != path_t::npos || model.find(PATHSTR("models-se")) != path_t::npos)
{
Expand Down

0 comments on commit f1271a2

Please sign in to comment.