Managing packages and runtime¶
Snowflake Notebooks run inside a pre-built container environment optimized for scalable AI/ML development powered by Snowflake Container Runtime.
Python versions¶
Snowflake Notebooks support Python 3.10 to 3.12. When creating a notebook service, select the Python version that best fits your workload requirements.
Pre-installed packages¶
Snowflake Container Runtime includes approximately 100 packages and libraries that support a wide range of ML development tasks inside Snowflake. These packages run natively on the Snowflake-managed CPU and GPU infrastructure.
To view the pre-installed packages, run pip freeze in a Python cell or in the notebook terminal.
Installing additional packages¶
Snowflake supports package installation from several sources.
From external repositories¶
After configuring External Access Integrations (EAIs) for secure repository access, you can install packages directly from external sources such as PyPI. Users have access to a comprehensive ecosystem of packages beyond the pre-installed runtime, ensuring secure connectivity to external repos.
You can run pip install in a Python cell or in the notebook terminal.
For more information, see Set up external access for Snowflake Notebooks.
From requirements.txt¶
You can specify and install required package versions in a requirements.txt file to ensure a consistent environment setup. Install them
using the following command:
!pip install -r requirements.txt
Note
If the package version specified in requirements.txt conflicts with supported versions of the
pre-installed packages, the Python environment may break. Validate compatibility before
installing.
From Workspace files¶
You can download or build .whl or .py files, upload them to your workspace, and install or import them.
Wheel files (:file:`.whl`): Upload the
.whlfile and install it:!pip install file_name.whl
If the package contains dependencies that are not already installed, upload the complete dependency tree (either directly into Workspaces or to a stage). Alternatively, attach an EAI that allows access to a repository where the package can be downloaded (for example, PyPI).
Python files (:file:`.py`): Modules stored in your workspace can be imported directly for sharing utilities and functions across notebooks. For example:
from my_utils import my_func
From a Snowflake stage¶
Stages provide secure and governed package deployment by leveraging existing Snowflake data storage and governance controls for package files. Use the Snowpark session to retrieve package files from a Snowflake stage into the container environment for import and use. For example:
from snowflake.snowpark.context import get_active_session
import sys
session = get_active_session()
session.file.get("@db.schema.stage_name/math_tools.py", "/tmp")
sys.path.append("/tmp")
import math_tools
math_tools.add_one(3)
Runtime management¶
Runtime pinning¶
All notebook services are pinned to the Runtime selected at creation unless you explicitly change it by editing the service. For example, a notebook
service created on Runtime 2.0 will not be automatically upgraded when new Runtime versions are released.
Runtime vulnerability scanning¶
Snowflake scans the Runtime images daily for security vulnerabilities. High or critical Common Vulnerabilities and Exposures (CVEs) are addressed by releasing new Runtime versions within 30 days of detection.
Existing notebook services can continue using Runtimes with detected CVEs. However, Runtimes with known CVEs cannot be selected when creating new notebook services.