• Docs >
  • Customize your Cloud Compute

Customize your Cloud Compute

Audience: Users who want to select the hardware to run in the cloud.

Level: Intermediate

Customize my Work resources

In the cloud, you can simply configure which machine to run on by passing a CloudCompute to your work __init__ method:

import lightning as L

# Run on a free, shared CPU machine. This is the default for every LightningWork.

# Run on a dedicated, medium-size CPU machine (see specs below)

# Run on cheap GPU machine with a single GPU (see specs below)

# Run on a fast multi-GPU machine (see specs below)

Here is the full list of supported machine names:

Hardware by Accelerator Type


# of CPUs






4 GB




8 GB




32 GB



1 (T4, 16 GB)

16 GB



1 (V100, 16 GB)

61 GB



4 (V100 16 GB)

244 GB

The up-to-date prices for these instances can be found here.

Run on spot/preemptible machine

Most cloud provider offers preemptible (synonym of spot) machines that are usually discounted by up to 90 %. Those machines are cheaper but the cloud provider can retrieve them at any time and might take longer to be ready.

import lightning as L

# Run on a single CPU
MyCustomWork(cloud_compute=L.CloudCompute("gpu", preemptible=True))

Stop my work when idle

By providing idle_timeout=X Seconds, the work is automatically stopped X seconds after doing nothing.

import lightning as L

# Run on a single CPU and turn down immediately when idle.
MyCustomWork(cloud_compute=L.CloudCompute("gpu", idle_timeout=0))


class lightning_app.utilities.packaging.cloud_compute.CloudCompute(name='default', disk_size=0, clusters=None, preemptible=False, wait_timeout=None, idle_timeout=None, shm_size=0)[source]

Bases: object

  • name (str) – The name of the hardware to use. A full list of supported options can be found in Customize your Cloud Compute. If you have a request for more hardware options, please contact onprem@lightning.ai.

  • disk_size (int) – The disk size in Gigabytes. The value you set here will be allocated to the /home folder.

  • clusters (Union[str, List[str], None]) – Name of the cluster or a list of cluster names. The cluster(s) must already exist. If multiple clusters are provided, we try one by one until we can allocate the resources we need in the order they were provided. Cluster default to the Grid Default Cluster.

  • preemptible (bool) – Whether to use a preemptible / spot instance. If none are available at the moment, we will wait forever or up to the specified timeout (see wait_timeout argument). Default: False (on-demand instance)

  • wait_timeout (Optional[int]) – The number of seconds to wait before giving up on the getting the requested compute. If used in combination with spot instance (spot preemptible=True) and the timeout is reached, falls back to regular instance type and waits again for this amount.

  • idle_timeout (Optional[int]) – The number of seconds to wait before pausing the compute when the work is running and idle. This timeout starts whenever your run() method succeeds (or fails). If the timeout is reached, the instance pauses until the next run() call happens.

  • shm_size (Optional[int]) – Shared memory size in MiB, backed by RAM. min 512, max 8192, it will auto update in steps of 512. For example 1100 will become 1024. If set to zero (the default) will get the default 64MiB inside docker.