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 (alpha)

  • Datasets: Flexible Distributed Data Loading (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

This version

1.8.0

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.8.0-cp39-cp39-win_amd64.whl (18.3 MB view details)

Uploaded CPython 3.9Windows x86-64

ray-1.8.0-cp39-cp39-manylinux2014_x86_64.whl (54.4 MB view details)

Uploaded CPython 3.9

ray-1.8.0-cp39-cp39-macosx_11_0_arm64.whl (24.2 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

ray-1.8.0-cp39-cp39-macosx_10_15_x86_64.whl (55.7 MB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

ray-1.8.0-cp38-cp38-win_amd64.whl (18.3 MB view details)

Uploaded CPython 3.8Windows x86-64

ray-1.8.0-cp38-cp38-manylinux2014_x86_64.whl (54.4 MB view details)

Uploaded CPython 3.8

ray-1.8.0-cp38-cp38-macosx_11_0_arm64.whl (24.2 MB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

ray-1.8.0-cp38-cp38-macosx_10_15_x86_64.whl (55.7 MB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

ray-1.8.0-cp37-cp37m-win_amd64.whl (18.4 MB view details)

Uploaded CPython 3.7mWindows x86-64

ray-1.8.0-cp37-cp37m-manylinux2014_x86_64.whl (54.7 MB view details)

Uploaded CPython 3.7m

ray-1.8.0-cp37-cp37m-macosx_10_15_intel.whl (55.9 MB view details)

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

ray-1.8.0-cp36-cp36m-win_amd64.whl (18.4 MB view details)

Uploaded CPython 3.6mWindows x86-64

ray-1.8.0-cp36-cp36m-manylinux2014_x86_64.whl (54.7 MB view details)

Uploaded CPython 3.6m

ray-1.8.0-cp36-cp36m-macosx_10_15_intel.whl (55.9 MB view details)

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

File details

Details for the file ray-1.8.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: ray-1.8.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 18.3 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for ray-1.8.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 8bd9a2beb0594555d74907d2a390a050d4dd08158409ef0d64c1bf9fceeb149c
MD5 ac67c6643ab0046078a16136f34c4150
BLAKE2b-256 abecb2a9735f9a5b84770929d80ba335bfe1d4f87f25040e1dc4cf8f05f08226

See more details on using hashes here.

File details

Details for the file ray-1.8.0-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

  • Download URL: ray-1.8.0-cp39-cp39-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 54.4 MB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for ray-1.8.0-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9e4ccb5e4ba925d41d73e3af304c4ae19b44967d4f18f6e16655b43123a2ff5e
MD5 eff314b40fbe552cb7b6dab69e00a228
BLAKE2b-256 d1fa2b3079a0286cf25d7ae486cb28773cc36cc7daa45e12d139f4bcaf888762

See more details on using hashes here.

File details

Details for the file ray-1.8.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

  • Download URL: ray-1.8.0-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 24.2 MB
  • Tags: CPython 3.9, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for ray-1.8.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d26fbbd86bada6031434ebdc33da9b9ee490d35b99e0e5297e21f424e56e4ea9
MD5 561f337fd7133bb35ab9930e4e5e4005
BLAKE2b-256 1817e4dd459507cca91d29d0676b4a5c4d44a4a08a5ae1cd5ea1136648ca5f65

See more details on using hashes here.

File details

Details for the file ray-1.8.0-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: ray-1.8.0-cp39-cp39-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 55.7 MB
  • Tags: CPython 3.9, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for ray-1.8.0-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 e4c59d04c617ad33372526c03b503b93dbb1fa614544c41214ecbe8750b11caa
MD5 9d84b64e290b22acdcafaf19c2390d59
BLAKE2b-256 880fdfc0cf2089e55eec36e4019e9fcc1606d948ea63f6ee0ea29e005848da0f

See more details on using hashes here.

File details

Details for the file ray-1.8.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: ray-1.8.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 18.3 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for ray-1.8.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 05b52aeaf100d840bd664ef28db3f485dbe7b4b208da0cc8ee3e060e2fc2d1ba
MD5 13f9bb99aa8b07e767f486869c84450b
BLAKE2b-256 36f997aee1deb5841319fd8c5303f7721ab3a98db2d3936bc258cfbd3694220f

See more details on using hashes here.

File details

Details for the file ray-1.8.0-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

  • Download URL: ray-1.8.0-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 54.4 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for ray-1.8.0-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bfbbda17a7753d3a16cc530744d037f28ef18561f173bed923f05590267a79b4
MD5 4af14e47f75d53a3947e226bccf37f26
BLAKE2b-256 310072a1b0ac45b6ab82581ee658d7a05b44ce8a8eebe21148a82da038cfe4d1

See more details on using hashes here.

File details

Details for the file ray-1.8.0-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

  • Download URL: ray-1.8.0-cp38-cp38-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 24.2 MB
  • Tags: CPython 3.8, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for ray-1.8.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 53f4c620c770a99ca709afe5973f13eb97f22dc8db1871ffedfe29364b9f4cca
MD5 9c8647d933b22aeb198f27a492e1be56
BLAKE2b-256 a0c691c399f49ffdf1ba681dfc6f9dfa73231e5e616e59482f2e32f1a549693d

See more details on using hashes here.

File details

Details for the file ray-1.8.0-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: ray-1.8.0-cp38-cp38-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 55.7 MB
  • Tags: CPython 3.8, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for ray-1.8.0-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 c73353eb4e6f9083be3320f705891bf693f8e0aef82021cb9f9d221f69b4de5d
MD5 3d8d2574a666e6e68bc98edc288882c7
BLAKE2b-256 0b467985171065c2912404cff56872833d8bfbe7dfa66782e0804405e840fe92

See more details on using hashes here.

File details

Details for the file ray-1.8.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: ray-1.8.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 18.4 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for ray-1.8.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 77f8d1e51ae9802a98abe0b66273dd2dbd7612f3c17081d6100aaf35baab9aa7
MD5 118e49220299368a006c1852afea2164
BLAKE2b-256 f2ce824bc152dd1b2b1b2277b4526a343b24358fb8caaf6e2c237df3f1efd200

See more details on using hashes here.

File details

Details for the file ray-1.8.0-cp37-cp37m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: ray-1.8.0-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 54.7 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for ray-1.8.0-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 28c16a6203ca298d8726b6a33d6928304fca78246655c2da20e5e38799d71c48
MD5 2e0f204d6d785b6dc890e2cc0aae1818
BLAKE2b-256 9c0f7276f00654911e553df73cafde37cb67451688ce20aaba0ebde9c751a4ef

See more details on using hashes here.

File details

Details for the file ray-1.8.0-cp37-cp37m-macosx_10_15_intel.whl.

File metadata

  • Download URL: ray-1.8.0-cp37-cp37m-macosx_10_15_intel.whl
  • Upload date:
  • Size: 55.9 MB
  • Tags: CPython 3.7m, macOS 10.15+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for ray-1.8.0-cp37-cp37m-macosx_10_15_intel.whl
Algorithm Hash digest
SHA256 34346a99047ea450aa8281fd9ff1079b0a6cc1e88192daefff4c30bda222a3e1
MD5 854193bf24a3762cf39d58bd7be287b3
BLAKE2b-256 1abeafddd3ea7f6bf7f67b71c76e261b6eb840cebf673ccb1de4b941a81d3cce

See more details on using hashes here.

File details

Details for the file ray-1.8.0-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: ray-1.8.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 18.4 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for ray-1.8.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 d1a685b2f13a33a31aca7984a17803bf193bb84471e25d51c7a26f8574d8bffd
MD5 dadee08551218a8056a3a107816cfd05
BLAKE2b-256 f4759ad22265e783d24152443716f5ab260641e6c65e88ee0a2dd744b15b3c39

See more details on using hashes here.

File details

Details for the file ray-1.8.0-cp36-cp36m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: ray-1.8.0-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 54.7 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for ray-1.8.0-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1d67bd2d08d6ad9e308d0e2ecd513c780054aac8ac59a8a1fe8546e05d8bd700
MD5 437e10351012c80528a1e0d7b4a90934
BLAKE2b-256 dca7380d78b8103f62f29444c863212ac297727bc45be8df2a9dd0f72a9aa055

See more details on using hashes here.

File details

Details for the file ray-1.8.0-cp36-cp36m-macosx_10_15_intel.whl.

File metadata

  • Download URL: ray-1.8.0-cp36-cp36m-macosx_10_15_intel.whl
  • Upload date:
  • Size: 55.9 MB
  • Tags: CPython 3.6m, macOS 10.15+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for ray-1.8.0-cp36-cp36m-macosx_10_15_intel.whl
Algorithm Hash digest
SHA256 77d6db630041103c31ffbe05de082a42a35ef2c7cbeaff064bdc2dc2e03bd55e
MD5 d559b3281290cbfdcf8907af5913ad97
BLAKE2b-256 918f51d8b6d1f6fa28edcc70bcf82edc4a637dbfda267c498b506441ab0c9255

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