Need help training SAM2

Hi all, I am currently following this blog post by @ James Gallagher (@rfjames ?)

Step 1 and 2 are done successfully, but I am stuck on step 3. When I run this in my Jupyter Notebook:

!python training/train.py -c 'configs/train.yaml' --use-cluster 0 --num-gpus 1

I get this error:

Traceback (most recent call last):
  File "/home2/minorai4/capstone/test/lucas4/sam2/training/train.py", line 270, in <module>
    main(args)
  File "/home2/minorai4/capstone/test/lucas4/sam2/training/train.py", line 124, in main
    cfg = compose(config_name=args.config)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home2/minorai4/.local/lib/python3.12/site-packages/hydra/compose.py", line 38, in compose
    cfg = gh.hydra.compose_config(
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home2/minorai4/.local/lib/python3.12/site-packages/hydra/_internal/hydra.py", line 594, in compose_config
    cfg = self.config_loader.load_configuration(
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home2/minorai4/.local/lib/python3.12/site-packages/hydra/_internal/config_loader_impl.py", line 142, in load_configuration
    return self._load_configuration_impl(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home2/minorai4/.local/lib/python3.12/site-packages/hydra/_internal/config_loader_impl.py", line 243, in _load_configuration_impl
    self.ensure_main_config_source_available()
  File "/home2/minorai4/.local/lib/python3.12/site-packages/hydra/_internal/config_loader_impl.py", line 129, in ensure_main_config_source_available
    self._missing_config_error(
  File "/home2/minorai4/.local/lib/python3.12/site-packages/hydra/_internal/config_loader_impl.py", line 102, in _missing_config_error
    raise MissingConfigException(
hydra.errors.MissingConfigException: Primary config module 'sam2' not found.
Check that it's correct and contains an __init__.py file

I have no idea how to solve this issue as I have successfully followed every prior step in detail. Can anyone help me? Much appreciated.
I’m working in a Linux environment if that matters.

Same problem: python - SAM 2.1 what is causing hydra.errors.MissingConfigException: Primary config module 'sam2' not found? - Stack Overflow

I also tried this:

cp /home2/minorai4/capstone/test/lucas4/sam2/sam2/configs/train.yaml /home2/minorai4/.local/lib/python3.12/site-packages/sam2_configs

ls
__init__.py  __pycache__  sam2_hiera_b+.yaml  sam2_hiera_l.yaml  sam2_hiera_s.yaml  sam2_hiera_t.yaml  train.yaml

Wow what a great help, no response after 8 days!

Just passing through here and saw this. Not sure if you’ve stumbled on this page yet, but it has a few proposed solutions for this type of problem: Config files are missing → hydra.errors.MissingConfigException:Cannot find primary config ‘sam2_hiera_l.yaml’ · Issue #81 · facebookresearch/sam2 · GitHub

One interesting item on that page relates to what you tried. Where you moved the train.yaml to the site-packages folder, it almost sounds like this guy moved sam2_configs over to the project. And if it makes you feel any better, one guy on there actually submitted your problem as a Hydra initialization fix, so apparently you’re not alone.

1 Like

I am trying to fine tune the model using images and points as prompts but my GPU memory keeps running out I can tune my model using upto 256 points per image but beyond that it isnt working , I even trying to batch points but the code is going haywire