管理包和运行时

Snowflake 笔记本在针对可扩展 AI/ML 开发优化的预构建容器环境中运行,并由 Snowflake 容器运行时提供支持。

Python 版本

Snowflake 笔记本支持 Python 3.10 至 3.12。创建笔记本服务时,请选择最适合您工作负载要求的 Python 版本。

Pre-installed Snowflake Container Runtime packages

Snowflake Container Runtime version 2.2 includes approximately 100 packages and libraries that support a wide range of ML development tasks inside Snowflake.

以下部分列出了每个 Python 版本的 Snowflake 容器运行时版本 2.2 可用的预安装包的精选子集(每个环境 40 个条目)。

备注

To view the full list of pre-installed packages for your current notebook environment, run pip freeze in a Python cell or in the notebook terminal.

CPU version 2.2

以下包适用于 CPU 版本 2.2 的每个 Python 版本:

CPU 容器运行时 Python 3.10 版本 2.2 包括以下包:

Version

absl-py

2.3.1

aiobotocore

2.26.0

aiohappyeyeballs

2.6.1

aiohttp

3.13.3

aiohttp-cors

0.8.1

aioitertools

0.13.0

aiosignal

1.4.0

altair

5.5.0

annotated-doc

0.0.4

annotated-types

0.7.0

anyio

4.12.1

appdirs

1.4.4

argon2-cffi

25.1.0

argon2-cffi-bindings

25.1.0

arrow

1.4.0

arviz

0.23.1

asn1crypto

1.5.1

asttokens

3.0.1

async-lru

2.1.0

async-timeout

5.0.1

attrs

25.4.0

babel

2.17.0

bayesian-optimization

1.5.1

beautifulsoup4

4.14.3

bleach

6.3.0

blinker

1.9.0

boto3

1.41.5

botocore

1.41.5

cachetools

5.5.2

CausalPy

0.5.0

certifi

2026.1.4

cffi

1.17.1

charset-normalizer

3.4.4

click

8.2.1

clikit

0.6.2

cloudpickle

3.1.1

cmdstanpy

1.3.0

colorama

0.4.6

colorful

0.5.8

comm

0.2.3

GPU version 2.2

以下包适用于 GPU 版本 2.2 的每个 Python 版本:

GPU 容器运行时 Python 3.10 版本 2.2 包括以下包:

Version

absl-py

2.3.1

accelerate

1.12.0

aiobotocore

2.26.0

aiohappyeyeballs

2.6.1

aiohttp

3.13.3

aiohttp-cors

0.8.1

aioitertools

0.13.0

aiosignal

1.4.0

airportsdata

20250909

altair

5.5.0

annotated-doc

0.0.4

annotated-types

0.7.0

anyio

4.12.1

appdirs

1.4.4

argon2-cffi

25.1.0

argon2-cffi-bindings

25.1.0

arrow

1.4.0

arviz

0.23.1

asn1crypto

1.5.1

astor

0.8.1

asttokens

3.0.1

async-lru

2.1.0

async-timeout

5.0.1

attrs

25.4.0

babel

2.17.0

bayesian-optimization

1.5.1

beautifulsoup4

4.14.3

blake3

1.0.8

bleach

6.3.0

blinker

1.9.0

boto3

1.41.5

botocore

1.41.5

cachetools

5.5.2

CausalPy

0.5.0

certifi

2026.1.4

cffi

1.17.1

charset-normalizer

3.4.4

click

8.2.1

clikit

0.6.2

cloudpickle

3.1.1

安装附加包

Snowflake 支持从多个来源安装包。

来自外部存储库

在配置了用于安全访问存储库的外部访问集成 (EAIs) 后,您可以直接从外部源(例如 PyPI)安装包。除了预安装的运行时外,用户还可以访问全面的包生态系统,从而确保与外部存储库的安全连接。

您可以在 Python 单元格或笔记本终端中运行 pip install

有关更多信息,请参阅 为 Snowflake Notebooks 设置外部访问

requirements.txt 安装

您可以在 requirements.txt 文件中指定并安装所需的包版本,以确保一致的环境设置。使用以下命令安装它们:

!pip install -r requirements.txt
Copy

备注

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.

来自工作区文件

您可以下载或构建 .whl.py 文件,将它们上传到您的工作区,并进行安装或导入。

  • Wheel files (.whl): Upload the .whl file and install it:

    !pip install file_name.whl
    
    Copy

    如果包包含尚未安装的依赖关系,请上传完整的依赖关系树(直接上传到工作区或暂存区)。或者,附加一个 EAI,允许访问可以下载包的存储库(例如 PyPI)。

  • Python files (.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
    
    Copy

来自 Snowflake 暂存区

暂存区利用现有的 Snowflake 数据存储和包文件的治理控制,提供安全且受监管的包部署。使用 Snowpark 会话将包文件从 Snowflake 暂存区检索到容器环境中,以便导入和使用。例如:

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)
Copy

运行时管理

运行时固定

所有笔记本服务都固定在创建时选择的运行时,除非您通过编辑服务明确更改它。例如,在 Runtime 2.0 上创建的笔记本服务在发布新的运行时版本时不会自动升级。

运行时漏洞扫描

Snowflake 每天都会扫描运行时镜像以查找安全漏洞。检测到高危或严重的常见漏洞与披露 (CVEs) 后,会在 30 天内通过发布新的运行时版本来解决。

现有的笔记本服务可以继续使用检测到 CVEs 的运行时。但是,在创建新的笔记本服务时,无法选择已知存在 CVEs 的运行时。

语言: 中文