{"record":{"id":"bf3364c4e74c67ed","repo":"tracel-ai/burn","slug":"failed-to-create-cache-file-bf3364","errorCode":null,"errorMessage":"Failed to create cache file","messagePattern":"Failed to create cache file","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-train/src/metric/vision/fid/weights.rs","lineNumber":27,"sourceCode":"const INCEPTION_WEIGHTS_URL: &str = \"https://github.com/mseitzer/pytorch-fid/releases/download/fid_weights/pt-inception-2015-12-05-6726825d.pth\";\n\nfn get_cache_dir() -> PathBuf {\n    let cache_dir = dirs::cache_dir()\n        .expect(\"Could not get cache directory\")\n        .join(\"burn-dataset\")\n        .join(\"fid\");\n\n    if !cache_dir.exists() {\n        create_dir_all(&cache_dir).expect(\"Failed to create cache directory\");\n    }\n\n    cache_dir\n}\n\nfn download_if_needed(url: &str, cache_path: &PathBuf, message: &str) {\n    if !cache_path.exists() {\n        let bytes = download_file_as_bytes(url, message);\n        let mut file = File::create(cache_path).expect(\"Failed to create cache file\");\n        file.write_all(&bytes).expect(\"Failed to write weights\");\n    }\n}\n\n/// Download and load pretrained pytorch-fid InceptionV3 weights.\n///\n/// Weights are cached in `~/.cache/burn-dataset/fid/`.\npub fn load_pretrained_weights(mut fid: Fid) -> Fid {\n    let cache_dir = get_cache_dir();\n    let cache_path = cache_dir.join(\"pt-inception-2015-12-05-6726825d.pth\");\n\n    download_if_needed(\n        INCEPTION_WEIGHTS_URL,\n        &cache_path,\n        \"Downloading InceptionV3 weights for FID...\",\n    );\n\n    // PyTorch keys use \"Conv2d_1a_3x3.*\" etc, our model nests them under \"extractor.*\"","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-train/src/metric/vision/fid/weights.rs#L9-L45","documentation":"I/O guard in the FID metric's weight downloader: creating the cache file (in the burn-dataset/fid cache dir) to store downloaded Inception weights failed, so the download path panics rather than continue without cached weights.","triggerScenarios":"Thrown at crates/burn-train/src/metric/vision/fid/weights.rs:27 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check permissions and free space in the system cache directory","Ensure `dirs::cache_dir()` resolves to a writable location","Pre-place the weights file in the cache path to skip downloading"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}