{"record":{"id":"1280b3bd24b03fe6","repo":"Lightning-AI/pytorch-lightning","slug":"torch-distributed-is-not-available","errorCode":null,"errorMessage":"Torch distributed is not available.","messagePattern":"Torch distributed is not available\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"src/lightning/fabric/plugins/collectives/torch_collective.py","lineNumber":32,"sourceCode":"    from torch.distributed.constants import default_pg_timeout\nelse:\n    default_pg_timeout = datetime.timedelta(seconds=1800)\n\n\nclass TorchCollective(Collective):\n    \"\"\"Collective operations using `torch.distributed <https://pytorch.org/docs/stable/distributed.html>`__.\n\n    .. warning:: This is an :ref:`experimental <versioning:Experimental API>` feature which is still in development.\n\n    \"\"\"\n\n    manages_default_group = False\n    addr_key = \"MASTER_ADDR\"\n    port_key = \"MASTER_PORT\"\n\n    def __init__(self) -> None:\n        if not dist.is_available():\n            raise RuntimeError(\"Torch distributed is not available.\")\n        super().__init__()\n\n    @property\n    @override\n    def group(self) -> CollectibleGroup:\n        if self._group is None:\n            self._group = dist.GroupMember.WORLD\n        return super().group\n\n    @property\n    @override\n    def rank(self) -> int:\n        # local rank\n        return dist.get_rank(self.group)  # type: ignore[arg-type]\n\n    @property\n    @override\n    def world_size(self) -> int:","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/fabric/plugins/collectives/torch_collective.py#L14-L50","documentation":"`TorchCollective.__init__` raises RuntimeError when `torch.distributed.is_available()` is False, i.e. the installed PyTorch build was compiled without distributed support (no NCCL/Gloo support on that platform/build).","triggerScenarios":"Constructing `TorchCollective()` under a PyTorch build lacking distributed (common on some Windows builds, very old/edge builds, or stripped-down wheels).","commonSituations":"Developing on Windows where torch.distributed has limited availability; CI using minimal torch wheels; running Fabric's distributed features on unsupported platforms.","solutions":["Install a PyTorch build with distributed support, typically the official Linux wheels: `pip install torch` from pytorch.org","Use a container/Linux environment for distributed training","If distributed is optional, fall back to non-distributed Fabric strategy when `torch.distributed.is_available()` is False"],"exampleFix":"# before\ncollective = TorchCollective()  # RuntimeError on non-distributed build\n\n# after\nimport torch.distributed as dist\nif dist.is_available():\n    collective = TorchCollective()\nelse:\n    strategy = SingleDeviceStrategy(...)  # run without distributed","handlingStrategy":"validation","validationCode":"import torch.distributed as dist\nassert dist.is_available(), 'install a torch build with distributed support'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use official Linux torch wheels for distributed work","Check dist.is_available() before enabling distributed strategies"],"tags":["pytorch-lightning","distributed","pytorch-build","platform-support"],"backgroundTag":"distributed-unavailable","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}