Skip to main content

Ray provides a simple, universal API for building distributed applications.

Project description

https://github.com/ray-project/ray/raw/master/doc/source/images/ray_header_logo.png https://readthedocs.org/projects/ray/badge/?version=master https://img.shields.io/badge/Ray-Join%20Slack-blue https://img.shields.io/badge/Discuss-Ask%20Questions-blue https://img.shields.io/twitter/follow/raydistributed.svg?style=social&logo=twitter

Ray provides a simple, universal API for building distributed applications.

Ray is packaged with the following libraries for accelerating machine learning workloads:

  • Tune: Scalable Hyperparameter Tuning

  • RLlib: Scalable Reinforcement Learning

  • Train: Distributed Deep Learning (beta)

  • Datasets: Distributed Data Loading and Compute (beta)

As well as libraries for taking ML and distributed apps to production:

  • Serve: Scalable and Programmable Serving

  • Workflows: Fast, Durable Application Flows (alpha)

There are also many community integrations with Ray, including Dask, MARS, Modin, Horovod, Hugging Face, Scikit-learn, and others. Check out the full list of Ray distributed libraries here.

Install Ray with: pip install ray. For nightly wheels, see the Installation page.

Quick Start

Execute Python functions in parallel.

import ray
ray.init()

@ray.remote
def f(x):
    return x * x

futures = [f.remote(i) for i in range(4)]
print(ray.get(futures))

To use Ray’s actor model:

import ray
ray.init()

@ray.remote
class Counter(object):
    def __init__(self):
        self.n = 0

    def increment(self):
        self.n += 1

    def read(self):
        return self.n

counters = [Counter.remote() for i in range(4)]
[c.increment.remote() for c in counters]
futures = [c.read.remote() for c in counters]
print(ray.get(futures))

Ray programs can run on a single machine, and can also seamlessly scale to large clusters. To execute the above Ray script in the cloud, just download this configuration file, and run:

ray submit [CLUSTER.YAML] example.py --start

Read more about launching clusters.

Tune Quick Start

https://github.com/ray-project/ray/raw/master/doc/source/images/tune-wide.png

Tune is a library for hyperparameter tuning at any scale.

To run this example, you will need to install the following:

$ pip install "ray[tune]"

This example runs a parallel grid search to optimize an example objective function.

from ray import tune


def objective(step, alpha, beta):
    return (0.1 + alpha * step / 100)**(-1) + beta * 0.1


def training_function(config):
    # Hyperparameters
    alpha, beta = config["alpha"], config["beta"]
    for step in range(10):
        # Iterative training function - can be any arbitrary training procedure.
        intermediate_score = objective(step, alpha, beta)
        # Feed the score back back to Tune.
        tune.report(mean_loss=intermediate_score)


analysis = tune.run(
    training_function,
    config={
        "alpha": tune.grid_search([0.001, 0.01, 0.1]),
        "beta": tune.choice([1, 2, 3])
    })

print("Best config: ", analysis.get_best_config(metric="mean_loss", mode="min"))

# Get a dataframe for analyzing trial results.
df = analysis.results_df

If TensorBoard is installed, automatically visualize all trial results:

tensorboard --logdir ~/ray_results

RLlib Quick Start

https://github.com/ray-project/ray/raw/master/doc/source/images/rllib-wide.jpg

RLlib is an open-source library for reinforcement learning built on top of Ray that offers both high scalability and a unified API for a variety of applications.

pip install tensorflow  # or tensorflow-gpu
pip install "ray[rllib]"
import gym
from gym.spaces import Discrete, Box
from ray import tune

class SimpleCorridor(gym.Env):
    def __init__(self, config):
        self.end_pos = config["corridor_length"]
        self.cur_pos = 0
        self.action_space = Discrete(2)
        self.observation_space = Box(0.0, self.end_pos, shape=(1, ))

    def reset(self):
        self.cur_pos = 0
        return [self.cur_pos]

    def step(self, action):
        if action == 0 and self.cur_pos > 0:
            self.cur_pos -= 1
        elif action == 1:
            self.cur_pos += 1
        done = self.cur_pos >= self.end_pos
        return [self.cur_pos], 1 if done else 0, done, {}

