Skip to content

Commit

Permalink
register once
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed Dec 20, 2023
1 parent 4514e84 commit 4847923
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2030,7 +2030,12 @@ int create_gpu_instance(const char* driver_path)
// but it seems to be too late for nvidia driver :(
// driver's internal data structure has been destroyed when called, causing segfault
// atexit() seems to be helpful for calling it earlier --- nihui
atexit(destroy_gpu_instance);
static int destroy_gpu_instance_atexit_registered = 0;
if (!destroy_gpu_instance_atexit_registered)
{
atexit(destroy_gpu_instance);
destroy_gpu_instance_atexit_registered = 1;
}

return 0;
}
Expand Down

0 comments on commit 4847923

Please sign in to comment.