Guide · ComfyUI · SAM 3 / 3.1
How to Install SAM 3 in ComfyUI Two clearly separated routes: ComfyUI’s native SAM 3.1 nodes and templates, or the community ComfyUI-SAM3 node pack by PozzettiAndrea. Then a step-by-step image and video workflow you can run right away.
Pick a route
Native Nodes or the Community Pack?
Both run SAM 3 inside ComfyUI. They are separate projects with different nodes; don’t mix their workflows.
| A · Native | B · ComfyUI-SAM3 | |
|---|---|---|
| Made by | Comfy-Org (built into ComfyUI) | Community: PozzettiAndrea |
| Model | SAM 3.1 (fp16 repack) | SAM 3 via the pack’s loader |
| Prompts | Text (with :N limits) | Text, points, boxes, multi-region |
| Install | Update ComfyUI + 1 file | Manager or git clone |
| Templates | Built-in image + video | Community workflows |
| Best for | Most users; start here | Interactive point/box selection |
Before you start
Prepare ComfyUI
A recent ComfyUI, enough disk, and an NVIDIA GPU.
- Recent ComfyUI: native SAM 3.1 arrived in a 2026 update; use the latest release, or Nightly if nodes are missing.
- ComfyUI Manager installed, for the community route and missing nodes.
- GPU: NVIDIA strongly recommended. System requirements
- No GPU? Comfy Cloud has ComfyUI-SAM3 preinstalled on managed GPUs.
update ComfyUI
# manual (git) install: update ComfyUI
cd ComfyUI
git pull
pip install -r requirements.txt
# desktop / portable builds: use the built-in updater insteadRoute A · Official
Native SAM 3.1 in ComfyUI
Maintained with ComfyUI itself. Recommended for most users.
- 1Update ComfyUINative SAM 3.1 support needs a recent build; use Nightly if the nodes are missing.
- 2Download the modelsam3.1_multiplex_fp16.safetensors from Comfy-Org/sam3.1 into ComfyUI/models/checkpoints/.
- 3Open the templateWorkflow → Browse Templates → Utility → “SAM3: Image Segmentation”.
- 4Load an imagePut it in ComfyUI/input/ and pick it in the Load Image node.
- 5Type a promptA short noun such as person, car or cat; separate several with commas.
- 6RunQueue the workflow and check the RGBA mask preview.
download the model (or use the browser link on Comfy-Org/sam3.1)
# from the ComfyUI folder: puts the file in models/checkpoints/
pip install -U huggingface_hub
hf download Comfy-Org/sam3.1 checkpoints/sam3.1_multiplex_fp16.safetensors --local-dir models| Item | Value |
|---|---|
| Model file | sam3.1_multiplex_fp16.safetensors (~1.6 GiB) |
| Source | Comfy-Org/sam3.1 on Hugging Face (SAM License) |
| Folder | ComfyUI/models/checkpoints/ |
| Image template | “SAM3: Image Segmentation” (utility_image_segment_sam3.json) |
| Video template | “SAM3: Video Segmentation” (utility_video_segment_sam3.json) |
| Where | Workflow → Browse Templates → Utility |
Route B · Community
Community Integration: ComfyUI-SAM3 by PozzettiAndrea
Use this pack if you want interactive point, box and multi-region selection.
ComfyUI-SAM3 by PozzettiAndrea ·
github.com/PozzettiAndrea/ComfyUI-SAM3
SAM 3 image and video segmentation with text prompts, boxes and points. Version 0.1.21 at the time of writing, with 14 nodes and tens of thousands of installs. It installs its dependencies in an isolated environment using the experimental comfy-env tool, which downloads the pixi package manager.
install
# option 1: ComfyUI Manager
# Manager → Custom Nodes Manager → search “ComfyUI-SAM3” → Install → Restart → refresh browser
# option 2: manual
cd ComfyUI/custom_nodes
git clone https://github.com/PozzettiAndrea/ComfyUI-SAM3
# restart ComfyUI; follow the pack’s README for its one-time dependency setupif the nodes don’t appear
# nodes missing and the log mentions “pytest mode”? (false positive)
SAM3_FORCE_INIT=1 python main.py- Model access: SAM 3 weights are gated; request access first. Hugging Face access
- Model files: the “(down)Load SAM3 Model” node downloads and loads the model; follow the pack’s README for paths.
- Updates: update through the Manager; check the repo’s releases for breaking changes.
- Other community packs exist, e.g.
comfyui_sam3(wouterverweirder) andComfyUI-TBG-SAM3(Ltamann), plusComfyUI-SAM3DObjects(PozzettiAndrea) for 3D. Use one SAM 3 pack at a time.
Tested workflow
Step-by-Step: Your First SAM 3 Mask in ComfyUI
This uses the official native template, so it doesn’t depend on custom nodes. Comfy-Org ships and documents it with its sample image.
- 1OpenWorkflow → Browse Templates → Utility → SAM3: Image Segmentation.
- 2Check the modelThe loader should list
sam3.1_multiplex_fp16.safetensors; if it’s red, the file isn’t inmodels/checkpoints/. - 3Load an imageKeep the template’s
neon_guitarist.pngfor a first test, or choose your own fromComfyUI/input/. - 4PromptType
person. - 5RunClick Run / Queue. The first run loads the model and is slower.
- 6CheckThe preview shows the person on a transparent (RGBA) background. Then try
guitar, orperson, guitar.
We documented this from Comfy-Org’s official template and guide; we did not run it on our own hardware. Node names can change between ComfyUI releases, so trust the template over screenshots.
Prompts
How to Prompt SAM 3 in ComfyUI
Short, concrete nouns work best. Two bits of syntax do the rest.
- Several subjects: separate with commas:
person, guitar. - Limit detections: add
:N, e.g.eye:2, window panels:4. - Keep it short: prompts are capped at 32 tokens.
- Be specific: “red car”, not “the car that is red on the left”.
- More tips: SAM 3 prompts guide
Video
Video Segmentation Workflow
Same idea, across frames: one prompt, masks and boxes for every frame.
- 1TemplateUtility → SAM3: Video Segmentation.
- 2Load VideoStart with the sample
drinking_unicorn.mp4, then your own clip. - 3PromptDescribe what to track, e.g.
unicorn. - 4RunOutput: masks and bounding boxes for each frame.
Long or high-resolution clips need lots of VRAM; trim first. Slow tracking
Use the masks
What to Do With the Masks
Common recipes
- Background removal: mask → alpha → save PNG.
- Inpainting: mask → inpaint nodes to replace or remove an object.
- Compositing: mask a subject and place it on a new background.
- Video effects: per-frame masks for colour grading or blur.
Customise
- The templates use Subgraph nodes; open them to tweak thresholds and outputs.
- Save your edited graph as your own workflow.
- Export masks for other tools. Mask formats
- Background removal guide
Troubleshooting
ComfyUI SAM 3 Problems and Fixes
| Symptom | Route | Fix |
|---|---|---|
| No SAM3 templates or nodes | Native | Update ComfyUI; try Nightly; check the startup log for import errors |
| Model loader shows red / not found | Native | Put the file in ComfyUI/models/checkpoints/, then refresh |
| Nodes missing, log says “pytest mode” | ComfyUI-SAM3 | Start with SAM3_FORCE_INIT=1 |
| Red nodes after loading a shared workflow | Either | Manager → Install Missing Custom Nodes, restart, refresh the browser |
| 401 / gated error on download | ComfyUI-SAM3 | Request access and log in. Model access |
| Empty mask | Either | Shorter noun; check the subject is visible. Empty masks |
| Out of memory | Either | Smaller images, shorter clips, fewer subjects. OOM fixes |
| Two SAM 3 packs conflict | Community | Keep one SAM 3 pack enabled at a time |
Questions
ComfyUI SAM 3 FAQ
Does ComfyUI support SAM 3 natively?
Yes. Native SAM 3.1 support was added to ComfyUI, with built-in “SAM3: Image Segmentation” and “SAM3: Video Segmentation” templates. Update ComfyUI first; if the nodes are missing, try the Nightly build.
Which model file does native ComfyUI SAM 3 use?
sam3.1_multiplex_fp16.safetensors from the Comfy-Org/sam3.1 repository, placed in ComfyUI/models/checkpoints/.
What is ComfyUI-SAM3?
A community node pack by PozzettiAndrea (github.com/PozzettiAndrea/ComfyUI-SAM3) that adds SAM 3 image and video segmentation with text prompts, boxes and points, including point, box and multi-region collector nodes. It is not made by Meta or Comfy-Org.
Should I use the native nodes or ComfyUI-SAM3?
Start with the native nodes and templates: they’re maintained with ComfyUI and use SAM 3.1. Use ComfyUI-SAM3 if you need its interactive point, box and multi-region collectors or a workflow built for it.
How do I prompt SAM 3 in ComfyUI?
Use short nouns. Separate several subjects with commas and limit detections with :N, for example “eye:2, window panels:4”. Prompts are capped at 32 tokens.
Why don’t the ComfyUI-SAM3 nodes appear?
Check the startup log for import errors. If it says it is running in pytest mode, that is a false positive: set SAM3_FORCE_INIT=1 before starting ComfyUI.
Can I use SAM 3 in ComfyUI without a GPU?
Comfy Cloud has the ComfyUI-SAM3 pack preinstalled on managed GPUs. Locally, an NVIDIA GPU is strongly recommended.