mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
Friendly catch exception when fail to initialize XPU devices (#141658)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/141658 Approved by: https://github.com/EikanWang
This commit is contained in:
parent
60fe50aa42
commit
d905f1350a
1 changed files with 12 additions and 2 deletions
|
|
@ -44,8 +44,18 @@ void enumDevices(std::vector<std::unique_ptr<sycl::device>>& devices) {
|
|||
}
|
||||
|
||||
inline void initGlobalDevicePoolState() {
|
||||
// Enumerate all GPU devices and record them.
|
||||
enumDevices(gDevicePool.devices);
|
||||
// Attempt to initialize XPU devices. If no device is found or the driver is
|
||||
// not installed correctly, issue a warning message instead of raising an
|
||||
// exception to avoid disrupting the user experience.
|
||||
try {
|
||||
// Enumerate all GPU devices and record them.
|
||||
enumDevices(gDevicePool.devices);
|
||||
} catch (const sycl::exception& e) {
|
||||
TORCH_WARN(
|
||||
"Failed to initialize XPU devices. The driver may not be installed, installed incorrectly, or incompatible with the current setup. ",
|
||||
"Please refer to the guideline (https://github.com/pytorch/pytorch?tab=readme-ov-file#intel-gpu-support) for proper installation and configuration.");
|
||||
return;
|
||||
}
|
||||
if (gDevicePool.devices.empty()) {
|
||||
TORCH_WARN("XPU device count is zero!");
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue