@@ -1745,39 +1745,45 @@ void ggml_vk_instance_init() {
1745
1745
1746
1746
// Default to using all dedicated GPUs
1747
1747
for (size_t i = 0 ; i < devices.size (); i++) {
1748
- vk::PhysicalDeviceProperties props = devices[i].getProperties ();
1749
-
1750
- if (props.deviceType == vk::PhysicalDeviceType::eDiscreteGpu) {
1748
+ vk::PhysicalDeviceProperties2 new_props;
1749
+ vk::PhysicalDeviceDriverProperties new_driver;
1750
+ vk::PhysicalDeviceIDProperties new_id;
1751
+ new_props.pNext = &new_driver;
1752
+ new_driver.pNext = &new_id;
1753
+ devices[i].getProperties2 (&new_props);
1754
+
1755
+ if (new_props.properties .deviceType == vk::PhysicalDeviceType::eDiscreteGpu) {
1751
1756
// Check if there are two physical devices corresponding to the same GPU
1752
1757
auto old_device = std::find_if (
1753
1758
vk_instance.device_indices .begin (),
1754
1759
vk_instance.device_indices .end (),
1755
- [&devices, &props](const size_t k){ return devices[k].getProperties ().deviceID == props.deviceID ; }
1760
+ [&devices, &new_id](const size_t k){
1761
+ vk::PhysicalDeviceProperties2 old_props;
1762
+ vk::PhysicalDeviceIDProperties old_id;
1763
+ old_props.pNext = &old_id;
1764
+ devices[k].getProperties2 (&old_props);
1765
+ return std::equal (std::begin (old_id.deviceUUID ), std::end (old_id.deviceUUID ), std::begin (new_id.deviceUUID ));
1766
+ }
1756
1767
);
1757
1768
if (old_device == vk_instance.device_indices .end ()) {
1758
1769
vk_instance.device_indices .push_back (i);
1759
1770
} else {
1760
1771
// There can be two physical devices corresponding to the same GPU if there are 2 different drivers
1761
1772
// This can cause error when splitting layers aross the devices, need to keep only 1
1762
- VK_LOG_DEBUG (" Device " << i << " and device " << *old_device << " have the same device id " );
1773
+ VK_LOG_DEBUG (" Device " << i << " and device " << *old_device << " have the same deviceUUID " );
1763
1774
1764
- vk::PhysicalDeviceProperties2 old_prop ;
1775
+ vk::PhysicalDeviceProperties2 old_props ;
1765
1776
vk::PhysicalDeviceDriverProperties old_driver;
1766
- old_prop.pNext = &old_driver;
1767
- devices[*old_device].getProperties2 (&old_prop);
1768
-
1769
- vk::PhysicalDeviceProperties2 new_prop;
1770
- vk::PhysicalDeviceDriverProperties new_driver;
1771
- new_prop.pNext = &new_driver;
1772
- devices[i].getProperties2 (&new_prop);
1777
+ old_props.pNext = &old_driver;
1778
+ devices[*old_device].getProperties2 (&old_props);
1773
1779
1774
1780
std::map<vk::DriverId, int > driver_priorities {};
1775
1781
int old_priority = std::numeric_limits<int >::max ();
1776
1782
int new_priority = std::numeric_limits<int >::max ();
1777
1783
1778
1784
// Check https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkDriverId.html for the list of driver id
1779
1785
// Smaller number -> higher priority
1780
- switch (old_prop .properties .vendorID ) {
1786
+ switch (old_props .properties .vendorID ) {
1781
1787
case VK_VENDOR_ID_AMD:
1782
1788
driver_priorities[vk::DriverId::eMesaRadv] = 1 ;
1783
1789
driver_priorities[vk::DriverId::eAmdOpenSource] = 2 ;
0 commit comments