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

  • RaySGD: Distributed Training Wrappers

  • Datasets: Flexible Distributed Data Loading (alpha)

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.7.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

ray-1.7.0-cp39-cp39-win_amd64.whl (18.1 MB view details)

Uploaded CPython 3.9Windows x86-64

ray-1.7.0-cp39-cp39-manylinux2014_x86_64.whl (53.7 MB view details)

Uploaded CPython 3.9

ray-1.7.0-cp39-cp39-macosx_10_15_x86_64.whl (54.7 MB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

ray-1.7.0-cp38-cp38-win_amd64.whl (18.1 MB view details)

Uploaded CPython 3.8Windows x86-64

ray-1.7.0-cp38-cp38-manylinux2014_x86_64.whl (53.7 MB view details)

Uploaded CPython 3.8

ray-1.7.0-cp38-cp38-macosx_10_15_x86_64.whl (54.7 MB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

ray-1.7.0-cp37-cp37m-win_amd64.whl (18.2 MB view details)

Uploaded CPython 3.7mWindows x86-64

ray-1.7.0-cp37-cp37m-manylinux2014_x86_64.whl (54.0 MB view details)

Uploaded CPython 3.7m

ray-1.7.0-cp37-cp37m-macosx_10_15_intel.whl (54.9 MB view details)

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

ray-1.7.0-cp36-cp36m-win_amd64.whl (18.2 MB view details)

Uploaded CPython 3.6mWindows x86-64

ray-1.7.0-cp36-cp36m-manylinux2014_x86_64.whl (54.0 MB view details)

Uploaded CPython 3.6m

ray-1.7.0-cp36-cp36m-macosx_10_15_intel.whl (54.9 MB view details)

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

File details

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

File metadata

  • Download URL: ray-1.7.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 18.1 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.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.7.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ab12fd3381721776e0121b68194df6a15264803fc39935af3de0e5b6d7987e3b
MD5 1c01899691a08cebdf887465c4e72e60
BLAKE2b-256 75a91b4836380660156964dc26bc2038c1c1b084bbaa7434150f3b9c510f4e66

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.7.0-cp39-cp39-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 53.7 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.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.7.0-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 52e8a6733eeb13dc7afb5fe91bc34347d789838ca926cbd09498e4d7cd8a8903
MD5 58b5dfcaa3ed7818dcda47012ea87d6e
BLAKE2b-256 8d29874afa66ca22a90d798558268ee0bb5527ec7fbdb159954302f443b216c8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.7.0-cp39-cp39-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 54.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.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.7.0-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 0453805695050f38213c4c71b24486a71d20b2ee185b97e9f14695416f25cbf1
MD5 5858579761c4b2fd2a4f2ab91c7d1dd5
BLAKE2b-256 293dc1484b184de9c8d93a7ef1fc3bf7153cf8e2d8349506cae5d190ad6fd454

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.7.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 18.1 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.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.7.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 223d00aac45c93d013c3acee1498b44b9525e886e08220268a2a52c087565890
MD5 c4202b4036be70bae3758289a0e76ace
BLAKE2b-256 e3ba5c1e1645b937ca0b4522985aab0a5d8a70b6e7e19ecb5b103319096a4e54

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.7.0-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 53.7 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.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.7.0-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 40e1a5c15993b34190ceef75296f9e725a8b6c73cb723ae060a709b3392fab7f
MD5 cedffee037f79abe82da4c8bd10f02e6
BLAKE2b-256 0c73d3525380dfc6b37f1dbeb8d1508f27ee0bbec531dbfaf934efd64646ab63

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.7.0-cp38-cp38-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 54.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.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.7.0-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 f70d230f77a39dc3471ff937ec4f5e7ecbd0de813408e91da2a17a2311c2008a
MD5 9269f025b8b280d09acee6d9fd170cc1
BLAKE2b-256 4abd0b617143ccc58d4801657b953c3e648469732d7938b9a7c302ab2eb084e8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.7.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 18.2 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.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.7.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 1cb379a425883ec8c98436bb92bca452692c2d1dafa9edb2f7509d07ff8696ab
MD5 a5ed5e5343230a5a0d01730a636f90cb
BLAKE2b-256 2a6a6a91e056529c64ff5a5016192ca552028361bab73a6a6c84b63e361793d9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.7.0-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 54.0 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.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.7.0-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f2915a30418a441b7ccda4e12f2b060b735d88b3a306e2e97798c15137ab7397
MD5 377e0717141a28594fe6c0f66807fa30
BLAKE2b-256 761ceebdbcb025d53d5946a2bff959a9420309fdb8b8f60664935f51f50b273e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.7.0-cp37-cp37m-macosx_10_15_intel.whl
  • Upload date:
  • Size: 54.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.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.7.0-cp37-cp37m-macosx_10_15_intel.whl
Algorithm Hash digest
SHA256 d9cff662c9fc10f9e4a74b9b4fd88972850a4b745582653d951b3ffdb6a8138f
MD5 efa0db7cf966279b57a1a2d172230c7c
BLAKE2b-256 e1c1d6e0b2cc16b588b2eb1f5f317ffe92195ee84956935ea8540bc0294bc192

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.7.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 18.2 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.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.7.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 fa0c09743036d7b9895bdfa8e3d61096a96e41a28f02e4e461d1f7f8718523f3
MD5 abe8ff978ae9f2860b2c5dc98b3a5295
BLAKE2b-256 0e370b4f919f1ad2867fea788218daaab294d968f92ec62a93ae39e52c02664b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.7.0-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 54.0 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.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.7.0-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3be58eb9fed36207b7f256c9665446a3bbee2b143d7f4cf08ba5a1b48995fa25
MD5 47d2ceb5a794f947930e4378b56d452b
BLAKE2b-256 10f9f6e1ea367b970fedde59b89eb55e548fc1ccce98c3dbe33ec2a079689e15

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.7.0-cp36-cp36m-macosx_10_15_intel.whl
  • Upload date:
  • Size: 54.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.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for ray-1.7.0-cp36-cp36m-macosx_10_15_intel.whl
Algorithm Hash digest
SHA256 01f654352c1b365164ee25221e5450c738c498f55a7aae0c46f952e2c0e1f3db
MD5 04e72db22ac0b43e03795a8ac16b46da
BLAKE2b-256 909018444b8f1778af5c64d1362be667d2fce3e2320296f6ec790822428cda6d

See more details on using hashes here.

Supported by

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