Snowflake

Snowpark Container Services (SPCS) Complete Guide: Compute Pools to GPU Inference

2026-03-26
更新: 2026-03-27
NicheeLab Editorial Team

Snowpark Container Services (SPCS) lets you run OCI container images directly inside Snowflake's managed environment. Workloads that cannot run on a warehouse — ML inference, LLM hosting, web apps, custom ETL — can all operate under Snowflake's security and governance umbrella.

SPCS Architecture

SPCS is built from three components: compute pools, an image registry, and services. A compute pool is a cluster of nodes that runs the containers — completely isolated from warehouse compute resources. The image registry is an OCI-compatible private registry embedded in your Snowflake account, accessible from the docker CLI via push/pull. A service is the execution unit deployed on top of a compute pool.

Creating a Compute Pool

A compute pool is the cluster of nodes that runs your service containers. INSTANCE_FAMILY selects the CPU/GPU type, and MIN_NODES / MAX_NODES define the autoscaling range.

-- CPU compute pool (for lightweight API servers)
CREATE COMPUTE POOL ml_cpu_pool
  MIN_NODES = 1
  MAX_NODES = 3
  INSTANCE_FAMILY = CPU_X64_S
  AUTO_RESUME = TRUE
  AUTO_SUSPEND_SECS = 600;

-- GPU compute pool (for ML inference)
CREATE COMPUTE POOL gpu_inference_pool
  MIN_NODES = 1
  MAX_NODES = 2
  INSTANCE_FAMILY = GPU_NV_S
  AUTO_RESUME = TRUE
  AUTO_SUSPEND_SECS = 300;

-- Inspect compute pool state
SHOW COMPUTE POOLS IN ACCOUNT;
DESCRIBE COMPUTE POOL gpu_inference_pool;

The main INSTANCE_FAMILY options are listed below.

INSTANCE_FAMILYCPU/GPUMemoryTypical Use Case
CPU_X64_XS2 vCPU8 GBLightweight batch, testing
CPU_X64_S4 vCPU16 GBAPI servers, ETL
CPU_X64_M8 vCPU32 GBMid-scale processing
GPU_NV_S1 GPU (T4 class)16 GB GPUSmall to mid-scale inference
GPU_NV_M1 GPU (A10G class)24 GB GPUMid-scale inference and training
GPU_NV_L1 GPU (A100 class)40/80 GB GPULLMs, large-scale training

Image Registry

SPCS provides an OCI-compliant private image registry built into your Snowflake account. Authenticate with the docker CLI and push prebuilt images.

-- Create an image repository
CREATE IMAGE REPOSITORY ml_images;

-- Check the repository URL
SHOW IMAGE REPOSITORIES;
-- e.g. myorg-myacct.registry.snowflakecomputing.com/ml_db/ml_schema/ml_images

-- Log in and push from the CLI
-- docker login myorg-myacct.registry.snowflakecomputing.com
-- docker tag my-model:v1 myorg-myacct.registry.snowflakecomputing.com/ml_db/ml_schema/ml_images/my-model:v1
-- docker push myorg-myacct.registry.snowflakecomputing.com/ml_db/ml_schema/ml_images/my-model:v1

Access to image repositories is governed by Snowflake's RBAC: you grant READ/WRITE privileges to roles. SPCS cannot pull directly from external registries like Docker Hub, so you need a workflow that builds images locally or in CI/CD and then re-pushes them into the Snowflake registry.

Creating and Deploying a Service

A service is the container execution unit, defined by a YAML service specification (spec). Upload the spec file to a Snowflake stage and start the service with CREATE SERVICE.

-- Upload the service spec (spec.yaml) to a stage
PUT file:///tmp/spec.yaml @ml_db.ml_schema.service_stage
  AUTO_COMPRESS = FALSE
  OVERWRITE = TRUE;

-- Create the service
CREATE SERVICE ml_inference_service
  IN COMPUTE POOL gpu_inference_pool
  FROM @ml_db.ml_schema.service_stage
  SPEC = 'spec.yaml'
  MIN_INSTANCES = 1
  MAX_INSTANCES = 3
  EXTERNAL_ACCESS_INTEGRATIONS = (egress_integration);

-- Check service status
SHOW SERVICES IN ACCOUNT;
SELECT SYSTEM$GET_SERVICE_STATUS('ml_inference_service');
SELECT SYSTEM$GET_SERVICE_LOGS(
  'ml_inference_service', 0, 'inference-container', 100
);

Structure of the Service Spec YAML

spec.yaml defines container images, ports, environment variables, volume mounts, and similar properties.

# Example spec.yaml
spec:
  containers:
    - name: inference-container
      image: /ml_db/ml_schema/ml_images/my-model:v1
      resources:
        requests:
          nvidia.com/gpu: 1
        limits:
          nvidia.com/gpu: 1
          memory: 8Gi
      env:
        MODEL_PATH: /models/v1
      readinessProbe:
        port: 8080
        path: /health
  endpoints:
    - name: predict
      port: 8080
      public: true
  volumes:
    - name: model-volume
      source: "@ml_db.ml_schema.model_stage"
      uid: 1000
      gid: 1000

SQL Integration via Service Functions

To call a service from SQL, create a service function. This lets you fetch the container's inference results from inside a SELECT statement.

-- Create a service function
CREATE FUNCTION predict_sentiment(text VARCHAR)
  RETURNS VARIANT
  SERVICE = ml_inference_service
  ENDPOINT = predict
  AS '/predict';

