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

  • Ray Serve: Scalable and Programmable Serving

  • Datasets: Distributed Arrow on Ray (preview)

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.

from ray import serve
import pickle
import requests
from sklearn.datasets import load_iris
from sklearn.ensemble import GradientBoostingClassifier

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

# Define Ray Serve model,
class BoostingModel:
    def __init__(self):
        self.model = model
        self.label_list = iris_dataset["target_names"].tolist()

    def __call__(self, flask_request):
        payload = flask_request.json["vector"]
        print("Worker: received flask request with data", payload)

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


# Deploy model
client = serve.start()
client.create_backend("iris:v1", BoostingModel)
client.create_endpoint("iris_classifier", backend="iris:v1", route="/iris")

# 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

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

Uploaded CPython 3.9Windows x86-64

ray-1.6.0-cp39-cp39-manylinux2014_x86_64.whl (49.3 MB view details)

Uploaded CPython 3.9

ray-1.6.0-cp39-cp39-macosx_10_15_x86_64.whl (52.4 MB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

ray-1.6.0-cp38-cp38-win_amd64.whl (15.6 MB view details)

Uploaded CPython 3.8Windows x86-64

ray-1.6.0-cp38-cp38-manylinux2014_x86_64.whl (49.3 MB view details)

Uploaded CPython 3.8

ray-1.6.0-cp38-cp38-macosx_10_15_x86_64.whl (52.4 MB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

ray-1.6.0-cp37-cp37m-win_amd64.whl (15.7 MB view details)

Uploaded CPython 3.7mWindows x86-64

ray-1.6.0-cp37-cp37m-manylinux2014_x86_64.whl (49.6 MB view details)

Uploaded CPython 3.7m

ray-1.6.0-cp37-cp37m-macosx_10_15_intel.whl (52.5 MB view details)

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

ray-1.6.0-cp36-cp36m-win_amd64.whl (15.7 MB view details)

Uploaded CPython 3.6mWindows x86-64

ray-1.6.0-cp36-cp36m-manylinux2014_x86_64.whl (49.6 MB view details)

Uploaded CPython 3.6m

ray-1.6.0-cp36-cp36m-macosx_10_15_intel.whl (52.6 MB view details)

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

File details

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

File metadata

  • Download URL: ray-1.6.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 15.6 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.10

File hashes

Hashes for ray-1.6.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 5a684eb6a990f8e03fad2ee1259644e9d484ddbe5560ac4407264ec9b8066d82
MD5 58339305c989f60d97735b0e3596ef4e
BLAKE2b-256 f1b453e68b5873287828e747a3c0f605db807e8e16dfbeaf41bca5e1bdc7359f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.6.0-cp39-cp39-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 49.3 MB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.10

File hashes

Hashes for ray-1.6.0-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e86a9871bee94c3042ad24190e9cec45a16b5f5053b48021e2b03a0a74e8ccbd
MD5 55d292e6fd99fce4281d0b63b83c7a97
BLAKE2b-256 2d9d24f233ec79c095defdc66aca21eb0429f7d811c6f2f5095fe9e7e47d080e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.6.0-cp39-cp39-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 52.4 MB
  • Tags: CPython 3.9, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.10

File hashes

Hashes for ray-1.6.0-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 3d823cbfe6a4fa0b49d55c7ba3e20ed7ac69a58aa1a9bbe6930597ecafdb4e3e
MD5 63517d98d5f38a0d1cf6196f963620e1
BLAKE2b-256 e8ad307d64268fccab6182391d0f537266e6561c5d7b1fb4f425ca8363386d28

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.6.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 15.6 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.10

File hashes

Hashes for ray-1.6.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 655078d7b0279606da57a74830fb8e1721bdecddd96b82573d85f48f9ea0b03e
MD5 f0b8815238f5f959f3e1f2d6d7984c7a
BLAKE2b-256 06c68ed00947eb12e4fad805f79bedf993e57072cdadba4f25047dd327c8fc0f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.6.0-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 49.3 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.10

File hashes

Hashes for ray-1.6.0-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9938fb57d2e40e3b40d8fd354614730c5a34597391d78ed91a186f2621b7db5e
MD5 65bac3b948c2204bd8506874a79f10f4
BLAKE2b-256 c6adeb0be6c9bc7ead69490185b3c17f194df26a6b97793e687d9d1301d3e7e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.6.0-cp38-cp38-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 52.4 MB
  • Tags: CPython 3.8, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.10

File hashes

Hashes for ray-1.6.0-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 8851666e7807e133f27d4027ec1ced8a457020ffb2783ec3a67d946d4688e339
MD5 75169fdc197d4cb46affede38fa384e6
BLAKE2b-256 844091c471a6129d58cd07293170f0325bcaba5917b8f10e97342ebaa2e4a13c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.6.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 15.7 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.10

File hashes

Hashes for ray-1.6.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 3fe7675b9239b45549ab196b2237dfd143e9ac86aab01dbd181ab6fb014a8ed1
MD5 fc21b243cbafc7057c70ea348b7717ff
BLAKE2b-256 ad556604055acd095baaa1265bfeafa23e050972bb1672dc2e0532d3cbd968ff

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.6.0-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 49.6 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.10

File hashes

Hashes for ray-1.6.0-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 74a78cfa24e63254636602d089adc276eadc67ce7a9a0ce4e2918b2eb0232a69
MD5 b81d5930c5912862590ec425e76b290e
BLAKE2b-256 d8590f453e4bca1af5f36d9fc3c0f6893523e25ae62b9ecc2c36c61d7bb5d52f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.6.0-cp37-cp37m-macosx_10_15_intel.whl
  • Upload date:
  • Size: 52.5 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.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.10

File hashes

Hashes for ray-1.6.0-cp37-cp37m-macosx_10_15_intel.whl
Algorithm Hash digest
SHA256 c08492b755b700642ada4571301c0f2b7c4a4ec61689c97393c572bd605ab33c
MD5 6eedf8d31918d641506b01106c15d1dc
BLAKE2b-256 31fef931f0f602472d4116913ed30dce5073ddf91fa694337619eebd8f186f31

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.6.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 15.7 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.10

File hashes

Hashes for ray-1.6.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 d25a9b43f0ad139bad6bcf0b4177974242e0e089272fedb06bef06112c231aa9
MD5 dacf6016337fc99eb122ef77c9f9d840
BLAKE2b-256 5cb9b6587d8c0a92fc28cffe0867c6cbdeb0fcc82f7f8e4d37a14c4bbd7c9798

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.6.0-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 49.6 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.10

File hashes

Hashes for ray-1.6.0-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f499016503b52c1ae09ae1cb3c64736c5093edde36633a15259cd21345753ab6
MD5 e89f916e58895a43835d2a921811b413
BLAKE2b-256 673c33dfa2b55f553032b1700a023571e2545df0cc91a09bcbe72fb9a0e373bb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray-1.6.0-cp36-cp36m-macosx_10_15_intel.whl
  • Upload date:
  • Size: 52.6 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.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.10

File hashes

Hashes for ray-1.6.0-cp36-cp36m-macosx_10_15_intel.whl
Algorithm Hash digest
SHA256 17b34001296c6a9b6a625dec78261d24bf07cfaad3c936afeab4b1424f26e89e
MD5 5771ec9dba35034027a1efaf844130a1
BLAKE2b-256 da9c57db71813910ace81d53e5b3a3ae466659fcfc8bdd3cdab35457b7e41ac5

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