{"record":{"id":"a699bc6021cfcb51","repo":"hiyouga/LlamaFactory","slug":"megatron-bridge-is-not-installed-please-install-i","errorCode":null,"errorMessage":"megatron-bridge is not installed. Please install it with `pip install --no-build-isolation megatron-bridge` or use the NeMo Framework container.","messagePattern":"megatron-bridge is not installed\\. Please install it with `pip install --no-build-isolation megatron-bridge` or use the NeMo Framework container\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/train/megatron_bridge/workflow.py","lineNumber":98,"sourceCode":"        os.makedirs(sync_dir, exist_ok=True)\n        if os.path.isfile(done_file):\n            os.remove(done_file)\n        work()\n        with open(done_file, \"w\", encoding=\"utf-8\") as f:\n            f.write(\"done\")\n\n    if dist_ready:\n        dist.barrier()\n    elif not is_main:\n        while True:\n            if os.path.isfile(done_file) and os.path.getmtime(done_file) >= wait_start - 1.0:\n                break\n            time.sleep(0.5)\n\n\ndef _check_backend_available() -> None:\n    if not is_megatron_bridge_available():\n        raise ImportError(\n            \"megatron-bridge is not installed. \"\n            \"Please install it with `pip install --no-build-isolation megatron-bridge` \"\n            \"or use the NeMo Framework container.\"\n        )\n    _patch_dataset_helper_compilation()\n    _patch_dist_checkpoint_preload()\n\n\ndef _patch_dist_checkpoint_preload() -> None:\n    r\"\"\"Use blocking GPU->CPU copies when saving distributed checkpoints.\n\n    Megatron's default ``non_blocking=True`` preload can raise ``cudaErrorInvalidValue``\n    on some GPUs (e.g. V100) when saving distributed optimizer shards, because pinned\n    host memory allocation or async D2H transfer may fail under memory pressure.\n    \"\"\"\n    from megatron.core.dist_checkpointing.strategies import filesystem_async\n\n    if getattr(filesystem_async.FileSystemWriterAsync.preload_tensors, \"_llamafactory_patched\", False):","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/train/megatron_bridge/workflow.py#L80-L116","documentation":"Error \"megatron-bridge is not installed. Please install it with `pip install --no-build-isolation megatron-bridge` or use the NeMo Framework container.\" thrown in hiyouga/LlamaFactory.","triggerScenarios":"Thrown at src/llamafactory/train/megatron_bridge/workflow.py:98 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Install megatron-bridge: pip install --no-build-isolation megatron-bridge.","Alternatively run inside the NVIDIA NeMo Framework container which ships megatron-bridge."],"exampleFix":"pip install --no-build-isolation megatron-bridge","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}