-- Invoke inference from SQL
SELECT
  review_id,
  review_text,
  predict_sentiment(review_text) AS sentiment
FROM product_reviews
WHERE review_date >= '2026-01-01';

GPU-Enabled ML/AI Workloads

There are three typical use cases for GPUs on SPCS.

  • Model Inference: Run inference servers like TensorFlow Serving, Triton, or vLLM on a GPU compute pool and perform batch inference from SQL via service functions.
  • Fine-Tuning: Run Hugging Face Transformers training loops inside containers and persist the trained model to a Snowflake stage.
  • LLM Hosting: Host open models such as Llama in a vLLM container and offer chat or summarization features without sending internal data outside the boundary.

Networking and Security

SPCS services have outbound network access blocked by default. When containers need to call external APIs or download models, create an External Access Integration to authorize egress traffic.

-- Create a network rule
CREATE NETWORK RULE hf_egress_rule
  TYPE = HOST_PORT
  MODE = EGRESS
  VALUE_LIST = ('huggingface.co:443', 'cdn-lfs.huggingface.co:443');

-- Create the External Access Integration
CREATE EXTERNAL ACCESS INTEGRATION egress_integration
  ALLOWED_NETWORK_RULES = (hf_egress_rule)
  ENABLED = TRUE;

For ingress, you can expose an endpoint by setting public: true, with access controlled by Snowflake authentication tokens.

Cost and Autoscaling

Compute pool cost is determined by node count times uptime times the INSTANCE_FAMILY unit price. AUTO_SUSPEND_SECS automatically suspends the pool when idle, and AUTO_RESUME brings it back up on the next request. Setting MIN_INSTANCES=0 lets a service scale all the way down to zero instances when there is no traffic.

Key Exam Takeaways

  • SPCS containers run on compute pools rather than virtual warehouses (note the different billing model).
  • The image registry is a private registry built into Snowflake; direct pulls from public registries are not allowed.
  • Architecture allows you to invoke container processing from SQL via service functions.
  • External communication requires an External Access Integration (egress is blocked by default).
  • The mapping between GPU_NV_S / GPU_NV_M / GPU_NV_L instance families and their respective use cases.

Check Your Understanding

SnowPro

問題 1

When deploying a GPU-based ML inference service on Snowpark Container Services (SPCS), which sequence of steps is correct?

  1. Create a compute pool with INSTANCE_FAMILY = GPU_NV_S, push the container image to the Snowflake built-in image registry, then deploy with CREATE SERVICE.
  2. Create a virtual warehouse with GPU_NV_S specified and run the container image directly by referencing it in a CREATE FUNCTION statement.
  3. Write a Docker Hub URL into the FROM clause of CREATE SERVICE so SPCS pulls the image directly from Docker Hub.
  4. Create a GPU-enabled External Stage, load model files, and execute inference on a virtual warehouse.

正解: A

The correct flow for SPCS is: (1) create a compute pool with a GPU instance family, (2) push the image to the built-in Snowflake registry, and (3) deploy with CREATE SERVICE. The exam frequently tests that compute pools (not warehouses) are used, and that direct pulls from external registries are not supported.

Frequently Asked Questions

What GPU instance types are available in Snowpark Container Services?

The compute pool INSTANCE_FAMILY can be set to GPU_NV_S (NVIDIA T4 class), GPU_NV_M (A10G class), or GPU_NV_L (A100 class). GPU_NV_S is well suited for inference, while GPU_NV_L is the right choice for fine-tuning and large-scale training — pick the size based on compute intensity. Available families vary by cloud region, so always confirm with the output of SHOW COMPUTE POOLS IN ACCOUNT.

How is the SPCS image registry different from Docker Hub?

SPCS uses an OCI-compliant image registry built into Snowflake, and you upload images with the docker push command. The registry URL takes the form <org>-<account>.registry.snowflakecomputing.com/<db>/<schema>/<image_repo>, and Snowflake's authentication, RBAC, and network policies all apply directly. Direct pulls from public registries like Docker Hub are not supported, so prebuilt images must be re-pushed into the Snowflake registry.

Do SPCS services consume virtual warehouse credits?

No. SPCS services run as containers on a compute pool, using compute resources that are completely separate from virtual warehouses. Billing is based on compute pool node count multiplied by uptime, calculated under the Serverless Credit model. SQL issued from a service to access Snowflake tables via a service function may consume warehouse credits, but the container execution itself is independent of warehouses.

Check what you learned with practice questions

Practice with certification-focused question sets

無料で問題を解いてみる
Author

NicheeLab Editorial Team

NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.


Related articles
Snowflake

Snowflake Certifications: All 11 Exams Explained (2026)

Every SnowPro certification — Associate, Core, Specialty, Ad...

Snowflake

Snowflake Exam Difficulty Ranking: All 11 Certs Compared (2026)

All 11 SnowPro exams ranked by difficulty with study-time es...

Snowflake

Snowflake Study Guide: Fastest Pass Route by Exam (2026)

How to pass SnowPro certifications efficiently — official ma...

Snowflake

SnowPro Core (COF-C03): Complete Exam Guide (2026)

Pass the SnowPro Core exam — six domains, scope, sample ques...

Snowflake

SnowPro Associate Platform (SOL-C01): Complete Guide (2026)

The entry-level SnowPro Associate exam — scope, weighting, s...

Browse all Snowflake articles (103)
© 2026 NicheeLab All rights reserved.