{"id":20446373,"url":"https://github.com/ray-project/tutorial","last_synced_at":"2025-05-16T18:06:23.122Z","repository":{"id":41653366,"uuid":"89322668","full_name":"ray-project/tutorial","owner":"ray-project","description":null,"archived":false,"fork":false,"pushed_at":"2022-03-21T20:43:22.000Z","size":31896,"stargazers_count":782,"open_issues_count":33,"forks_count":212,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-04-03T17:13:01.776Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ray-project.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-25T05:55:26.000Z","updated_at":"2025-03-26T09:13:00.000Z","dependencies_parsed_at":"2022-07-07T12:44:40.402Z","dependency_job_id":null,"html_url":"https://github.com/ray-project/tutorial","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ray-project%2Ftutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ray-project%2Ftutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ray-project%2Ftutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ray-project%2Ftutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ray-project","download_url":"https://codeload.github.com/ray-project/tutorial/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248598359,"owners_count":21131081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T10:19:44.815Z","updated_at":"2025-04-12T16:40:42.019Z","avatar_url":"https://github.com/ray-project.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"Ray Tutorial\n============\n\n**NOTE**: These sets of tutorials have been **deprecated**. A portion of their modules have\nbeen incorporated into the new Anyscale Academy tutorials at https://github.com/anyscale/academy.\n\n\nTry Ray on Google Colab\n-----------------------\n\nTry the Ray tutorials online using Google Colab:\n\n- `Remote Functions`_\n- `Remote Actors`_\n- `In-Order Task Processing`_\n- `Reinforcement Learning with RLlib`_\n\n.. _`Remote Functions`: https://colab.research.google.com/github/ray-project/tutorial/blob/master/exercises/colab01-03.ipynb\n.. _`Remote Actors`: https://colab.research.google.com/github/ray-project/tutorial/blob/master/exercises/colab04-05.ipynb\n.. _`In-Order Task Processing`: https://colab.research.google.com/github/ray-project/tutorial/blob/master/exercises/colab06-07.ipynb\n.. _`Reinforcement Learning with RLlib`: https://colab.research.google.com/github/ray-project/tutorial/blob/master/rllib_exercises/rllib_colab.ipynb\n\nTry Tune on Google Colab\n------------------------\n\nTuning hyperparameters is often the most expensive part of the machine learning workflow. `Ray Tune \u003chttp://tune.io\u003e`_ is built to address this, demonstrating an efficient and scalable solution for this pain point.\n\n`Exercise 1 \u003chttps://github.com/ray-project/tutorial/tree/master/tune_exercises/exercise_1_basics.ipynb\u003e`_ covers basics of using Tune - creating your first training function and using Tune. This tutorial uses Keras.\n\n.. raw:: html\n\n    \u003ca href=\"https://colab.research.google.com/github/ray-project/tutorial/blob/master/tune_exercises/exercise_1_basics.ipynb\" target=\"_parent\"\u003e\n    \u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Tune Tutorial\"/\u003e\n    \u003c/a\u003e\n\n`Exercise 2 \u003chttps://github.com/ray-project/tutorial/tree/master/tune_exercises/exercise_2_optimize.ipynb\u003e`_ covers Search algorithms and Trial Schedulers. This tutorial uses PyTorch.\n\n.. raw:: html\n\n    \u003ca href=\"https://colab.research.google.com/github/ray-project/tutorial/blob/master/tune_exercises/exercise_2_optimize.ipynb\" target=\"_parent\"\u003e\n    \u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Tune Tutorial\"/\u003e\n    \u003c/a\u003e\n\n`Exercise 3 \u003chttps://github.com/ray-project/tutorial/tree/master/tune_exercises/exercise_3_pbt.ipynb\u003e`_  covers using Population-Based Training (PBT) and uses the advanced Trainable API with save and restore functions and checkpointing.\n\n.. raw:: html\n\n    \u003ca href=\"https://colab.research.google.com/github/ray-project/tutorial/blob/master/tune_exercises/exercise_3_pbt.ipynb\" target=\"_parent\"\u003e\n    \u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Tune Tutorial\"/\u003e\n    \u003c/a\u003e\n\nTry Ray on Binder\n-----------------\n\nTry the Ray tutorials online on `Binder`_. Note that Binder will use very small\nmachines, so the degree of parallelism will be limited.\n\n.. _`Binder`: https://mybinder.org/v2/gh/ray-project/tutorial/master?urlpath=lab\n\nLocal Setup\n-----------\n\n1. Make sure you have Python installed (we recommend using the `Anaconda Python\n   distribution`_). Ray works with both Python 2 and Python 3. If you are unsure\n   which to use, then use Python 3.\n\n   **If not using conda**, continue to step 2.\n\n   **If using conda**, you can then run the following commands and skip the next 4 steps:\n\n   .. code-block:: bash\n\n       git clone https://github.com/ray-project/tutorial\n       cd tutorial\n       conda env create -f environment.yml\n       conda activate ray-tutorial\n\n\n2. **Install Jupyter** with ``pip install jupyter``. Verify that you can start\n   Jupyter lab with the command ``jupyter-lab`` or ``jupyter-notebook``.\n\n3. **Install Ray** by running ``pip install -U ray``. Verify that you can run\n\n    .. code-block:: bash\n\n      import ray\n      ray.init()\n\n   in a Python interpreter.\n\n4. Clone the tutorial repository with\n\n    .. code-block:: bash\n\n      git clone https://github.com/ray-project/tutorial.git\n\n5. Install the additional dependencies.\n\n   Either install them from the given requirements.txt\n\n    .. code-block:: bash\n      pip install -r requirements.txt\n\n   Or install them manually\n\n    .. code-block:: bash\n\n      pip install modin\n      pip install tensorflow\n      pip install gym\n      pip install scipy\n      pip install opencv-python\n      pip install bokeh\n      pip install ipywidgets==6.0.0\n      pip install keras\n\n   Verify that you can run ``import tensorflow`` and ``import gym`` in a Python\n   interpreter.\n\n   **Note:** If you have trouble installing these Python modules, note that\n   almost all of the exercises can be done without them.\n\n6. If you want to run the pong exercise (in `rl_exercises/rl_exercise05.ipynb`),\n   you will need to do `pip install utilities/pong_py`.\n\nExercises\n---------\n\nEach file ``exercises/exercise*.ipynb`` is a separate exercise. They can be\nopened in Jupyter lab by running the following commands.\n\n.. code-block:: bash\n\n  cd tutorial/exercises\n  jupyter-lab\n\nIf you don't have `jupyter-lab`, try `jupyter-notebook`. If it asks for a password, just hit enter.\n\nInstructions are written in each file. To do each exercise, first run all of\nthe cells in Jupyter lab. Then modify the ones that need to be modified\nin order to prevent any exceptions from being raised. Throughout these\nexercises, you may find the `Ray documentation`_ helpful.\n\n**Exercise 1:** Define a remote function, and execute multiple remote functions\nin parallel.\n\n**Exercise 2:** Execute remote functions in parallel with some dependencies.\n\n**Exercise 3:** Call remote functions from within remote functions.\n\n**Exercise 4:** Use actors to share state between tasks. See the documentation\non `using actors`_.\n\n**Exercise 5:** Pass actor handles to tasks so that multiple tasks can invoke\nmethods on the same actor.\n\n**Exercise 6:** Use ``ray.wait`` to ignore stragglers. See the\n`documentation for wait`_.\n\n**Exercise 7:** Use ``ray.wait`` to process tasks in the order that they finish.\nSee the `documentation for wait`_.\n\n**Exercise 8:** Use ``ray.put`` to avoid serializing and copying the same\nobject into shared memory multiple times.\n\n**Exercise 9:** Specify that an actor requires some GPUs. For a complete\nexample that does something similar, you may want to see the `ResNet example`_.\n\n**Exercise 10:** Specify that a remote function requires certain custom\nresources. See the documentation on `custom resources`_.\n\n**Exercise 11:** Extract neural network weights from an actor on one process,\nand set them in another actor. You may want to read the documentation on\n`using Ray with TensorFlow`_.\n\n**Exercise 12:** Pass object IDs into tasks to construct dependencies between\ntasks and perform a tree reduce.\n\n.. _`Anaconda Python distribution`: https://www.continuum.io/downloads\n.. _`Ray documentation`: https://ray.readthedocs.io/en/latest/?badge=latest\n.. _`documentation for wait`: https://ray.readthedocs.io/en/latest/api.html#ray.wait\n.. _`using actors`: https://ray.readthedocs.io/en/latest/actors.html\n.. _`using Ray with TensorFlow`: https://ray.readthedocs.io/en/latest/using-ray-with-tensorflow.html\n.. _`ResNet example`: https://ray.readthedocs.io/en/latest/example-resnet.html\n.. _`custom resources`: https://ray.readthedocs.io/en/latest/resources.html#custom-resources\n\n\nMore In-Depth Examples\n----------------------\n\n**Sharded Parameter Server:** This exercise involves implementing a parameter\nserver as a Ray actor, implementing a simple asynchronous distributed training\nalgorithm, and sharding the parameter server to improve throughput.\n\n**Speed Up Pandas:** This exercise involves using `Modin`_ to speed up your\npandas workloads.\n\n**MapReduce:** This exercise shows how to implement a toy version of the\nMapReduce system on top of Ray.\n\n.. _`Modin`: https://modin.readthedocs.io/en/latest/\n\nRL Exercises\n------------\n\nThe exercises in ``rl_exercises/rl_exercise*.ipynb`` should be done in order.\nThey can be opened in Jupyter lab by running the following commands.\n\n.. code-block:: bash\n\n  cd tutorial/rl_exercises\n  jupyter-lab\n\n**Exercise 1:** Introduction to Markov Decision Processes.\n\n**Exercise 2:** Derivative free optimization.\n\n**Exercise 3:** Introduction to proximal policy optimization (PPO).\n\n**Exercise 4:** Introduction to asynchronous advantage actor-critic (A3C).\n\n**Exercise 5:** Train a policy to play pong using RLlib. Deploy it using actors,\nand play against the trained policy.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fray-project%2Ftutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fray-project%2Ftutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fray-project%2Ftutorial/lists"}