Summary:
`Sam3BasePredictor.close_session` already calls `gc.collect()` after
popping the session from `_all_inference_states`, but never tells
PyTorch to return the freed allocations to the device. PyTorch's
caching allocator keeps them in its per-process pool, so
`cuda.memory_reserved()` (and the production deployment metric
`dyno.twtask.gpu_memory_utilization_avg` derived from it) climbs
monotonically across long-running workloads even though the Python-side session is gone.
Change: in `sam3/model/sam3_base_predictor.py`, call
`torch.cuda.empty_cache()` after the existing `gc.collect()`, gated on
the same `run_gc_collect` flag so the no-collect path is unchanged.
Wrapped in `torch.cuda.is_available()` for the (rare) CPU test path.
`empty_cache()` causes a CUDA synchronization, so it has a small cost per close. The existing `run_gc_collect` flag already acknowledges this trade-off (`gc.collect()` is also non-free), and the default has always been True, so the call site contract is preserved.
Reviewed By: arpitkalla
Differential Revision: D103081459
fbshipit-source-id: 71da61d28b822f4af5dd5c72ffdeca0f542a8b97
Summary:
Default to multi-GPUs to avoid OOM. CPU offload seems to not helping as it still need to copy back into memory for tracking
___
overriding_review_checks_triggers_an_audit_and_retroactive_review
Oncall Short Name: storytelling_ai_fsx_health
Differential Revision: D102039480
fbshipit-source-id: c3540efb984382756ead223f16b66f5d87bbeb0b
Summary: better design between LLM and SAM3 due to the embedding issue of SAM3
Reviewed By: mchorton
Differential Revision: D101818594
fbshipit-source-id: b51c36defc6ed4adae5406e8eba31280e05cac9a
Summary: Fix SAM3 io_utils.py to handle extensionless video files from OIL (Object Image Library). Previously, the code would immediately raise NotImplementedError when encountering files without recognized video extensions. This change attempts to load such files as videos using the video loader, only raising an exception if the actual decoding fails. This enables SAM3 to process OIL-stored video paths that don't include file extensions.
Differential Revision: D99228861
fbshipit-source-id: c93d089ad4b7eac9e0eb629d7a71b021604db410