Skip to main content
Version: Latest

Dependency management

Check your docs version

These docs are for the new Anyscale design. If you started using Anyscale before April 2024, use Version 1.0.0 of the docs. If you're transitioning to Anyscale Preview, see the guide for how to migrate.

Anyscale's approach to dependency management mirrors the development-to-production flow. For fast iteration cycles, runtime dependencies allow dynamic configuration of an Anyscale Workspace environment. For deploying applications to production, custom container images ensure performance and reliability across cluster nodes.

Manage dependencies in development​

To quickly manage your environment, you may already be familiar with running pip install <PACKAGE_NAME> or pip uninstall -r requirements.txt. Running these on the command line in Anyscale Workspaces updates the head node’s environment, tracking and persisting environment changes as you work. At runtime of a Ray application, the workspace distributes the dependencies to all nodes in the cluster, ensuring consistent execution.

To inspect the dependencies, select a workspace and navigate to the Dependencies tab. With this user interface, you can add and remove packages equivalent to pip install and pip uninstall.

Dependencies tab

note

Anyscale Workspaces supports a subset of pip options. Reach out to preview-help@anyscale.com for advanced options.

Environment variables​

Within the Dependencies tab, you can add and remove environment variables to the workspace. After modification, open a new terminal and run source ~/.bashrc to restart bash and reload the environment variables into the current session.

Transition to a production environment​

Anyscale installs runtime dependencies on each node as it spins up. Though this method enables flexibility and quick iteration during development, it introduces some challenges for production workloads.

  1. Version variability - Different nodes started at different times might end up with varying versions depending on how strictly defined the requirements are.
  2. Latency issues - Each node must install all dependencies and download data or model weights before performing work, which can lead to significant slowdowns.
  3. Risk of production failure - If an incident occurs with package sources like pip or GitHub, this could lead to failure of the job or service.

The section shows how to solidify dynamic dependencies into stable, optimized images.

Build an optimized image​

Container images are the standard for production workloads. These isolated environments encapsulate all necessary elements for software execution, including code, runtime, system tools, libraries, and settings, ensuring consistent operation across different computing environments.

Workspaces start with a default, Anyscale-built image that works with most Ray workloads out-of-the-box. This image contains various versions of Ray, Python, CUDA, and popular machine learning packages like torch and pandas. When you modify runtime dependencies, you're using a default image as the base.

Anyscale build farm

To build a custom container image, select a workspace and navigate to the Dependencies tab. Click Build an optimized image to access a Dockerfile-like interface where you can specify the base image. See Anyscale base image options. Only images with Ray 2.8.1 or later are supported. This interface supports the following Dockerfile instructions:

  • FROM: Create a new build from an Anyscale base image.
  • ENV: Set environment variables.
  • WORKDIR: Change working directory.
  • COPY: Copy files and directories only from a previous build stage, not from local storage.
  • RUN: Execute build commands.

After building an image, switch the workspace image, restart the workspace, and submit a job or deploy a service. This enables a faster start-up time and a fixed environment for production workloads.

For the full specification for building Anyscale compatible images, see Image requirements.