Skip to content

Commit

Permalink
[Templates] Remove runtime_env usage and use a custom docker image …
Browse files Browse the repository at this point in the history
…when needed (ray-project#35475)

Signed-off-by: Justin Yu <[email protected]>
  • Loading branch information
justinvyu authored May 27, 2023
1 parent 97f6e93 commit 11370b6
Show file tree
Hide file tree
Showing 30 changed files with 959 additions and 2,293 deletions.
43 changes: 3 additions & 40 deletions doc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -252,57 +252,20 @@ py_test_run_all_subdirectory(
)

# --------------------------------------------------------------------
# Test all Workspace template notebooks in doc/source/templates
# as smoke tests.
# Workspace templates tests
# --------------------------------------------------------------------

filegroup(
name = "workspace_templates",
srcs = glob([
"source/templates/tests/**/*.ipynb",
"source/templates/tests/**/requirements.txt"
]),
visibility = ["//doc:__subpackages__"]
)

# Validate that all the paths and yamls within the templates.yaml file are valid.

py_test(
name = "templates_directory_validation",
size = "small",
main = "source/templates/validate.py",
srcs = ["source/templates/validate.py"],
main = "source/templates/testing/validate.py",
srcs = ["source/templates/testing/validate.py"],
data = glob(["source/templates/**/*"]),
tags = ["exclusive", "team:ml"]
)

# Templates that only require CPU

py_test_run_all_notebooks(
size = "large",
# TODO(justinvyu): Merge tests/ with the regular versions of the templates.
include = ["source/templates/tests/02_many_model_training/many_model_training.ipynb"],
exclude = [],
data = ["//doc:workspace_templates"],
tags = ["exclusive", "team:ml", "ray_air"],
env = {"SMOKE_TEST": "1"},
)

# Templates that require GPU

py_test_run_all_notebooks(
size = "large",
include = [
# TODO(justinvyu): Merge tests/ with the regular versions of the templates.
"source/templates/tests/01_batch_inference/batch_inference.ipynb",
"source/templates/tests/03_serving_stable_diffusion/serving_stable_diffusion.ipynb"
],
exclude = [],
data = ["//doc:workspace_templates"],
tags = ["exclusive", "team:ml", "ray_air", "gpu"],
env = {"SMOKE_TEST": "1"},
)

# --------------
# Run GPU tests
# --------------
Expand Down
32 changes: 9 additions & 23 deletions doc/source/templates/01_batch_inference/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
# Scaling Batch Inference with Ray Data

This template is a quickstart to using [Ray
Data](https://docs.ray.io/en/latest/data/data.html) for batch
inference. Ray Data is one of many libraries under the [Ray AI
Runtime](https://docs.ray.io/en/latest/ray-air/getting-started.html).
See [this blog
post](https://www.anyscale.com/blog/model-batch-inference-in-ray-actors-actorpool-and-datasets)
for more information on why and how you should perform batch inference
with Ray!
| Template Specification | Description |
| ---------------------- | ----------- |
| Summary | This template walks through GPU batch inference on an image dataset using a PyTorch ResNet model. |
| Time to Run | Less than 2 minutes to compute predictions on the dataset. |
| Minimum Compute Requirements | No hard requirements. The default is 4 nodes, each with 1 NVIDIA T4 GPU. |
| Cluster Environment | This template uses the latest Anyscale-provided Ray ML image using Python 3.9: [`anyscale/ray-ml:2.4.0-py39-gpu`](https://docs.anyscale.com/reference/base-images/ray-240/py39#ray-ml-2-4-0-py39). If you want to change to a different cluster environment, make sure that it is based off of this image! |

This template walks through GPU batch prediction on an image dataset
using a PyTorch model, but the framework and data format are there just
to help you build your own application!
## Getting Started

At a high level, this template will:
**When the workspace is up and running, start coding by clicking on the Jupyter or VSCode icon above. Open the `start.ipynb` file and follow the instructions there.**

1. [Load your dataset using Ray
Data.](https://docs.ray.io/en/latest/data/loading-data.html)
2. [Preprocess your dataset before feeding it to your
model.](https://docs.ray.io/en/latest/data/transforming-data.html)
3. [Initialize your model and perform inference on a shard of your
dataset with a remote
actor.](https://docs.ray.io/en/latest/data/transforming-data.html#callable-class-udfs)
4. [Save your prediction
results.](https://docs.ray.io/en/latest/data/api/input_output.html)

Start coding by clicking on the Jupyter or VSCode icon above.
By the end, we will have classified around 4000 images using the pre-trained ResNet model and saved these predictions to a local directory.
Loading

0 comments on commit 11370b6

Please sign in to comment.