.jpeg)
Deploy When Available is now GA
Queue for any GPU spec, even one that's fully rented out, and we'll deploy it the moment capacity opens up. No more refreshing the console or running a sniping tool.
Blog
Segment Anything Model 2 (SAM 2) offers real-time segmentation power. This guide walks you through running it efficiently on Runpod’s cloud GPUs.

Meta has unveiled Segment Anything Model 2 (SAM 2), a revolutionary advancement in object segmentation. Building on the success of its predecessor, SAM 2 integrates real-time, promptable object segmentation for both images and videos, enhancing accuracy and speed. Its ability to operate across previously unseen visual domains holds significant promise for various fields, from creative video editing to scientific research. Check out this demo video showcasing SAM 2's video segmentation capabilities.
Demo video from Meta
SAM 2 is the first unified model capable of real-time, promptable segmentation for both images and videos. It effectively handles complex motion, occlusion, and lighting variations, overcoming challenges that traditional segmentation models struggled with. The comparison below highlights SAM 2's performance against prior segmentation models, showcasing its superior segmentation benchmarks and frame processing speed, making it ideal for video processing.

SAM 2's real-time processing capabilities allow it to handle video frames efficiently, making it suitable for applications requiring quick image and video segmentation. The model’s ability to process multiple objects simultaneously enhances its applicability in various scenarios. If you'd like to read more about how SAM 2 works, check out Meta's blog.
In this blog, we'll show you how you can get started with a simple SAM 2 use-case:
Prerequisites




Once you've connected to your jupyter notebook, follow these steps to run SAM 2. If you click on "Connect to Jupyter Lab [Port 8888]" and see an error message, wait a few minutes and try again.
!git clone https://github.com/facebookresearch/segment-anything-2
%cd segment-anything-2
!pip install -e .
%cd checkpoints
!./download_ckpts.sh
!pip install opencv-python-headless
File paths for the different models:
| Model Name | Checkpoint File Path | Configuration File Path |
|---|---|---|
| SAM 2 Tiny | ./checkpoints/sam2_hiera_tiny.pt | sam2_hiera_t.yaml |
| SAM 2 Small | ./checkpoints/sam2_hiera_small.pt | sam2_hiera_s.yaml |
| SAM 2 Base Plus | ./checkpoints/sam2_hiera_base_plus.pt | sam2_hiera_b_plus.yaml |
| SAM 2 Large | ./checkpoints/sam2_hiera_large.pt | sam2_hiera_l.yaml |
You should have achieved the desired output image where the input point (indicated by a star) guides SAM 2 to display a mask over the rest of the segmented object. In this example, the segmented object is the man in the image.

By following these troubleshooting tips, you can resolve common issues and ensure a smooth experience running SAM 2 on Runpod. If problems persist, consult the documentation or seek support from the community.
nvidia-smivenv or conda for this purposevenv:python -m venv myenvsource myenv/bin/activate # On Windows, use myenv\Scripts\activatepython -m pip install --upgrade pip
pip install -r requirements.txtpython -m pip install --upgrade pip
pip install -r requirements.txtComment below with any problems you may be facing for support – We're here to help you every step of the way!
The SAM 2 model, as demonstrated through our example of segmenting objects in an image, extends its capabilities to videos as well. This powerful model offers extensive opportunities for customization and enhancement, thanks to its open-source nature. Researchers and developers can fine-tune SAM 2 to address specific needs by adjusting the model's parameters and training it on specialized datasets. This adaptability is particularly useful in domains requiring high precision or tailored segmentation performance, including the processing of multiple objects within a single frame.
Additionally, SAM 2's capabilities are not just limited to video segmentation. Its performance in image processing and segmentation is equally impressive, making it a versatile tool for various applications. The ability to handle diverse video content efficiently opens up new possibilities for video processing and analysis.
Hopefully, you found this tutorial helpful, and if you're ready to deploy or fine-tune SAM 2 for your use case, head over to Runpod and unlock the full potential of this cutting-edge segmentation model!
Author profile: Shaamil Karim
Blog Posts
.jpeg)
Queue for any GPU spec, even one that's fully rented out, and we'll deploy it the moment capacity opens up. No more refreshing the console or running a sniping tool.

Explore why faster chips have shifted the bottleneck to AI infrastructure, and what that means for teams running production workloads.
.jpeg)
With MIG, we can partition RTX 6000 Pro cards into isolated 24 GB instances. Here's when it makes sense for your workloads.