---
title: KubeflowEnvironment
description: >-
  Environment for distributed training using the PyTorchJob operator from
  Kubeflow.
canonical: >-
  https://lightning.ai/docs/pytorch/stable/optional-api/api/lightning.pytorch.plugins.environments.KubeflowEnvironment
---
# KubeflowEnvironment {#kubeflowenvironment}

### `class lightning.pytorch.plugins.environments.KubeflowEnvironment` {#lightning.pytorch.plugins.environments.KubeflowEnvironment}

Bases: [`ClusterEnvironment`](/docs/pytorch/2.6.6/optional-api/api/lightning.pytorch.plugins.environments.ClusterEnvironment.md#lightning.pytorch.plugins.environments.ClusterEnvironment "lightning.fabric.plugins.environments.cluster_environment.ClusterEnvironment")

Environment for distributed training using the [PyTorchJob](https://www.kubeflow.org/docs/components/trainer/legacy-v1/user-guides/pytorch/) operator from [Kubeflow](https://www.kubeflow.org).

This environment, unlike others, does not get auto-detected and needs to be passed to the Fabric/Trainer constructor manually.

#### `static detect()` {#lightning.pytorch.plugins.environments.KubeflowEnvironment.detect}

Detects the environment settings corresponding to this cluster and returns `True` if they match.

Return type:

[`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")

#### `global_rank()` {#lightning.pytorch.plugins.environments.KubeflowEnvironment.global_rank}

The rank (index) of the currently running process across all nodes and devices.

Return type:

[`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")

#### `local_rank()` {#lightning.pytorch.plugins.environments.KubeflowEnvironment.local_rank}

The rank (index) of the currently running process inside of the current node.

Return type:

[`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")

#### `node_rank()` {#lightning.pytorch.plugins.environments.KubeflowEnvironment.node_rank}

The rank (index) of the node on which the current process runs.

Return type:

[`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")

#### `world_size()` {#lightning.pytorch.plugins.environments.KubeflowEnvironment.world_size}

The number of processes across all devices and nodes.

Return type:

[`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")

#### `property creates_processes_externally: bool` {#lightning.pytorch.plugins.environments.KubeflowEnvironment.creates_processes_externally}

Whether the environment creates the subprocesses or not.

#### `property main_address: str` {#lightning.pytorch.plugins.environments.KubeflowEnvironment.main_address}

The main address through which all processes connect and communicate.

#### `property main_port: int` {#lightning.pytorch.plugins.environments.KubeflowEnvironment.main_port}

An open and configured port in the main node through which all processes communicate.

---

**Navigation**

- Parent: [Api](/docs/pytorch/2.6.6/optional-api/api.md)
