nemo_rl.utils.venvs#

Module Contents#

Functions#

create_local_venv

Create a virtual environment using uv and execute a command within it.

_env_builder

create_local_venv_on_each_node

Create a virtual environment on each Ray node.

make_actor_runtime_env

Build a Ray runtime_env for one of our registered actors.

Data#

API#

nemo_rl.utils.venvs.dir_path#

‘dirname(…)’

nemo_rl.utils.venvs.git_root#

‘abspath(…)’

nemo_rl.utils.venvs.DEFAULT_VENV_DIR#

‘join(…)’

nemo_rl.utils.venvs.logger#

‘getLogger(…)’

nemo_rl.utils.venvs.create_local_venv(
py_executable: str,
venv_name: str,
force_rebuild: bool = False,
) str#

Create a virtual environment using uv and execute a command within it.

The output can be used as a py_executable for a Ray worker assuming the worker nodes also have access to the same file system as the head node.

This function is cached to avoid multiple calls to uv to create the same venv, which avoids duplicate logging.

Parameters:
  • py_executable (str) – Command to run with the virtual environment (e.g., “uv.sh run –locked”)

  • venv_name (str) – Name of the virtual environment (e.g., “foobar.Worker”)

  • force_rebuild (bool) – If True, force rebuild the venv even if it already exists

Returns:

Path to the python executable in the created virtual environment

Return type:

str

nemo_rl.utils.venvs._env_builder(
py_executable: str,
venv_name: str,
node_idx: int,
force_rebuild: bool = False,
)#
nemo_rl.utils.venvs.create_local_venv_on_each_node(py_executable: str, venv_name: str)#

Create a virtual environment on each Ray node.

Parameters:
  • py_executable (str) – Command to run with the virtual environment

  • venv_name (str) – Name of the virtual environment

Returns:

Path to the python executable in the created virtual environment

Return type:

str

nemo_rl.utils.venvs.make_actor_runtime_env(actor_class_fqn: str) dict#

Build a Ray runtime_env for one of our registered actors.

Resolves the actor’s tier-specific py_executable via the registry, materializes a per-node venv when uv-managed, and packages it with VIRTUAL_ENV / UV_PROJECT_ENVIRONMENT env vars so workers see the same interpreter as the driver.

Used by ReplayBuffer, AsyncTrajectoryCollector, and SyncRolloutActor — three actors that need the VLLM tier’s venv on every node. Also used by the SGLang router and SGLang generation engines (SGLANG tier).