fix: catch all exceptions when importing cupy, not just ImportError
An installed-but-broken cupy (e.g. incompatible with NumPy 2.5, which removed the 'bool8' alias) raises a TypeError during its own import, not an ImportError. The narrow `except ImportError` guard let that propagate and crashed the entire node import chain. Broaden the guard to `except Exception` in all three CUDA-kernel modules so any import-time failure disables cupy and falls back to the pure-PyTorch implementations. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -15,8 +15,11 @@ def _ensure_cupy():
|
||||
try:
|
||||
import cupy as _cupy
|
||||
cupy = _cupy
|
||||
except ImportError:
|
||||
pass # cupy unavailable; PyTorch fallback will be used
|
||||
except Exception:
|
||||
# Broad catch: an installed-but-broken cupy (e.g. incompatible
|
||||
# NumPy) raises non-ImportError exceptions at import time. Treat any
|
||||
# failure as "cupy unavailable"; the PyTorch fallback will be used.
|
||||
pass
|
||||
|
||||
|
||||
##########################################################
|
||||
|
||||
@@ -11,7 +11,10 @@
|
||||
import collections
|
||||
try:
|
||||
import cupy
|
||||
except ImportError:
|
||||
except Exception:
|
||||
# Broad catch: an installed-but-broken cupy (e.g. incompatible NumPy)
|
||||
# raises non-ImportError exceptions at import time. Treat any failure as
|
||||
# "cupy unavailable" and fall back to the pure-PyTorch implementation.
|
||||
cupy = None
|
||||
import os
|
||||
import re
|
||||
|
||||
@@ -3,7 +3,10 @@
|
||||
import collections
|
||||
try:
|
||||
import cupy
|
||||
except ImportError:
|
||||
except Exception:
|
||||
# Broad catch: an installed-but-broken cupy (e.g. incompatible NumPy)
|
||||
# raises non-ImportError exceptions at import time. Treat any failure as
|
||||
# "cupy unavailable" and fall back to the pure-PyTorch implementation.
|
||||
cupy = None
|
||||
import os
|
||||
import re
|
||||
|
||||
Reference in New Issue
Block a user