{"record":{"id":"afdabb80fa107898","repo":"tracel-ai/burn","slug":"burn-device-cuda-requested-but-the-cuda-feature","errorCode":null,"errorMessage":"BURN_DEVICE=cuda requested, but the 'cuda' feature is not enabled.","messagePattern":"BURN_DEVICE=cuda requested, but the 'cuda' feature is not enabled\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-dispatch/src/device.rs","lineNumber":235,"sourceCode":"    #[allow(unreachable_code)]\n    fn default() -> Self {\n        // TODO: which priority?\n        // Single override e.g. `BURN_DEVICE=vulkan` forces Vulkan or panics if not available.\n        // Priority list e.g. `BURN_DEVICE_PRIORITY=cuda,vulkan,cpu` sets the order.\n        // Both could be tied into `burn.toml` config\n        // For now we just use `BURN_DEVICE` on CI to force a single device\n\n        #[cfg(feature = \"std\")]\n        {\n            if let Ok(device_str) = std::env::var(\"BURN_DEVICE\") {\n                match device_str.to_lowercase().as_str() {\n                    // Every cubecl runtime is the one `Cube` backend; the name here\n                    // picks the runtime the device names, and the wgpu spellings all\n                    // reach wgpu, whose compiler is chosen for it at runtime.\n                    \"cuda\" => {\n                        #[cfg(feature = \"cuda\")]\n                        return Self::Cube(CubeDevice::Cuda(Default::default()));\n                        panic!(\n                            \"BURN_DEVICE=cuda requested, but the 'cuda' feature is not enabled.\"\n                        );\n                    }\n                    \"rocm\" => {\n                        #[cfg(feature = \"rocm\")]\n                        return Self::Cube(CubeDevice::Hip(Default::default()));\n                        panic!(\n                            \"BURN_DEVICE=rocm requested, but the 'rocm' feature is not enabled.\"\n                        );\n                    }\n                    \"metal\" | \"vulkan\" | \"webgpu\" | \"wgpu\" => {\n                        #[cfg(any(\n                            feature = \"metal\",\n                            feature = \"vulkan\",\n                            feature = \"webgpu\",\n                            feature = \"wgpu\"\n                        ))]\n                        return Self::Cube(CubeDevice::Wgpu(Default::default()));","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-dispatch/src/device.rs#L217-L253","documentation":"Environment/feature mismatch guard at backend selection: `ReadDevice::default()` parses `BURN_DEVICE`; the `cuda` arm returns a CUDA device only when the `cuda` cargo feature is compiled in, otherwise it panics. It fires at runtime when the env var requests a backend the binary was not built with — the input at fault is the `BURN_DEVICE` value versus the crate's enabled features.","triggerScenarios":"Thrown at crates/burn-dispatch/src/device.rs:235 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rebuild with the `cuda` feature enabled (e.g. `burn = { features = [\"cuda\"] }`).","Remove/unset `BURN_DEVICE` or set it to a backend the build supports.","Check CI/deployment scripts that export BURN_DEVICE and align them with the compiled feature set."],"exampleFix":null,"handlingStrategy":"fallback","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"}