OpenBMB/VoxCPM · error · ValueError

triton is not installed

Error message

triton is not installed

What it means

optimize() depends on triton for compiled kernels; if the import fails on a CUDA setup, it raises ValueError('triton is not installed') from the ImportError.

Source

Thrown at src/voxcpm/model/voxcpm.py:238

        # 投影层
        if cfg.enable_proj:
            from ..modules.layers.lora import LoRALinear

            for attr_name in cfg.target_proj_modules:
                module = getattr(self, attr_name, None)
                if isinstance(module, nn.Linear):
                    setattr(self, attr_name, LoRALinear(base=module, **lora_kwargs))

    def optimize(self, disable: bool = False):
        if disable:
            return self
        try:
            if self.device != "cuda":
                raise ValueError("VoxCPMModel can only be optimized on CUDA device")
            try:
                import triton  # noqa: F401
            except ImportError:
                raise ValueError("triton is not installed")
            self.base_lm.forward_step = torch.compile(self.base_lm.forward_step, mode="reduce-overhead", fullgraph=True)
            self.residual_lm.forward_step = torch.compile(
                self.residual_lm.forward_step, mode="reduce-overhead", fullgraph=True
            )
            self._feat_encoder_raw = self.feat_encoder
            self.feat_encoder = torch.compile(self.feat_encoder, mode="reduce-overhead", fullgraph=True)
            self.feat_decoder.estimator = torch.compile(
                self.feat_decoder.estimator, mode="reduce-overhead", fullgraph=True
            )
        except Exception as e:
            print(f"Warning: torch.compile disabled - {e}", file=sys.stderr)
        return self

    def forward(
        self,
        text_tokens: torch.Tensor,
        text_mask: torch.Tensor,
        audio_feats: torch.Tensor,

View on GitHub (pinned to f5a1c6a6b9)

Solutions

  1. pip install triton (version matching your torch/CUDA)
  2. Install torch via a CUDA bundle that ships triton
  3. If triton can't be supported on your platform, keep optimize=False

Example fix

# before
# optimize=True with no triton
pip install triton
# after
model = VoxCPM(arch="v1", device="cuda", optimize=True)  # now works
Defensive patterns

Strategy: fallback

Validate before calling

try:
    import triton  # noqa
    has_triton = True
except ImportError:
    has_triton = False
optimize = optimize and has_triton

Prevention

When it happens

Trigger: Enabling optimize=True on CUDA where triton is absent — e.g. torch installed without the bundled triton, or an env where triton was uninstalled/pinned out.

Common situations: Slim Docker images, conda envs with mismatched torch/triton versions, or triton lacking support for the platform (e.g. Windows without a triton build).

Related errors


AI-assisted analysis of OpenBMB/VoxCPM@f5a1c6a6b9 (2026-08-27). Data as JSON: /api/errors/2d223368ea4ffd2f. Report an issue: GitHub.