Skip to main content

A subpackage of Ray which provides the Ray C++ API.

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_cpp-1.9.2-cp39-cp39-win_amd64.whl (17.1 MB view details)

Uploaded CPython 3.9Windows x86-64

ray_cpp-1.9.2-cp39-cp39-manylinux2014_x86_64.whl (28.9 MB view details)

Uploaded CPython 3.9

ray_cpp-1.9.2-cp39-cp39-macosx_11_0_arm64.whl (24.9 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

ray_cpp-1.9.2-cp39-cp39-macosx_10_15_x86_64.whl (27.0 MB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

ray_cpp-1.9.2-cp38-cp38-win_amd64.whl (17.1 MB view details)

Uploaded CPython 3.8Windows x86-64

ray_cpp-1.9.2-cp38-cp38-manylinux2014_x86_64.whl (28.9 MB view details)

Uploaded CPython 3.8

ray_cpp-1.9.2-cp38-cp38-macosx_11_0_arm64.whl (24.9 MB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

ray_cpp-1.9.2-cp38-cp38-macosx_10_15_x86_64.whl (27.0 MB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

ray_cpp-1.9.2-cp37-cp37m-win_amd64.whl (17.1 MB view details)

Uploaded CPython 3.7mWindows x86-64

ray_cpp-1.9.2-cp37-cp37m-manylinux2014_x86_64.whl (28.9 MB view details)

Uploaded CPython 3.7m

ray_cpp-1.9.2-cp37-cp37m-macosx_10_15_intel.whl (27.0 MB view details)

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

ray_cpp-1.9.2-cp36-cp36m-win_amd64.whl (17.1 MB view details)

Uploaded CPython 3.6mWindows x86-64

ray_cpp-1.9.2-cp36-cp36m-manylinux2014_x86_64.whl (28.9 MB view details)

Uploaded CPython 3.6m

ray_cpp-1.9.2-cp36-cp36m-macosx_10_15_intel.whl (27.0 MB view details)

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

File details

Details for the file ray_cpp-1.9.2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: ray_cpp-1.9.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 17.1 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_cpp-1.9.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 052ddc9a04db12a4d771c442f7243cbef7188e0c6fbaa3caedb76c486ef0b809
MD5 6351fa97212846d9f0b0c785785adbc8
BLAKE2b-256 b6ee5186e81a8daa4a9bfc5d07faa97a4861a62b557865e2c6f87de23ff96ba8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.2-cp39-cp39-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 28.9 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_cpp-1.9.2-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a062e96c21cd778bbf564513fcc01e62d8fd2e4a8971ef1dd77b83e9b10ff9af
MD5 b7603384958e92a43191de5ceea7ee96
BLAKE2b-256 8a939a69c0c4cf27c3f1636ef49abf957c856c652c379caf40426f4b0a44d212

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.2-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 24.9 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_cpp-1.9.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0d60fcd260b9035c12a2b6a189804d9742d2e64b46f321637f2a9727081c624b
MD5 6f98476fda5e276c88671a7b4d0feed5
BLAKE2b-256 1d133601dc10940a68426ac2cbf70db1d6b678ac292f74342eddc156b7cd611f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.2-cp39-cp39-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 27.0 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_cpp-1.9.2-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 0138ea6b48460399fbd3654ec0bb6e42fd2f3455785897686c87ce7f76d7f1ce
MD5 04921dcb856ed2ad5c3a0385f568e735
BLAKE2b-256 5d673dacdc4749ab6ad258c108abf2eae1ac0559914b8f02020aeb4a9ee1feb0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.2-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 17.1 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_cpp-1.9.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 a013fe28dd91d0666c2f38915697ca0e7b05a49064055be5c0d3102e74bd8514
MD5 9be3712ef7fa89105a58f45f205afba3
BLAKE2b-256 7de192c84c9add8cf5a1130faf1794beb8d3d4554887f91cea1db1f0d2486b8c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.2-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 28.9 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_cpp-1.9.2-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7aab52f47796c6192e1f2f94123f302c566099d3bb33c3b18df69bdff04c55a0
MD5 7858a038ae24daba5c89ed14a438e84e
BLAKE2b-256 749ffa39ac46a276bbca44e55f374b512e9ee4f70284324320ec0ed2b53ad0d3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.2-cp38-cp38-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 24.9 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_cpp-1.9.2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 44e87c046adfcc17b2fb58bf4b038b37b5722ba0bec09227b030c548df05f133
MD5 900129f5ddffd9551e8866fb095ad060
BLAKE2b-256 6ac327e0c50208b68bcba9a39c7a4c6603a893edcb5ad02154e04defde8ebcbc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.2-cp38-cp38-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 27.0 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_cpp-1.9.2-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 f2be34fb8180ef3e3ec5304f05b67bbd0f950820aa2f8d7cd1fc069012dd251a
MD5 41f23bf9837125a29e969f9b4b54f92e
BLAKE2b-256 465c13ce7db7fc060b37083ae31055774e1ca587e743c21a4199a1a97f265833

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.2-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 17.1 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_cpp-1.9.2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 f759beb26c7689777d8f3831596d457ee8756e54aee74aa4115efe9655c76e8c
MD5 a1c71619a83a3068ed4b92bd3df7498e
BLAKE2b-256 63ce02196b4e970e52e8382c479a9c3e2fa45cfb86901a92ef6648dec44d9d4b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.2-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 28.9 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_cpp-1.9.2-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 60eb1110998356be1f245697526d7ca288859a4c1d056ffc7def944b43b3d536
MD5 34cc9286c999a080c8f85b9cc19e2045
BLAKE2b-256 528b83ba92d5a80b42f1d8984c1305e49e7798982829125bac21ba6d8ad3af53

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.2-cp37-cp37m-macosx_10_15_intel.whl
  • Upload date:
  • Size: 27.0 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_cpp-1.9.2-cp37-cp37m-macosx_10_15_intel.whl
Algorithm Hash digest
SHA256 e799cd453e1d32cfb1af0cea32ffd8d5e70fa11cf64c5743e4e83a45ce3212ed
MD5 3fad65b4ad0825dd5f58c94fd19eb516
BLAKE2b-256 6893f560ce3f09d09185435f2e2599bab0f7018b0385b31483d9cbc2890ec309

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.2-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 17.1 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_cpp-1.9.2-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 8fd5c3a71c9e7bb5d43985205ece6d15059a2339594132283be925f5eda15165
MD5 84876bf37df0e90b636754bf2fc45948
BLAKE2b-256 60141a53448594c22338de5498ab6f7578d5c4d6573e3d2bda1347a0db3d279a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.2-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 28.9 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_cpp-1.9.2-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5983a38b545dd16dc1fdc27a8e1a684b4d22a03a4657d6bd10bf66e92932dde5
MD5 65a999fedcdc05d980a4d94893e634d0
BLAKE2b-256 1f8ec1ad0439f86298814ee743a1bf67a64c4b6bbf12974a5f0bc5f3ed2a4184

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.2-cp36-cp36m-macosx_10_15_intel.whl
  • Upload date:
  • Size: 27.0 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_cpp-1.9.2-cp36-cp36m-macosx_10_15_intel.whl
Algorithm Hash digest
SHA256 4486b3b60c7ec86a9995fcbd8a26d40459e737264f5fb09182b0125781c1c3ff
MD5 ac0db51431ab48ebf340a1af1edd2b30
BLAKE2b-256 c8ac59a10d56b25c29112d4b6211153e246a4e6460965a9c0e8caba12e231a76

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