Shortcuts

LightningTrainerScript

class lightning_app.components.training.LightningTrainerScript(script_path, script_args=None, num_nodes=1, cloud_compute=CloudCompute(name='default', disk_size=0, idle_timeout=None, shm_size=0, mounts=None, _internal_id='default'), sanity_serving=False, script_runner=<class 'lightning_app.components.training.PyTorchLightningScriptRunner'>, **script_runner_kwargs)[source]

Bases: lightning_app.core.flow.LightningFlow

This component enables performing distributed multi-node multi-device training.

Example:

from lightning_app import LightningApp
from lightning_app.components.training import LightningTrainerScript
from lightning_app.utilities.packaging.cloud_compute import CloudCompute

app = LightningApp(
    LightningTrainerScript(
        "train.py",
        num_nodes=2,
        cloud_compute=CloudCompute("gpu"),
    ),
)
Parameters
  • script_path (str) – Path to the script to be executed.

  • script_args (Union[list, str, None]) – The arguments to be pass to the script.

  • num_nodes (int) – Number of nodes.

  • cloud_compute (CloudCompute) – The cloud compute object used in the cloud.

  • sanity_serving (bool) – Whether to validate that the model correctly implements the ServableModule API

run(**run_kwargs)[source]

Override with your own logic.