tracel-ai/burn · error
Failed to create cache file
Error message
Failed to create cache file
What it means
I/O guard in the LPIPS weights downloader: creating the cache file to store downloaded LPIPS backbone weights failed, so the download path panics rather than run the metric without its pretrained weights.
Source
Thrown at crates/burn-train/src/metric/vision/lpips/weights.rs:62
/// Get the cache directory for LPIPS weights.
fn get_cache_dir() -> PathBuf {
let cache_dir = dirs::cache_dir()
.expect("Could not get cache directory")
.join("burn-dataset")
.join("lpips");
if !cache_dir.exists() {
create_dir_all(&cache_dir).expect("Failed to create cache directory");
}
cache_dir
}
/// Download file if not cached and return the cache path.
fn download_if_needed(url: &str, cache_path: &PathBuf, message: &str) {
if !cache_path.exists() {
let bytes = download_file_as_bytes(url, message);
let mut file = File::create(cache_path).expect("Failed to create cache file");
file.write_all(&bytes).expect("Failed to write weights");
}
}
/// Download and load pretrained weights into an LPIPS module.
///
/// This loads both:
/// 1. ImageNet pretrained backbone weights (VGG16/AlexNet/SqueezeNet)
/// 2. LPIPS trained linear layer weights
///
/// Weights are cached in the user's cache directory to avoid re-downloading.
///
/// # Arguments
///
/// * `lpips` - The LPIPS module to load weights into.
/// * `net` - The network type (determines which weights to download).
///
/// # ReturnsView on GitHub (pinned to d16f7ba2ed)
Solutions
- Verify disk space and permissions in the lpips cache directory
- Ensure the cache path points to a writable location
- Pre-download and place the weights file at the cache path
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at crates/burn-train/src/metric/vision/lpips/weights.rs:62 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/aefb618fcd3f3298.
Report an issue: GitHub.