{"record":{"id":"3e71e2f050d975db","repo":"tracel-ai/burn","slug":"failed-to-write-weights-3e71e2","errorCode":null,"errorMessage":"Failed to write weights","messagePattern":"Failed to write weights","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-train/src/metric/vision/fid/weights.rs","lineNumber":28,"sourceCode":"\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.*\"\n    let mut store = PytorchStore::from_file(&cache_path)","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-train/src/metric/vision/fid/weights.rs#L10-L46","documentation":"I/O guard in the FID metric's weight downloader: writing the downloaded Inception weights bytes into the newly created cache file failed (e.g., disk full or file removed mid-write), so the download path panics.","triggerScenarios":"Thrown at crates/burn-train/src/metric/vision/fid/weights.rs:28 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify sufficient disk space for the weights file","Check the cache directory was not deleted concurrently","Retry the download after resolving the filesystem issue"],"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"}