Skip to content

Conversation

@mattiagaggi
Copy link

@mattiagaggi mattiagaggi commented Dec 2, 2025

fixes #252

Summary

Fixes issue where several required packages were missing when running Jupyter notebooks after installing with pip install -e ".[notebooks]".

Changes

  • Added triton with platform-specific handling to notebooks optional dependencies
    • Windows: triton-windows; sys_platform == 'win32'
    • Linux/Mac: triton; sys_platform != 'win32'

Problem

Users reported missing modules when running notebooks:

  • einops (already present)
  • decord (already present)
  • pycocotools (already present)
  • triton / triton-windows (was missing)

Solution

The triton package is required for core model functionality (used in sam3/model/edt.py and sam3/model/sam3_tracker_utils.py). Adding it to the notebooks dependencies ensures it's automatically installed when users run pip install -e ".[notebooks]".

Testing

  • Verified triton is used in core inference code
  • Platform-specific markers ensure correct package installation on Windows vs Linux/Mac

This fixes the issue where importing sam3 causes cv2.imshow() to segfault
due to decord being imported at module level, which conflicts with OpenCV.

Changes:
- Removed module-level import of decord from sam3_image_dataset.py
- Added lazy import inside _load_images() method when processing .mp4 files
- Decord now only loads when actually needed, preventing the conflict

Fixes the issue reported where:
  import cv2
  from sam3.model_builder import build_sam3_image_model
  cv2.imshow('test', frame)  # Would segfault before this fix
- Add triton with platform-specific handling (triton-windows for Windows, triton for Linux/Mac)
- Fixes issue where einops, decord, pycocotools, and triton were missing when running Jupyter notebooks
- Addresses feedback from Windows users who had to manually install these packages
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Dec 2, 2025
Copy link

@drduhe drduhe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me and same thing as my comment in the other PR about potential README updates to let users know about the video support.

@rishavghosh605
Copy link

Great! Looking forward to this change so that I can run my notebook. Thanks @mattiagaggi and @drduhe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing modules after installation

4 participants