Overview
Ray is an open-source framework for scaling Python and AI applications. It pairs a core distributed runtime with a set of higher-level AI libraries, so you can run the same code on a laptop and then on a cluster without rewriting it or managing extra infrastructure yourself.
It is aimed at Python and ML engineers who hit the limits of a single machine. The core gives you three building blocks: Tasks (stateless functions run across the cluster), Actors (stateful worker processes), and Objects (immutable values shared across the cluster). On top of that sit libraries for data, training, tuning, reinforcement learning, and serving.
As a compute-orchestration tool, Ray runs on any machine, cloud provider, or Kubernetes. It fits teams that want one way to distribute training, hyperparameter tuning, batch data jobs, and online model serving rather than stitching together separate systems for each.
What it does
- Core distributed runtime with three primitives: Tasks (stateless functions), Actors (stateful workers), and Objects (shared immutable values)
- Ray Data for scalable datasets and batch processing across a cluster
- Ray Train for distributed model training
- Ray Tune for scalable hyperparameter tuning
- Ray Serve for programmable model and application serving, plus RLlib for reinforcement learning
- Runs on any machine, cloud provider, or Kubernetes, with a Ray Dashboard and distributed debugger for monitoring
Getting started
Install Ray from PyPI, then use the core API to run Python functions across the cluster.
Install Ray
Install the package from PyPI. For nightly wheels, see the Ray installation page in the docs.
pip install rayRun a task on the cluster
Decorate a Python function with @ray.remote to turn it into a Task, call it with .remote(), and collect results with ray.get(). Ray starts a local runtime automatically when you call ray.init().
import ray
ray.init()
@ray.remote
def square(x):
return x * x
futures = [square.remote(i) for i in range(4)]
print(ray.get(futures)) # [0, 1, 4, 9]Explore the AI libraries
Once Ray Core works, layer on the higher-level libraries (Data, Train, Tune, RLlib, Serve) for distributed data processing, training, tuning, and serving. See the Ray documentation for each library's quickstart.
Commands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Scale an existing Python script from a laptop to a cluster without rewriting it for new infrastructure
- Run distributed model training and hyperparameter tuning with Ray Train and Ray Tune
- Process large datasets in parallel with Ray Data as a batch compute layer
- Serve models and applications online with Ray Serve
How Ray compares
Ray alongside other open-source gpu & compute clouds tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| Daytona | ★ 72.2k | Daytona is an open-source runtime that spins up isolated sandboxes in under 90ms so agents can safely run and persist AI-generated code. |
| Ray | ★ 43.2k | Scale Python and ML workloads from a laptop to a cluster with one framework |
| Prefect | ★ 23.3k | A Python-native workflow orchestration tool for scheduling, running, and monitoring data and ML pipelines. |
| Dagster | ★ 15.8k | A data and ML pipeline orchestrator with a declarative asset model, built-in lineage, and observability. |
| Kubeflow | ★ 15.8k | A Kubernetes toolkit that brings together pipelines, notebooks, and training operators for running ML workflows at scale. |
| E2B | ★ 13k | E2B is open-source infrastructure that runs AI-generated code inside secure, isolated cloud sandboxes, controlled from JavaScript or Python SDKs. |
| OpenSandbox | ★ 12k | OpenSandbox gives AI agents a safe place to run code and commands, with one unified API across Docker and Kubernetes runtimes and SDKs in five languages. |
| SkyPilot | ★ 10.3k | A framework that runs AI jobs across clouds and Kubernetes, automatically finding and provisioning the cheapest available GPUs. |