Use Container Runtime

Snowflake Container Runtime is a preconfigured, versioned environment for machine learning that runs on CPU or GPU compute pools. You can run code on Container Runtime from two places:

  • Notebooks in Workspaces: Every notebook cell runs on Container Runtime.
  • A local IDE: Your code runs on your machine until you submit it to Container Runtime as an ML Job.

In both cases, Container Runtime includes Snowflake ML and popular open source frameworks, and you can install additional Python packages when your workflow needs them.

Preinstalled packages

Container Runtime includes the following Snowflake packages, along with popular open source data science and machine learning packages:

  • Snowflake ML (snowflake-ml-python) for feature engineering, modeling, and the Model Registry, plus distributed data loading, training, and hyperparameter optimization.
  • Snowpark (snowflake-snowpark-python) for DataFrame pipelines.
  • Snowpark Connect (snowpark-connect) for running Spark-style workloads against Snowflake.

For the full list of packages in each runtime version, see Snowflake Container Runtime release notes.

Use Container Runtime in Notebooks in Workspaces

Notebooks in Workspaces run on Container Runtime, so you can explore data and train models interactively on Snowflake compute.

Configure Container Runtime for a notebook

When you run a notebook in Workspaces, the notebook connects to a Snowflake-managed notebook service, which hosts the notebook kernel and runs your code. When you create the service, you configure the following settings:

  • Container Runtime version: The runtime version determines the Python version and the preinstalled packages. For the Python version and packages in each runtime, see Snowflake Container Runtime release notes.
  • Compute pool: The service runs on one node of the compute pool that you select. To train on GPUs, select a GPU compute pool.
  • External access integrations: Optional. Lets the notebook reach endpoints outside Snowflake, such as external package repositories.

All notebooks and Python files connected to the same service share the compute resources on that node. If a notebook needs dedicated resources, create a separate notebook service for it.

To scale training across multiple nodes, use Container Runtime 2.3 or later. For more information, see Compute setup for Snowflake Notebooks in Workspaces.

Install additional packages in a notebook

To install a package that isn’t in the runtime, run pip install in a Python cell or in the notebook terminal. To install pinned versions from a requirements.txt file, run the following command:

!pip install -r requirements.txt

Note

If a package version that you install conflicts with the supported versions of the preinstalled packages, the Python environment might break. Validate compatibility before you install.

Where pip gets the package depends on how your account is set up:

SourceUse when
Files in a workspace or stageYou have .whl or .py files to install or import, for example, private packages or shared utilities.
Artifact repositories (preview)You want packages from the Snowflake-managed PyPI repository or another package repository, with package policy enforcement.
External access integrationsYou need to reach external package repositories, such as PyPI, an internal PyPI server, or GitHub.
Custom runtime images (preview)You need full control over the container environment, such as system-level dependencies or a standard image for all notebooks.

For examples of each option, see Managing packages and runtime.

Use Container Runtime from a local IDE

When you develop in a local IDE, such as CoCo Desktop, VS Code, or Cursor, your Python code runs on your machine. To run code on Container Runtime, submit it as an ML Job with the @remote decorator or the submit_file or submit_directory function. The job runs on the compute pool that you specify, and you manage it from your local code. For setup steps, see Develop ML workflows locally.

Select a runtime version for a job

By default, a job runs on the latest Container Runtime version available on your compute pool. To use a specific version, pass the full version string in the runtime_environment argument:

@remote("MY_COMPUTE_POOL", stage_name="payload_stage", session=session, runtime_environment="2.3.0")
def train_model(data_table: str):
    ...

To run a job on a custom runtime image, use runtime_environment="cre@<name>".

Install additional packages for a job

Most jobs work with the preinstalled packages. To install other packages, list them in the pip_requirements argument. The job installs them from one of the following sources:

  • External access integration: The job reaches an external package index, such as PyPI. Pass the integration in the external_access_integrations argument. For more information, see Using an External Access Integration.
  • Artifact repository: The job installs packages from a Snowflake artifact repository, without external network access. For more information, see Using artifact repositories.

If you specify both, the job installs packages only from the artifact repositories.

@remote(
    "MY_COMPUTE_POOL",
    stage_name="payload_stage",
    pip_requirements=["custom-package"],
    external_access_integrations=["PYPI_EAI"],
    session=session,
)
def train_model():
    ...