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

Uploaded CPython 3.9Windows x86-64

ray-1.9.2-cp39-cp39-manylinux2014_x86_64.whl (57.4 MB view details)

Uploaded CPython 3.9

ray-1.9.2-cp39-cp39-macosx_11_0_arm64.whl (26.6 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

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

Uploaded CPython 3.9macOS 10.15+ x86-64

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

Uploaded CPython 3.8Windows x86-64

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

Uploaded CPython 3.8

ray-1.9.2-cp38-cp38-macosx_11_0_arm64.whl (26.6 MB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

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

Uploaded CPython 3.8macOS 10.15+ x86-64

ray-1.9.2-cp37-cp37m-win_amd64.whl (21.4 MB view details)

Uploaded CPython 3.7mWindows x86-64

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

Uploaded CPython 3.7m

ray-1.9.2-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.2-cp36-cp36m-win_amd64.whl (21.4 MB view details)

Uploaded CPython 3.6mWindows x86-64

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

Uploaded CPython 3.6m

ray-1.9.2-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.2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: ray-1.9.2-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.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.9.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a9de944bd0dc4d553d10eb31efba4eab508f65289c5595ab56df44f65810d9dd
MD5 d4a654850f3acdfba171a2aec9ef9328
BLAKE2b-256 22d4651789cddeebd7f68247dc9b03f2d4882434cfa6d8047e73172d307e7a82

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.9.2-cp39-cp39-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 57.4 MB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.9.2-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 76294786421799a2a157917cbe493f758ae2f5a0acee8ac23cb885936b1a4e35
MD5 2042988eef995499f2d50e03381edffb
BLAKE2b-256 8572ba45b2c96ab80fc5d89f58465aac86ace7aa3ed73084a1a3c356b2394e56

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.9.2-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 26.6 MB
  • Tags: CPython 3.9, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.9.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2ad01e197f65b4e110e44f84e856af1c888e48bb8e1e4ae9ffa4e1aec710b9a8
MD5 f6827d8b6de816aa3189a75cc3d728c5
BLAKE2b-256 cedcb2cefd0594aeec0b211d9fba87f9055cfc26f80cd3fe1d65bd8a30b6b110

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.9.2-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.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.9.2-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 a17b7496e8fef1a829f70b16f5498979cb33c98d9e4567f89ea55aeea0690e4e
MD5 f96330e63b66fda90acf8d912e1a3e7a
BLAKE2b-256 5bd0c2f8df3f4ed067f8b4e88417327bb7592f4a1172fdd4df7fc31670b59ee7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.9.2-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.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.9.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 6169d3fe4a31a3306731a271c0802fdecb838fb90caacce848ce27209205db17
MD5 beb5cdaf35506417ef387e1278b696e4
BLAKE2b-256 30e0449857d539b0cb58a09476b906995639f58b978bc9404848a6f9291230e7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.9.2-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.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.9.2-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 096322f006fab7d9584593454dd45005be4e2ae8a24e8f4ca626474d42bf2581
MD5 a7cfe0294680cfe3247e444f07a6cede
BLAKE2b-256 df40c99104ea654abc9d8223b04c907e20aa934fb2b8d3bd76550feea9aa52cf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.9.2-cp38-cp38-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 26.6 MB
  • Tags: CPython 3.8, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.9.2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 749117ef11e8d22a24b11968c0c499bad83d5125e5937a7253a2079b0ac539a6
MD5 c2b36a7086b123c0300e21b57709dbdf
BLAKE2b-256 ec5bfa7afe6e18f6872464a11e2412f9c282b4d11617a0e96ec9b25ac8b431db

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.9.2-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.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.9.2-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 875cb87ed44606a3b16a2866dfcddf97d03b42db514140562f2826c014a762cc
MD5 8a86eca55c8361dbfccbd225cee6081b
BLAKE2b-256 35b537bdfee060089de9bcc025f70eabbffa66aa44f7157621f3324991edb24a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.9.2-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 21.4 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.9.2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 0707b9b3c88f2c936ec6e38f05e0f4cb354ed47f06411ef15e88b9722dca739e
MD5 e75f57903ce96bbb17b0a5921e1a6251
BLAKE2b-256 7732aeefa424e5ad9ebfc3526a9d8f7df06bebb24c01fc06615b4d887f8df540

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.9.2-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.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.9.2-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4fe10c58edb6d1e7349bbd2cab31248fcfdcf8f4d5050fc315a03069f1036be2
MD5 bd8dd6e1447d420378abd31875185d3f
BLAKE2b-256 87cb9fb296c89ceef4edf45c3d967a75a6b63a8d1aba12ebaf8cced1d5d4b05d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.9.2-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.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.9.2-cp37-cp37m-macosx_10_15_intel.whl
Algorithm Hash digest
SHA256 dc811b8fbaff6a6fc2602a7cd0a9b93e441770e56a6e0065be385b01958c34be
MD5 0457a311ad728ae455c4b774c77347d7
BLAKE2b-256 ccd49ac18ee03599d9afceda87748c051644e8f766bd23d72d7bbd8cdb7337ad

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.9.2-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.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.9.2-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 513e8db6dd6320a77df4ef91c273b2fa428df9474450e7d84d70edccb1739baf
MD5 0d1455cea95a1f850b1a8989b6e47772
BLAKE2b-256 ea9a942870001b93845c73b422c477ed259fafbcefab63a8934018d69ae354ba

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.9.2-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.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.9.2-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 236dc9b43478339576fd2545f2ad898caca4df4df0fc17cb6947316a242ebb81
MD5 61c0387033514f424909465b8b556f28
BLAKE2b-256 af84cc96faccfb0589a4ec620789b7cfe32fee0368b20654c5eedec527bbf877

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.9.2-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.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.9.2-cp36-cp36m-macosx_10_15_intel.whl
Algorithm Hash digest
SHA256 a2b34ec2e63264593b07ace70541ffe5ba9069ecc2dc94294ffc1c3b491a751e
MD5 82c8b1ce0f9973dee05d0568631185a5
BLAKE2b-256 e84bd4ea8a9fee4a1922e547de81ad1e55ee719fd1b9e5991abbe96f71f92234

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