ray/doc/source/index.rst

370 lines
12 KiB
ReStructuredText
Raw Normal View History

What is Ray?
============
.. tip:: Please take 5 minutes to take the `Ray Pulse Community Survey <https://www.surveymonkey.com/r/ray-community-pulse-2021>`_!
.. include:: ray-overview/basics.rst
Getting Started with Ray
------------------------
Check out :ref:`gentle-intro` to learn more about Ray and its ecosystem of libraries that enable things like distributed hyperparameter tuning,
reinforcement learning, and distributed training.
Ray provides Python, Java, and *EXPERIMENTAL* C++ API. And Ray uses Tasks (functions) and Actors (Classes) to allow you to parallelize your code.
.. tabs::
.. group-tab:: Python
.. code-block:: python
# First, run `pip install ray`.
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)) # [0, 1, 4, 9]
@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)) # [1, 1, 1, 1]
.. group-tab:: Java
First, add the `ray-api <https://mvnrepository.com/artifact/io.ray/ray-api>`__ and `ray-runtime <https://mvnrepository.com/artifact/io.ray/ray-runtime>`__ dependencies in your project.
.. code-block:: java
import io.ray.api.ActorHandle;
import io.ray.api.ObjectRef;
import io.ray.api.Ray;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class RayDemo {
public static int square(int x) {
return x * x;
}
public static class Counter {
private int value = 0;
public void increment() {
this.value += 1;
}
public int read() {
return this.value;
}
}
public static void main(String[] args) {
// Intialize Ray runtime.
Ray.init();
{
List<ObjectRef<Integer>> objectRefList = new ArrayList<>();
// Invoke the `square` method 4 times remotely as Ray tasks.
// The tasks will run in parallel in the background.
for (int i = 0; i < 4; i++) {
objectRefList.add(Ray.task(RayDemo::square, i).remote());
}
// Get the actual results of the tasks with `get`.
System.out.println(Ray.get(objectRefList)); // [0, 1, 4, 9]
}
{
List<ActorHandle<Counter>> counters = new ArrayList<>();
// Create 4 actors from the `Counter` class.
// They will run in remote worker processes.
for (int i = 0; i < 4; i++) {
counters.add(Ray.actor(Counter::new).remote());
}
// Invoke the `increment` method on each actor.
// This will send an actor task to each remote actor.
for (ActorHandle<Counter> counter : counters) {
counter.task(Counter::increment).remote();
}
// Invoke the `read` method on each actor, and print the results.
List<ObjectRef<Integer>> objectRefList = counters.stream()
.map(counter -> counter.task(Counter::read).remote())
.collect(Collectors.toList());
System.out.println(Ray.get(objectRefList)); // [1, 1, 1, 1]
}
}
}
2019-08-05 23:33:14 -07:00
.. group-tab:: C++ (EXPERIMENTAL)
| The C++ Ray API is currently experimental with limited support. You can track its development `here <https://github.com/ray-project/ray/milestone/17>`__ and report issues on GitHub.
| Run the following commands to get started:
| - Build ray from source with *bazel* as shown `here <https://docs.ray.io/en/master/development.html#building-ray-full>`__.
2021-03-09 18:57:03 +08:00
| - Modify and build `cpp/example/example.cc`.
.. code-block:: shell
pip install -e python --verbose
2021-03-09 18:57:03 +08:00
bazel build //cpp/example:example
2021-02-01 21:13:43 +08:00
| Option 1: run the example directly with a dynamic library path. It will start a Ray cluster automatically.
2021-03-09 18:57:03 +08:00
.. code-block:: shell
ray stop
2021-06-04 13:41:47 +08:00
./bazel-bin/cpp/example/example --ray-dynamic-library-path=bazel-bin/cpp/example/example.so
2021-03-09 18:57:03 +08:00
| Option 2: connect to an existing Ray cluster with a known redis address (e.g. `127.0.0.1:6379`).
2021-03-09 18:57:03 +08:00
.. code-block:: shell
ray stop
ray start --head --port 6379 --redis-password 5241590000000000 --node-manager-port 62665
./bazel-bin/cpp/example/example --ray-dynamic-library-path=bazel-bin/cpp/example/example.so --ray-address=127.0.0.1:6379
.. literalinclude:: ../../cpp/example/example.cc
:language: cpp
2019-08-05 23:33:14 -07:00
You can also get started by visiting our `Tutorials <https://github.com/ray-project/tutorial>`_. For the latest wheels (nightlies), see the `installation page <installation.html>`__.
2019-08-05 23:33:14 -07:00
Getting Involved
================
2019-08-05 23:33:14 -07:00
.. include:: ray-overview/involvement.rst
2019-08-05 23:33:14 -07:00
If you're interested in contributing to Ray, visit our page on :ref:`Getting Involved <getting-involved>` to read about the contribution process and see what you can work on!
2019-08-05 23:33:14 -07:00
2019-08-28 17:54:15 -07:00
More Information
================
2019-08-28 17:54:15 -07:00
Here are some talks, papers, and press coverage involving Ray and its libraries. Please raise an issue if any of the below links are broken, or if you'd like to add your own talk!
Blog and Press
--------------
- `Modern Parallel and Distributed Python: A Quick Tutorial on Ray <https://towardsdatascience.com/modern-parallel-and-distributed-python-a-quick-tutorial-on-ray-99f8d70369b8>`_
- `Why Every Python Developer Will Love Ray <https://www.datanami.com/2019/11/05/why-every-python-developer-will-love-ray/>`_
- `Ray: A Distributed System for AI (BAIR) <http://bair.berkeley.edu/blog/2018/01/09/ray/>`_
- `10x Faster Parallel Python Without Python Multiprocessing <https://towardsdatascience.com/10x-faster-parallel-python-without-python-multiprocessing-e5017c93cce1>`_
- `Implementing A Parameter Server in 15 Lines of Python with Ray <https://ray-project.github.io/2018/07/15/parameter-server-in-fifteen-lines.html>`_
- `Ray Distributed AI Framework Curriculum <https://rise.cs.berkeley.edu/blog/ray-intel-curriculum/>`_
- `RayOnSpark: Running Emerging AI Applications on Big Data Clusters with Ray and Analytics Zoo <https://medium.com/riselab/rayonspark-running-emerging-ai-applications-on-big-data-clusters-with-ray-and-analytics-zoo-923e0136ed6a>`_
- `First user tips for Ray <https://rise.cs.berkeley.edu/blog/ray-tips-for-first-time-users/>`_
- [Tune] `Tune: a Python library for fast hyperparameter tuning at any scale <https://towardsdatascience.com/fast-hyperparameter-tuning-at-scale-d428223b081c>`_
- [Tune] `Cutting edge hyperparameter tuning with Ray Tune <https://medium.com/riselab/cutting-edge-hyperparameter-tuning-with-ray-tune-be6c0447afdf>`_
- [RLlib] `New Library Targets High Speed Reinforcement Learning <https://www.datanami.com/2018/02/01/rays-new-library-targets-high-speed-reinforcement-learning/>`_
- [RLlib] `Scaling Multi Agent Reinforcement Learning <http://bair.berkeley.edu/blog/2018/12/12/rllib/>`_
- [RLlib] `Functional RL with Keras and Tensorflow Eager <https://bair.berkeley.edu/blog/2019/10/14/functional-rl/>`_
- [Modin] `How to Speed up Pandas by 4x with one line of code <https://www.kdnuggets.com/2019/11/speed-up-pandas-4x.html>`_
- [Modin] `Quick Tip Speed up Pandas using Modin <https://pythondata.com/quick-tip-speed-up-pandas-using-modin/>`_
- `Ray Blog`_
.. _`Ray Blog`: https://ray-project.github.io/
Talks (Videos)
--------------
- `Programming at any Scale with Ray | SF Python Meetup Sept 2019 <https://www.youtube.com/watch?v=LfpHyIXBhlE>`_
- `Ray for Reinforcement Learning | Data Council 2019 <https://www.youtube.com/watch?v=Ayc0ca150HI>`_
- `Scaling Interactive Pandas Workflows with Modin <https://www.youtube.com/watch?v=-HjLd_3ahCw>`_
- `Ray: A Distributed Execution Framework for AI | SciPy 2018 <https://www.youtube.com/watch?v=D_oz7E4v-U0>`_
- `Ray: A Cluster Computing Engine for Reinforcement Learning Applications | Spark Summit <https://www.youtube.com/watch?v=xadZRRB_TeI>`_
- `RLlib: Ray Reinforcement Learning Library | RISECamp 2018 <https://www.youtube.com/watch?v=eeRGORQthaQ>`_
- `Enabling Composition in Distributed Reinforcement Learning | Spark Summit 2018 <https://www.youtube.com/watch?v=jAEPqjkjth4>`_
- `Tune: Distributed Hyperparameter Search | RISECamp 2018 <https://www.youtube.com/watch?v=38Yd_dXW51Q>`_
Slides
------
- `Talk given at UC Berkeley DS100 <https://docs.google.com/presentation/d/1sF5T_ePR9R6fAi2R6uxehHzXuieme63O2n_5i9m7mVE/edit?usp=sharing>`_
- `Talk given in October 2019 <https://docs.google.com/presentation/d/13K0JsogYQX3gUCGhmQ1PQ8HILwEDFysnq0cI2b88XbU/edit?usp=sharing>`_
- [Tune] `Talk given at RISECamp 2019 <https://docs.google.com/presentation/d/1v3IldXWrFNMK-vuONlSdEuM82fuGTrNUDuwtfx4axsQ/edit?usp=sharing>`_
Papers
------
- `Ray 1.0 Architecture whitepaper`_ **(new)**
- `Ray Design Patterns`_ **(new)**
2019-08-28 17:54:15 -07:00
- `RLlib paper`_
2021-03-01 20:11:40 -08:00
- `RLlib flow paper`_
2019-08-28 17:54:15 -07:00
- `Tune paper`_
*Older papers:*
- `Ray paper`_
- `Ray HotOS paper`_
.. _`Ray 1.0 Architecture whitepaper`: https://docs.google.com/document/d/1lAy0Owi-vPz2jEqBSaHNQcy2IBSDEHyXNOQZlGuj93c/preview
.. _`Ray Design Patterns`: https://docs.google.com/document/d/167rnnDFIVRhHhK4mznEIemOtj63IOhtIPvSYaPgI4Fg/edit
2019-08-28 17:54:15 -07:00
.. _`Ray paper`: https://arxiv.org/abs/1712.05889
.. _`Ray HotOS paper`: https://arxiv.org/abs/1703.03924
.. _`RLlib paper`: https://arxiv.org/abs/1712.09381
2021-03-01 20:11:40 -08:00
.. _`RLlib flow paper`: https://arxiv.org/abs/2011.12719
2019-08-28 17:54:15 -07:00
.. _`Tune paper`: https://arxiv.org/abs/1807.05118
.. toctree::
:hidden:
2019-08-28 17:54:15 -07:00
:maxdepth: -1
:caption: Overview of Ray
ray-overview/index.rst
ray-libraries.rst
installation.rst
2017-03-04 23:06:02 -08:00
.. toctree::
:hidden:
2019-08-28 17:54:15 -07:00
:maxdepth: -1
:caption: Ray Core
walkthrough.rst
using-ray.rst
configure.rst
ray-dashboard.rst
Tutorial and Examples <auto_examples/overview.rst>
Design patterns and anti-patterns <ray-design-patterns/index.rst>
2019-08-05 23:33:14 -07:00
package-ref.rst
.. toctree::
:hidden:
:maxdepth: -1
:caption: Multi-node Ray
cluster/index.rst
cluster/quickstart.rst
cluster/guide.rst
cluster/reference.rst
cluster/cloud.rst
cluster/ray-client.rst
cluster/deploy.rst
.. toctree::
:hidden:
2019-08-28 17:54:15 -07:00
:maxdepth: -1
:caption: Ray Serve
serve/index.rst
serve/tutorial.rst
serve/core-apis.rst
serve/http-servehandle.rst
serve/deployment.rst
serve/ml-models.rst
serve/performance.rst
serve/architecture.rst
serve/tutorials/index.rst
2020-10-19 17:15:22 -07:00
serve/faq.rst
serve/package-ref.rst
.. toctree::
:hidden:
:maxdepth: -1
:caption: Ray Tune
tune/index.rst
tune/key-concepts.rst
tune/user-guide.rst
tune/tutorials/overview.rst
tune/examples/index.rst
tune/api_docs/overview.rst
tune/contrib.rst
.. toctree::
:hidden:
2019-08-28 17:54:15 -07:00
:maxdepth: -1
:caption: RLlib
rllib.rst
rllib-toc.rst
[rllib] Document "v2" APIs (#2316) * re * wip * wip * a3c working * torch support * pg works * lint * rm v2 * consumer id * clean up pg * clean up more * fix python 2.7 * tf session management * docs * dqn wip * fix compile * dqn * apex runs * up * impotrs * ddpg * quotes * fix tests * fix last r * fix tests * lint * pass checkpoint restore * kwar * nits * policy graph * fix yapf * com * class * pyt * vectorization * update * test cpe * unit test * fix ddpg2 * changes * wip * args * faster test * common * fix * add alg option * batch mode and policy serving * multi serving test * todo * wip * serving test * doc async env * num envs * comments * thread * remove init hook * update * fix ppo * comments1 * fix * updates * add jenkins tests * fix * fix pytorch * fix * fixes * fix a3c policy * fix squeeze * fix trunc on apex * fix squeezing for real * update * remove horizon test for now * multiagent wip * update * fix race condition * fix ma * t * doc * st * wip * example * wip * working * cartpole * wip * batch wip * fix bug * make other_batches None default * working * debug * nit * warn * comments * fix ppo * fix obs filter * update * wip * tf * update * fix * cleanup * cleanup * spacing * model * fix * dqn * fix ddpg * doc * keep names * update * fix * com * docs * clarify model outputs * Update torch_policy_graph.py * fix obs filter * pass thru worker index * fix * rename * vlad torch comments * fix log action * debug name * fix lstm * remove unused ddpg net * remove conv net * revert lstm * wip * wip * cast * wip * works * fix a3c * works * lstm util test * doc * clean up * update * fix lstm check * move to end * fix sphinx * fix cmd * remove bad doc * envs * vec * doc prep * models * rl * alg * up * clarify * copy * async sa * fix * comments * fix a3c conf * tune lstm * fix reshape * fix * back to 16 * tuned a3c update * update * tuned * optional * merge * wip * fix up * move pg class * rename env * wip * update * tip * alg * readme * fix catalog * readme * doc * context * remove prep * comma * add env * link to paper * paper * update * rnn * update * wip * clean up ev creation * fix * fix * fix * fix lint * up * no comma * ma * Update run_multi_node_tests.sh * fix * sphinx is stupid * sphinx is stupid * clarify torch graph * no horizon * fix config * sb * Update test_optimizers.py
2018-07-01 00:05:08 -07:00
rllib-training.rst
rllib-env.rst
rllib-models.rst
rllib-algorithms.rst
rllib-sample-collection.rst
rllib-offline.rst
rllib-concepts.rst
rllib-examples.rst
rllib-package-ref.rst
rllib-dev.rst
2017-03-04 23:06:02 -08:00
.. toctree::
:hidden:
:maxdepth: -1
:caption: Ray SGD
raysgd/raysgd.rst
raysgd/raysgd_pytorch.rst
raysgd/raysgd_tensorflow.rst
2020-06-01 15:48:15 -07:00
raysgd/raysgd_dataset.rst
raysgd/raysgd_ptl.rst
raysgd/raysgd_tune.rst
raysgd/raysgd_ref.rst
.. toctree::
:hidden:
:maxdepth: -1
:caption: Data Processing
modin/index.rst
dask-on-ray.rst
mars-on-ray.rst
raydp.rst
.. toctree::
:hidden:
2019-08-28 17:54:15 -07:00
:maxdepth: -1
:caption: More Libraries
2019-12-29 21:40:58 -06:00
multiprocessing.rst
2020-01-27 16:35:48 -08:00
joblib.rst
iter.rst
xgboost-ray.rst
ray-collective.rst
.. toctree::
:hidden:
:maxdepth: -1
:caption: Ray Observability
ray-metrics.rst
ray-debugging.rst
ray-logging.rst
2021-04-30 19:16:47 -10:00
ray-tracing.rst
.. toctree::
:hidden:
:maxdepth: -1
:caption: Contributing
getting-involved.rst
.. toctree::
:hidden:
2019-08-28 17:54:15 -07:00
:maxdepth: -1
:caption: Development and Ray Internals
development.rst
whitepaper.rst
debugging.rst
profiling.rst
2019-08-05 23:33:14 -07:00
fault-tolerance.rst