pytorch
runtime_error
ai_generated
true
RuntimeError: torch.compile cache corrupted: invalid key hash for compiled module
ID: pytorch/compiler-cache-corruption
90%Fix Rate
85%Confidence
1Evidence
2024-03-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| torch>=2.1.0 | active | — | — | — |
| torch>=2.2.0 | active | — | — | — |
Root Cause
The on-disk cache directory for torch.compile (default ~/.cache/torch/compile) contains stale or corrupted files due to version mismatch or incomplete writes.
generic中文
torch.compile的磁盘缓存目录(默认~/.cache/torch/compile)包含因版本不匹配或写入不完整而导致的陈旧或损坏文件。
Official Documentation
https://pytorch.org/docs/stable/compile/caching.htmlWorkarounds
-
99% success Clear the torch.compile cache: rm -rf ~/.cache/torch/compile/
Clear the torch.compile cache: rm -rf ~/.cache/torch/compile/
-
95% success Disable caching entirely: torch._dynamo.config.cache_size_limit = 0
Disable caching entirely: torch._dynamo.config.cache_size_limit = 0
-
90% success Set a different cache directory: export TORCH_COMPILE_CACHE_DIR=/tmp/torch_cache
Set a different cache directory: export TORCH_COMPILE_CACHE_DIR=/tmp/torch_cache
中文步骤
Clear the torch.compile cache: rm -rf ~/.cache/torch/compile/
Disable caching entirely: torch._dynamo.config.cache_size_limit = 0
Set a different cache directory: export TORCH_COMPILE_CACHE_DIR=/tmp/torch_cache
Dead Ends
Common approaches that don't work:
-
98% fail
The cache is stored in user home directory, not in the package installation; reinstalling doesn't clear it.
-
85% fail
Debug mode only prints information but doesn't fix the corruption.