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

Uploaded CPython 3.9Windows x86-64

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

Uploaded CPython 3.9

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

Uploaded CPython 3.9macOS 11.0+ ARM64

ray_cpp-1.9.1-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.1-cp38-cp38-win_amd64.whl (17.1 MB view details)

Uploaded CPython 3.8Windows x86-64

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

Uploaded CPython 3.8

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

Uploaded CPython 3.8macOS 11.0+ ARM64

ray_cpp-1.9.1-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.1-cp37-cp37m-win_amd64.whl (17.1 MB view details)

Uploaded CPython 3.7mWindows x86-64

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

Uploaded CPython 3.7m

ray_cpp-1.9.1-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.1-cp36-cp36m-win_amd64.whl (17.1 MB view details)

Uploaded CPython 3.6mWindows x86-64

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

Uploaded CPython 3.6m

ray_cpp-1.9.1-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.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: ray_cpp-1.9.1-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.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 91343c82b0ce8117a0f4fd4a640d60aaf25077c2fc40ee4dcbf3a2c4d93ac72e
MD5 41e43a1cdfe183fd3535bc2b0ad62a03
BLAKE2b-256 5eb25d7a3e26f6cd3866f9413f955bac7bae43be0c15ce5293f3a862cfac1948

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.1-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.1-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bf4527dc5621c876a224703ecdb0df40544bb16181f6f68dba5da3dfb7a79147
MD5 63916c9b96173ef64f6262d3af942a66
BLAKE2b-256 9d39697b64d846fb2f699e939f634843da5d49f094ee98e06b0199af87d2c766

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.1-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.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1b2ae8c6afd2a185bec7e29cf2d7299321750aca52dceef425aa8f55d053d833
MD5 64291d01fbdfa1a599810be7154373f6
BLAKE2b-256 44a8c06365dbfc0011b0ac3d26235384ebd3c2e898a5abc5062072ed98f1676a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.1-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.1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 51cde2d6b80a8419ad5b63335c47f006f1bcfe1c05fa691b750ec43f2dcb674c
MD5 2cb8004c4963e21393b223ba46ac059f
BLAKE2b-256 6ef88dd5c2b07d77e3c4624ed73d18a18e18366a4a6b4a63fa96f238d90da8aa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.1-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.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 ddee3ba6ef201f57afce16b57a3f651caa464e50a90c63e53a7abdfc38ad03d1
MD5 2b3a6a072459cc3d29579e4e6c616e17
BLAKE2b-256 6c5a192a114bdce18e865845e4848751e569cb89504ef378fd4ea4b40b1130a7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.1-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.1-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cc64267db283c5270965a340be2e8127d92352f2ae97b2457caf5994ecc9ce12
MD5 6dbfcb9fa736c9274579eaa587f79253
BLAKE2b-256 c6f5a3a774d09451e0dc6f8dbd0140350def483febd3802fbe26dfd81fcb81d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.1-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.1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 adbb6b47767268799dd5b8048b8b320fdbfa9abbf550981f6129e64cad03e527
MD5 58abdf002d5433d6c6dcb8c835126ed2
BLAKE2b-256 3b5729529ad139b775da19e206f849377f39677d3bb4d184eb1bd0f0334be14d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.1-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.1-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 f436ca0c5ac5ef554d2d4aac6f00fe8839af18ed5600a348d8a9db8ced5f6854
MD5 a589db58367b2fe07f08e75dfbea91a3
BLAKE2b-256 a220341ab09920068a0200946a4e290904fa4a4bba0ebc130a99328e8147340a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.1-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.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 57f61a6a609c7fcbf7f384eb87a556a03d904fab0d716fff754c33718b3aecf2
MD5 194bf110cd74f5123b5ae8adae85430e
BLAKE2b-256 9230cab1c1ab58cf34acf6d8aac194a05c1d16bf1dfc32ab2b203aae9f5107ad

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.1-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.1-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c95b017f0b43937dde81bf4aa7bf1bf561276844346ad3beb189450c5c4476e9
MD5 68c1a5f209f326f630077317a13518d3
BLAKE2b-256 1995675f28c96c8a405de7c64ffe935e865bc734fd65476d290305abe9f3dc5f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.1-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.1-cp37-cp37m-macosx_10_15_intel.whl
Algorithm Hash digest
SHA256 6f7950b4e1881a720c0a1743666036a65614ecff145b41bf4c422a84493b8c47
MD5 dd2a45f144d5f10b45bf89eb7e972edf
BLAKE2b-256 ef13a7afc618df8ecfe904aadb6cb1bb173098628f6398a829bf0879938f3e87

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.1-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.1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 328d254bd2d5c27eebbed38220b63fc48bfae6ab7a811bb8c818748c1ac0403b
MD5 f06b33e636dc830a1317ff006de119a4
BLAKE2b-256 1aa17f902e10ef0239373487d5abe508421f7bb329006e50570e36b3178d85dd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.1-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.1-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b77dce220c2eab463b5b33e08da24a029c967400f78832db64610c3b785ce668
MD5 3d514242f673bdf04ef155a413a0390f
BLAKE2b-256 81f8c3b491d202f9e030e139fbc3347b656b297aa6a7e84cf561d1cd2288afe2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ray_cpp-1.9.1-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.1-cp36-cp36m-macosx_10_15_intel.whl
Algorithm Hash digest
SHA256 ed6bcf387ff63a65ffc4ff1fadf1082bd661a21f3941a33ef45bdb07b4f1f9df
MD5 1913058d0bf5e8547cd13265c3c97d51
BLAKE2b-256 c5466ffc21053df538a78e70fa09738a231b8ac4e94b70bfe9e3274cb04b8b2a

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