mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
[MPS] Skip virtualized devices (#111576)
Skip devices that does not support `MTLGPUFamilyMac2`, for example something called "Apple Paravirtual device", which started to appear in GitHub CI, from https://github.com/malfet/deleteme/actions/runs/6577012044/job/17867739464#step:3:18 ``` Found device Apple Paravirtual device isLowPower false supports Metal false ``` As first attempt to allocate memory on such device will fail with: ``` RuntimeError: MPS backend out of memory (MPS allocated: 0 bytes, other allocations: 0 bytes, max allowed: 1.70 GB). Tried to allocate 0 bytes on private pool. Use PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0 to disable upper limit for memory allocations (may cause system failure). ``` Fixes https://github.com/pytorch/pytorch/issues/111449 Pull Request resolved: https://github.com/pytorch/pytorch/pull/111576 Approved by: https://github.com/atalman, https://github.com/clee2000, https://github.com/huydhn
This commit is contained in:
parent
0617f7fa75
commit
ca5f6f7af3
|
|
@ -93,11 +93,18 @@ MPSDevice::MPSDevice() : _mtl_device(nil), _mtl_indexing_library(nil) {
|
|||
NSArray* devices = [MTLCopyAllDevices() autorelease];
|
||||
for (unsigned long i = 0; i < [devices count]; i++) {
|
||||
id<MTLDevice> device = devices[i];
|
||||
if (![device isLowPower]) { // exclude Intel GPUs
|
||||
if ([device isLowPower]) { // exclude Intel GPUs
|
||||
continue;
|
||||
}
|
||||
if (![device supportsFamily:MTLGPUFamilyMac2]) {
|
||||
// Exclude devices that does not support Metal 2.0
|
||||
// Virtualised MPS device on MacOS 12.6 should fail this check
|
||||
TORCH_WARN("Skipping device ", [[device name] UTF8String], " that does not support Metal 2.0");
|
||||
continue;
|
||||
}
|
||||
_mtl_device = [device retain];
|
||||
break;
|
||||
}
|
||||
}
|
||||
TORCH_INTERNAL_ASSERT_DEBUG_ONLY(_mtl_device);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user