sgl-project/sglang · critical · RuntimeError
LMCache is not installed. Please install it by running `pip
Error message
LMCache is not installed. Please install it by running `pip install lmcache`
What it means
Module-level import of lmcache.integration.sglang (connectors, LoadMetadata/StoreMetadata, lmcache_get_config) failed with ImportError, which is re-raised as RuntimeError telling the user to pip install lmcache. Since the import is at module scope, merely importing lmc_radix_cache triggers it.
Source
Thrown at python/sglang/srt/mem_cache/storage/lmcache/lmc_radix_cache.py:31
EvictResult,
InitLoadBackParams,
MatchPrefixParams,
MatchResult,
)
from sglang.srt.mem_cache.radix_cache import RadixCache, RadixKey, TreeNode
from sglang.srt.runtime_context import get_memory, get_spec
from sglang.srt.utils import create_device_stream, device_stream_context
try:
from lmcache.integration.sglang.multi_process_adapter import LMCacheMPConnector
from lmcache.integration.sglang.sglang_adapter import (
LMCacheLayerwiseConnector,
LoadMetadata,
StoreMetadata,
)
from lmcache.integration.sglang.utils import lmcache_get_config
except ImportError as e:
raise RuntimeError(
"LMCache is not installed. Please install it by running `pip install lmcache`"
) from e
if TYPE_CHECKING:
from sglang.srt.configs.model_config import ModelConfig
from sglang.srt.managers.schedule_batch import Req
from sglang.srt.mem_cache.cache_init_params import CacheInitParams
logger = logging.getLogger(__name__)
@dataclass
class _LMCacheLoadBackMarker:
"""Carries the data ``init_load_back`` needs from the
``match_prefix`` call in MP mode.
"""
View on GitHub (pinned to 0132848349)
Solutions
- pip install lmcache in the same interpreter that runs SGLang (python -m pip install lmcache)
- Verify with: python -c "from lmcache.integration.sglang.utils import lmcache_get_config"
- If that fails with a deeper ImportError, reinstall lmcache matching your Python/torch versions
Defensive patterns
Strategy: validation
Validate before calling
try:
from lmcache.integration.sglang.utils import lmcache_get_config # noqa: F401
LMCACHE_OK = True
except ImportError:
LMCACHE_OK = False
assert LMCACHE_OK, 'pip install lmcache in this interpreter' Type guard
def lmcache_available() -> bool:
try:
import lmcache.integration.sglang # noqa: F401
return True
except ImportError:
return False Try / catch
try:
from sglang.srt.mem_cache.storage.lmcache.lmc_radix_cache import LMCacheRadixCache
except RuntimeError as e:
if 'LMCache is not installed' in str(e):
raise SystemExit('install lmcache before enabling --enable-lmcache')
raise Prevention
- Install lmcache into the exact venv/conda env running sglang and verify with python -c import
- Gate the --enable-lmcache flag on an availability check in launch tooling
When it happens
Trigger: Importing LMCacheRadixCache (or any module importing lmc_radix_cache) in a Python environment where lmcache is not installed or its sglang integration extras are missing.
Common situations: Enabling LMCache without installing the package; lmcache installed for a different Python interpreter than the one running the scheduler (common in venv/conda mixups); broken lmcache install where the top package imports but integration submodule does not.
Related errors
- hf3fs_fuse.io is not available. Please install the hf3fs_fus
- Sparse Video Gen 2 attention backend requires svg package to
- Humming quantization requires `humming-kernels`. Please inst
- Please install mooncake by following the instructions at htt
- The fastokens package is required when --tokenizer-backend=f
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/ae61433b4c79b2e5.
Report an issue: GitHub.