Commands Cheat Sheet

Evaluating engineering tools? Get the comparison in Google Sheets

(Perfect for making buy/build decisions or internal reviews.)

Most-used commands
Your email is safe thing.

Thankyou for your submission

We have sent the cheatsheet on your email!
Oops! Something went wrong while submitting the form.

Connection and Setup

ray start --head
Start a Ray cluster as the head node

ray start --address=
Connect a worker node to an existing Ray cluster

ray stop
Stop the Ray cluster

pip install ray
Install Ray package

Basic Ray Usage

import ray
Import Ray library

ray.init()
Initialize Ray locally

ray.init(address='auto')
Connect to an existing Ray cluster

ray.shutdown()
Shutdown Ray

Task Management

@ray.remote
Decorator to define a remote function

function_name.remote()
Execute a function remotely

ray.get(object_id)
Wait for and retrieve the result of a remote function

ray.wait(object_ids)
Wait for a list of objects to be ready

ray.cancel(object_id)
Cancel a task

Actor Management

@ray.remote class ClassName
Define a remote actor class

actor = ClassName.remote()
Create an actor

actor.method.remote()
Call a method on an actor

ray.kill(actor)
Terminate an actor

Resource Management

@ray.remote(num_cpus=2, num_gpus=1)
Specify resource requirements for a task

ray.init(num_cpus=8, num_gpus=2)
Set available resources when initializing Ray

ray.available_resources()
Get available resources in the cluster

Ray Dashboard

ray dashboard
View Ray dashboard (usually at http://localhost:8265)

ray status
Check status of the Ray cluster

Ray Data

ray.data.from_items()
Create a Ray dataset from items

ray.data.read_csv()
Create a Ray dataset from CSV files

dataset.map()
Apply a function to each record in the dataset

dataset.filter()
Filter records in the dataset

dataset.groupby()
Group records by key

dataset.to_pandas()
Convert dataset to pandas DataFrame

Ray Train

from ray import train
Import Ray train module

trainer = Trainer()
Create a trainer instance

trainer.run()
Run training

Ray Tune

from ray import tune
Import Ray tune module

tune.run()
Run hyperparameter tuning

tune.grid_search()
Specify grid search for hyperparameters

tune.report()
Report metrics from training

Ray Serve

from ray import serve
Import Ray serve module

serve.start()
Start Ray Serve

serve.deployment
Decorator to define a deployment

deployment.deploy()
Deploy a service