{"record":{"id":"b81f03039a8403dd","repo":"Lightning-AI/pytorch-lightning","slug":"cluster-environment-set-through-both-strategy-clas","errorCode":null,"errorMessage":"cluster_environment set through both strategy class and plugins, choose one","messagePattern":"cluster_environment set through both strategy class and plugins, choose one","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/fabric/connector.py","lineNumber":278,"sourceCode":"        # checkpoint io or cluster env set up\n        # TODO: improve the error messages below\n        if isinstance(self._strategy_flag, Strategy):\n            if self._strategy_flag._accelerator:\n                if self._accelerator_flag != \"auto\":\n                    raise ValueError(\"accelerator set through both strategy class and accelerator flag, choose one\")\n                self._accelerator_flag = self._strategy_flag._accelerator\n            if self._strategy_flag._precision:\n                # [RFC] handle precision plugin set up conflict?\n                if self._precision_instance:\n                    raise ValueError(\"precision set through both strategy class and plugins, choose one\")\n                self._precision_instance = self._strategy_flag._precision\n            if self._strategy_flag._checkpoint_io:\n                if self.checkpoint_io:\n                    raise ValueError(\"checkpoint_io set through both strategy class and plugins, choose one\")\n                self.checkpoint_io = self._strategy_flag._checkpoint_io\n            if getattr(self._strategy_flag, \"cluster_environment\", None):\n                if self._cluster_environment_flag:\n                    raise ValueError(\"cluster_environment set through both strategy class and plugins, choose one\")\n                self._cluster_environment_flag = getattr(self._strategy_flag, \"cluster_environment\")\n\n            if hasattr(self._strategy_flag, \"parallel_devices\") and self._strategy_flag.parallel_devices:\n                if self._strategy_flag.parallel_devices[0].type == \"cpu\":\n                    if self._accelerator_flag and self._accelerator_flag not in (\"auto\", \"cpu\"):\n                        raise ValueError(\n                            f\"CPU parallel_devices set through {self._strategy_flag.__class__.__name__} class,\"\n                            f\" but accelerator set to {self._accelerator_flag}, please choose one device type\"\n                        )\n                    self._accelerator_flag = \"cpu\"\n                if self._strategy_flag.parallel_devices[0].type == \"cuda\":\n                    if self._accelerator_flag and self._accelerator_flag not in (\"auto\", \"cuda\", \"gpu\"):\n                        raise ValueError(\n                            f\"GPU parallel_devices set through {self._strategy_flag.__class__.__name__} class,\"\n                            f\" but accelerator set to {self._accelerator_flag}, please choose one device type\"\n                        )\n                    self._accelerator_flag = \"cuda\"\n                self._parallel_devices = self._strategy_flag.parallel_devices","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/fabric/connector.py#L260-L296","documentation":"A Strategy instance already carries a `cluster_environment` attribute, but a ClusterEnvironment plugin was also passed via `plugins` (setting _cluster_environment_flag). Fabric refuses to choose between two cluster environment specifications.","triggerScenarios":"Fabric(strategy=DDPStrategy(cluster_environment=SLURMEnvironment(...)), plugins=[SLURMEnvironment(...)]) — any strategy with a non-None cluster_environment plus a ClusterEnvironment plugin.","commonSituations":"SLURM/Kubernetes workflows where cluster env is baked into the strategy and later a plugin is added; reusable cluster-launch strategy objects combined with cluster-env plugins; migrating launcher scripts.","solutions":["Remove the ClusterEnvironment plugin from `plugins` and keep it in the strategy","Or construct the Strategy without cluster_environment and pass it via `plugins`"],"exampleFix":"# before\nstrategy = DDPStrategy(cluster_environment=SLURMEnvironment())\nfabric = Fabric(strategy=strategy, plugins=[SLURMEnvironment()])\n\n# after\nstrategy = DDPStrategy()\nfabric = Fabric(strategy=strategy, plugins=[SLURMEnvironment()])","handlingStrategy":"validation","validationCode":"from lightning.fabric.plugins import ClusterEnvironment\n\nif isinstance(strategy, Strategy) and getattr(strategy, \"cluster_environment\", None) and any(\n    isinstance(p, ClusterEnvironment) for p in plugins\n):\n    raise SystemExit(\"cluster_environment defined in both strategy and plugins\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In SLURM/K8s launchers, configure cluster environment in one place only","Log which component supplies the cluster environment before constructing Fabric"],"tags":["lightning","fabric","strategy","cluster-environment","plugins","conflicting-arguments"],"backgroundTag":"conflicting-config-arguments","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}