remotely. Lastly, call that function with ``.remote()`` instead of calling it normally. This remote call yields a future, or ``ObjectID`` that you can then
fetch with ``ray.get``.
..code-block:: python
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]
In the above code block we defined some Ray Tasks. While these are great for stateless operations, sometimes you
must maintain the state of your application. You can do that with Ray Actors.
Parallelizing Python Classes with Ray Actors
==============================================
Ray provides actors to allow you to parallelize an instance of a class in Python.
Ray has a rich ecosystem of libraries and frameworks built on top of it. The main ones being:
-:ref:`tune-index`
-:ref:`rllib-index`
-:ref:`sgd-index`
-:ref:`rayserve`
Tune Quick Start
----------------
`Tune`_ is a library for hyperparameter tuning at any scale. With Tune, you can launch a multi-node distributed hyperparameter sweep in less than 10 lines of code. Tune supports any deep learning framework, including PyTorch, TensorFlow, and Keras.
..note::
To run this example, you will need to install the following:
..code-block:: bash
$ pip install ray torch torchvision filelock
This example runs a small grid search to train a CNN using PyTorch and Tune.
If TensorBoard is installed, automatically visualize all trial results:
..code-block:: bash
tensorboard --logdir ~/ray_results
.._`Tune`: tune.html
RLlib Quick Start
-----------------
`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.
..code-block:: bash
pip install tensorflow # or tensorflow-gpu
pip install ray[rllib] # also recommended: ray[debug]
Visit the `Walkthrough <walkthrough.html>`_ page a more comprehensive overview of Ray features.
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 <https://github.com/ray-project/ray/blob/master/python/ray/autoscaler/aws/example-full.yaml>`__, and run: