tracel-ai/burn · error
BURN_DEVICE=cuda requested, but the 'cuda' feature is not en
Error message
BURN_DEVICE=cuda requested, but the 'cuda' feature is not enabled.
What it means
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.
Source
Thrown at crates/burn-dispatch/src/device.rs:235
#[allow(unreachable_code)]
fn default() -> Self {
// TODO: which priority?
// Single override e.g. `BURN_DEVICE=vulkan` forces Vulkan or panics if not available.
// Priority list e.g. `BURN_DEVICE_PRIORITY=cuda,vulkan,cpu` sets the order.
// Both could be tied into `burn.toml` config
// For now we just use `BURN_DEVICE` on CI to force a single device
#[cfg(feature = "std")]
{
if let Ok(device_str) = std::env::var("BURN_DEVICE") {
match device_str.to_lowercase().as_str() {
// Every cubecl runtime is the one `Cube` backend; the name here
// picks the runtime the device names, and the wgpu spellings all
// reach wgpu, whose compiler is chosen for it at runtime.
"cuda" => {
#[cfg(feature = "cuda")]
return Self::Cube(CubeDevice::Cuda(Default::default()));
panic!(
"BURN_DEVICE=cuda requested, but the 'cuda' feature is not enabled."
);
}
"rocm" => {
#[cfg(feature = "rocm")]
return Self::Cube(CubeDevice::Hip(Default::default()));
panic!(
"BURN_DEVICE=rocm requested, but the 'rocm' feature is not enabled."
);
}
"metal" | "vulkan" | "webgpu" | "wgpu" => {
#[cfg(any(
feature = "metal",
feature = "vulkan",
feature = "webgpu",
feature = "wgpu"
))]
return Self::Cube(CubeDevice::Wgpu(Default::default()));View on GitHub (pinned to d16f7ba2ed)
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.
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/burn-dispatch/src/device.rs:235 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/afdabb80fa107898.
Report an issue: GitHub.