Skip to content

Commit

Permalink
[Bugfix][Vulkan] Call VulkanDeviceAPI destructor on program exit
Browse files Browse the repository at this point in the history
Most of the TVM Global() functions allocate with "new" and do
not deallocate, as the OS can clean up any leftover buffers at
the end.  In this case, we need the VulkanDeviceAPI destructor
to call vkDestroyInstance, to prevent a segfault on exit when
using some nvidia drivers.
  • Loading branch information
Lunderberg committed May 6, 2021
1 parent 9bf213d commit c94c86a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/runtime/vulkan/vulkan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,13 @@ class VulkanDeviceAPI final : public DeviceAPI {
}

static VulkanDeviceAPI* Global() {
static VulkanDeviceAPI* inst = new VulkanDeviceAPI();
return inst;
// Most of the TVM Global() functions allocate with "new" and do
// not deallocate, as the OS can clean up any leftover buffers at
// the end. In this case, we need the VulkanDeviceAPI destructor
// to call vkDestroyInstance, to prevent a segfault on exit when
// using some nvidia drivers.
static VulkanDeviceAPI inst;
return &inst;
}

const VulkanContext& context(size_t device_id) const {
Expand Down

0 comments on commit c94c86a

Please sign in to comment.