tune.run(
    "PPO",
    config={
        "env": SimpleCorridor,
        "num_workers": 4,
        "env_config": {"corridor_length": 5}})

Ray Serve Quick Start

https://raw.githubusercontent.com/ray-project/ray/master/doc/source/serve/logo.svg

Ray Serve is a scalable model-serving library built on Ray. It is:

  • Framework Agnostic: Use the same toolkit to serve everything from deep learning models built with frameworks like PyTorch or Tensorflow & Keras to Scikit-Learn models or arbitrary business logic.

  • Python First: Configure your model serving declaratively in pure Python, without needing YAMLs or JSON configs.

  • Performance Oriented: Turn on batching, pipelining, and GPU acceleration to increase the throughput of your model.

  • Composition Native: Allow you to create “model pipelines” by composing multiple models together to drive a single prediction.

  • Horizontally Scalable: Serve can linearly scale as you add more machines. Enable your ML-powered service to handle growing traffic.

To run this example, you will need to install the following:

$ pip install scikit-learn
$ pip install "ray[serve]"

This example runs serves a scikit-learn gradient boosting classifier.

import pickle
import requests

from sklearn.datasets import load_iris
from sklearn.ensemble import GradientBoostingClassifier

from ray import serve

serve.start()

# Train model.
iris_dataset = load_iris()
model = GradientBoostingClassifier()
model.fit(iris_dataset["data"], iris_dataset["target"])

@serve.deployment(route_prefix="/iris")
class BoostingModel:
    def __init__(self, model):
        self.model = model
        self.label_list = iris_dataset["target_names"].tolist()

    async def __call__(self, request):
        payload = await request.json()["vector"]
        print(f"Received flask request with data {payload}")

        prediction = self.model.predict([payload])[0]
        human_name = self.label_list[prediction]
        return {"result": human_name}


# Deploy model.
BoostingModel.deploy(model)

# Query it!
sample_request_input = {"vector": [1.2, 1.0, 1.1, 0.9]}
response = requests.get("http://localhost:8000/iris", json=sample_request_input)
print(response.text)
# Result:
# {
#  "result": "versicolor"
# }

More Information

Older documents:

Getting Involved

  • Forum: For discussions about development, questions about usage, and feature requests.

  • GitHub Issues: For reporting bugs.

  • Twitter: Follow updates on Twitter.

  • Slack: Join our Slack channel.

  • Meetup Group: Join our meetup group.

  • StackOverflow: For questions about how to use Ray.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ray-1.9.0rc1-cp39-cp39-win_amd64.whl (21.3 MB view details)

Uploaded CPython 3.9Windows x86-64

ray-1.9.0rc1-cp39-cp39-manylinux2014_x86_64.whl (57.3 MB view details)

Uploaded CPython 3.9

