mirror of
https://github.com/ostris/ai-toolkit.git
synced 2026-01-26 16:39:47 +00:00
Do not copy pin memory if it fails, just move
This commit is contained in:
@@ -99,7 +99,10 @@ def _ensure_cpu_pinned(t: Optional[torch.Tensor]) -> Optional[torch.Tensor]:
|
||||
if t is None:
|
||||
return None
|
||||
if t.device.type != "cpu":
|
||||
t = t.to("cpu", copy=True)
|
||||
try:
|
||||
t = t.to("cpu", copy=True)
|
||||
except Exception:
|
||||
t = t.to("cpu")
|
||||
# Don't attempt to pin quantized tensors; many backends don't support it
|
||||
if _is_quantized_tensor(t):
|
||||
return t
|
||||
|
||||
Reference in New Issue
Block a user