We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 10fd636 commit 33581b0Copy full SHA for 33581b0
1 file changed
lmcache/__init__.py
@@ -5,9 +5,6 @@
5
import importlib
6
import sys
7
8
-# Third Party
9
-import torch
10
-
11
# First Party
12
from lmcache.logging import init_logger
13
@@ -21,6 +18,9 @@ def _get_backend() -> Any:
21
18
"""
22
19
Try backends in order, first successful import wins.
23
20
+ # Third Party
+ import torch
+
24
backend_candidates = [
25
(
26
"lmcache.c_ops",
@@ -70,6 +70,8 @@ def _get_backend() -> Any:
70
# --------------------------
71
# Backend instance
72
73
-_ops = _get_backend()
74
75
-sys.modules["lmcache.c_ops"] = _ops
+try:
+ _ops = _get_backend()
+ sys.modules["lmcache.c_ops"] = _ops
76
+except (ImportError, ModuleNotFoundError):
77
+ pass # torch not installed; CLI-only usage does not need CUDA ops
0 commit comments