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:
|
try:
|
||||||
import cupy as _cupy
|
import cupy as _cupy
|
||||||
cupy = _cupy
|
cupy = _cupy
|
||||||
except ImportError:
|
except Exception:
|
||||||
pass # cupy unavailable; PyTorch fallback will be used
|
# 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
|
import collections
|
||||||
try:
|
try:
|
||||||
import cupy
|
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
|
cupy = None
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|||||||
@@ -3,7 +3,10 @@
|
|||||||
import collections
|
import collections
|
||||||
try:
|
try:
|
||||||
import cupy
|
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
|
cupy = None
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|||||||
Reference in New Issue
Block a user