ray-1.9.0rc1-cp39-cp39-macosx_11_0_arm64.whl (26.7 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

ray-1.9.0rc1-cp39-cp39-macosx_10_15_x86_64.whl (58.7 MB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

ray-1.9.0rc1-cp38-cp38-win_amd64.whl (21.3 MB view details)

Uploaded CPython 3.8Windows x86-64

ray-1.9.0rc1-cp38-cp38-manylinux2014_x86_64.whl (57.4 MB view details)

Uploaded CPython 3.8

ray-1.9.0rc1-cp38-cp38-macosx_11_0_arm64.whl (26.7 MB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

ray-1.9.0rc1-cp38-cp38-macosx_10_15_x86_64.whl (58.7 MB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

ray-1.9.0rc1-cp37-cp37m-win_amd64.whl (22.6 MB view details)

Uploaded CPython 3.7mWindows x86-64

ray-1.9.0rc1-cp37-cp37m-manylinux2014_x86_64.whl (57.6 MB view details)

Uploaded CPython 3.7m

ray-1.9.0rc1-cp37-cp37m-macosx_10_15_intel.whl (58.9 MB view details)

Uploaded CPython 3.7mmacOS 10.15+ Intel (x86-64, i386)

ray-1.9.0rc1-cp36-cp36m-win_amd64.whl (21.4 MB view details)

Uploaded CPython 3.6mWindows x86-64

ray-1.9.0rc1-cp36-cp36m-manylinux2014_x86_64.whl (57.6 MB view details)

Uploaded CPython 3.6m

ray-1.9.0rc1-cp36-cp36m-macosx_10_15_intel.whl (58.9 MB view details)

Uploaded CPython 3.6mmacOS 10.15+ Intel (x86-64, i386)

File details

Details for the file ray-1.9.0rc1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: ray-1.9.0rc1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 21.3 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.26.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10

File hashes

Hashes for ray-1.9.0rc1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 0dec588dce626ded35c607db56a17bb5b0f0ee05b4af44d1ef69a41c994c157b
MD5 b48c0127ab97b9ba9a819d1989388754
BLAKE2b-256 0663e9988c69eca8dbfdf35c75fb09b646957208005c9c7bb9aa1c0bd224878d

See more details on using hashes here.

File details

Details for the file ray-1.9.0rc1-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

  • Download URL: ray-1.9.0rc1-cp39-cp39-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 57.3 MB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.26.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10

File hashes

Hashes for ray-1.9.0rc1-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ac6368051e45a305637d5f13a5bce9545e6b0f60d62b80ba8719d75cb9088733
MD5 5369201c4bec44844f6fe84d3178b8dc
BLAKE2b-256 5d55b55a4d97d2a7c60f2eb3976ccceb29f5369e3b1a1531e21c024eb17dc241

See more details on using hashes here.

File details

Details for the file ray-1.9.0rc1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

  • Download URL: ray-1.9.0rc1-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 26.7 MB
  • Tags: CPython 3.9, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.26.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10

File hashes

Hashes for ray-1.9.0rc1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 30b8e4ea6857205c48f711254702329854b81fd9bb16f558d27b60bfc03ba433
MD5 401ac69da40497aff54c3bdeea114452
BLAKE2b-256 970ba30ad7478f3c3534bd3b9c7588d9e3b875567ced372ea665d6571f13d4e0

See more details on using hashes here.

File details

Details for the file ray-1.9.0rc1-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: ray-1.9.0rc1-cp39-cp39-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 58.7 MB
  • Tags: CPython 3.9, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.6.4 pkginfo/1.8.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

File hashes

Hashes for ray-1.9.0rc1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 9061fbeb8537806c1b0e0cb1549fdd4c14cf2c5fdef040b058e53baab88bd7dd
MD5 1d597a4f8479946b216ab0e1fef57ccb
BLAKE2b-256 2185773ff13ba39696a58cf4dc279b6e3b396d478f437fdcb66bf70b877d97d8

See more details on using hashes here.

File details

Details for the file ray-1.9.0rc1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: ray-1.9.0rc1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 21.3 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.26.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10

File hashes

Hashes for ray-1.9.0rc1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 a67a97164766811631ce1e881f0e967b7f7572e07bbdba71973bf2a5b27864af
MD5 eab05eb3849cdb31d31c8f1c30fa061f
BLAKE2b-256 3df09ed0adc8f7613f0fdead8efd5bdd3a1b67097ebe0c83aa0e56ebc4faad9f

See more details on using hashes here.

File details

Details for the file ray-1.9.0rc1-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

  • Download URL: ray-1.9.0rc1-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 57.4 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.26.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10

File hashes

Hashes for ray-1.9.0rc1-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a71502f8bbb39ea292f868f29fecfbe340c3ecb2269e80d07d6a76900e480636
MD5 8306f5157e1c90db49719416737a7895
BLAKE2b-256 3c10cc1bbc67c4172e863c1385e0ab4ff2a68a5123dda5dae3af892fbe980a08

See more details on using hashes here.

File details

Details for the file ray-1.9.0rc1-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

  • Download URL: ray-1.9.0rc1-cp38-cp38-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 26.7 MB
  • Tags: CPython 3.8, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.26.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10

File hashes

Hashes for ray-1.9.0rc1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cc5e764d95c4f24bf6da4478327f6f7ef9bdec5b0a9bec9d481aec5d38fe0cd5
MD5 aa8e633d84d6a5f45ed1319be72ee87e
BLAKE2b-256 3056903e50b31ef23cc1c406e5070d29384acbf2b5bae4596cffb3e45314c103

See more details on using hashes here.

File details

Details for the file ray-1.9.0rc1-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: ray-1.9.0rc1-cp38-cp38-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 58.7 MB
  • Tags: CPython 3.8, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.6.4 pkginfo/1.8.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

File hashes

Hashes for ray-1.9.0rc1-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 83e819a6aa321f2af84bcb11048e345d98c17e356a88ed1bec2cfde6a3b6388f
MD5 a882320286a966d3c3e267ae084355a2
BLAKE2b-256 4b59375942741c6cff2d79fa2198b8759e1f8a5a9e1fc85f98c4aeb0ded7a9d1

See more details on using hashes here.

File details

Details for the file ray-1.9.0rc1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: ray-1.9.0rc1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 22.6 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.26.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10

File hashes

Hashes for ray-1.9.0rc1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 5417343387cea70baeb44d1e6636f2280918982e01c8324f86613864b041ec73
MD5 204306d36c1ee7c9daa8dc8b21f4272c
BLAKE2b-256 d9d5a4633362f4f151bda77507941c8475a355f7694e68aabc872b896cd67915

See more details on using hashes here.

File details

Details for the file ray-1.9.0rc1-cp37-cp37m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: ray-1.9.0rc1-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 57.6 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.26.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10

File hashes

Hashes for ray-1.9.0rc1-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 abe555a4ef55f55e0b0cb36eb3ec8c917147388292ba8fda7b5d948a8cc533cd
MD5 02dbf7f55fa637cd6b314f9a988152ea
BLAKE2b-256 94473a724b6dafeb370c31e89bbd5ebcfa3ceb41139b2bb3b3816aea2f715c51

See more details on using hashes here.

File details

Details for the file ray-1.9.0rc1-cp37-cp37m-macosx_10_15_intel.whl.

File metadata

  • Download URL: ray-1.9.0rc1-cp37-cp37m-macosx_10_15_intel.whl
  • Upload date:
  • Size: 58.9 MB
  • Tags: CPython 3.7m, macOS 10.15+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.6.4 pkginfo/1.8.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

File hashes

Hashes for ray-1.9.0rc1-cp37-cp37m-macosx_10_15_intel.whl
Algorithm Hash digest
SHA256 fc6d5ce90dca38f32cbddeb1a4e98a33f0d83c29e2831a94995dce39fb54dfe3
MD5 13a699167494c9fd8fc5f3177cce95cf
BLAKE2b-256 36de707f080fb7b4ab1d40a347ff5f1d6dab1aad14c3bbb498a8a7a5b65a86bc

See more details on using hashes here.

File details

Details for the file ray-1.9.0rc1-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: ray-1.9.0rc1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 21.4 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.26.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10

File hashes

Hashes for ray-1.9.0rc1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 d8e9c1f3c0021217a6f1ae1c2d5dd404dee2b3d826381d21dfd920a7bcf2cc57
MD5 8d4308e7a1fab93e03afe0358c900e44
BLAKE2b-256 c03f9f183a81696b9399838596e3c757ea69fe518d12c3bd784ad442f44e6999

See more details on using hashes here.

File details

Details for the file ray-1.9.0rc1-cp36-cp36m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: ray-1.9.0rc1-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 57.6 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.26.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10

File hashes

Hashes for ray-1.9.0rc1-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6e1c5d8d8c5559955ee89ce8874301c762834035962f87401d9bfa61770c42a4
MD5 2f9ed8875b5acab099a191b899c55c6f
BLAKE2b-256 a94dc25d3791676a0ed7dec88ff2bc055f1c043a8e6b5834b7c6b015ccc44679

See more details on using hashes here.

File details

Details for the file ray-1.9.0rc1-cp36-cp36m-macosx_10_15_intel.whl.

File metadata

  • Download URL: ray-1.9.0rc1-cp36-cp36m-macosx_10_15_intel.whl
  • Upload date:
  • Size: 58.9 MB
  • Tags: CPython 3.6m, macOS 10.15+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.6.4 pkginfo/1.8.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

File hashes

Hashes for ray-1.9.0rc1-cp36-cp36m-macosx_10_15_intel.whl
Algorithm Hash digest
SHA256 3d1335a5a103123d83e06ace5c0288d30b045a6085165ff8d6fe3ed78f84b8e0
MD5 dde64c834936e08820af4fe48f07e11c
BLAKE2b-256 5e780fc6f97393fd860bddd02cd61fc9330216964e8ef2a0b8381d2e3d3ff4d3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page