Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: "view size is not compatible with input tensor's size and stride" during 2D training on Google Colab #50

Open
ayyucedemirbas opened this issue Sep 30, 2024 · 1 comment

Comments

@ayyucedemirbas
Copy link

I encountered an issue while training the 2D case on Google Colab. Here's the error message:

      `/content/Medical-SAM2/sam2_train/modeling/sam/transformer.py:22: UserWarning: Flash Attention is disabled as it requires a GPU with Ampere (8.0) CUDA capability.
  OLD_GPU, USE_FLASH_ATTN, MATH_KERNEL_ON = get_sdpa_settings()
  INFO:root:Namespace(net='sam2', encoder='vit_b', exp_name='REFUGE_MedSAM2', vis=True, train_vis=False, prompt='bbox', prompt_freq=2, pretrain=None, val_freq=1, gpu=True, gpu_device=0, image_size=1024, out_size=1024, distributed='none', dataset='REFUGE', sam_ckpt='./checkpoints/sam2_hiera_small.pt', sam_config='sam2_hiera_s', video_length=2, b=4, lr=0.0001, weights=0, multimask_output=1, memory_bank_size=16, data_path='/content/Medical-SAM2/REFUGE', path_helper={'prefix': 'logs/REFUGE_MedSAM2_2024_09_30_12_34_25', 'ckpt_path': 'logs/REFUGE_MedSAM2_2024_09_30_12_34_25/Model', 'log_path': 'logs/REFUGE_MedSAM2_2024_09_30_12_34_25/Log', 'sample_path': 'logs/REFUGE_MedSAM2_2024_09_30_12_34_25/Samples'})
  Namespace(net='sam2', encoder='vit_b', exp_name='REFUGE_MedSAM2', vis=True, train_vis=False, prompt='bbox', prompt_freq=2, pretrain=None, val_freq=1, gpu=True, gpu_device=0, image_size=1024, out_size=1024, distributed='none', dataset='REFUGE', sam_ckpt='./checkpoints/sam2_hiera_small.pt', sam_config='sam2_hiera_s', video_length=2, b=4, lr=0.0001, weights=0, multimask_output=1, memory_bank_size=16, data_path='/content/Medical-SAM2/REFUGE', path_helper={'prefix': 'logs/REFUGE_MedSAM2_2024_09_30_12_34_25', 'ckpt_path': 'logs/REFUGE_MedSAM2_2024_09_30_12_34_25/Model', 'log_path': 'logs/REFUGE_MedSAM2_2024_09_30_12_34_25/Log', 'sample_path': 'logs/REFUGE_MedSAM2_2024_09_30_12_34_25/Samples'})
  Traceback (most recent call last):
    File "/content/Medical-SAM2/train_2d.py", line 124, in <module>
      main()
    File "/content/Medical-SAM2/train_2d.py", line 97, in main
      tol, (eiou, edice) = function.validation_sam(args, nice_test_loader, epoch, net, writer)
    File "/content/Medical-SAM2/func_2d/function.py", line 335, in validation_sam
      vision_feats_temp = vision_feats[-1].permute(1, 0, 2).view(B, -1, 64, 64) 
  RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.`

Could you provide guidance on how to resolve this issue or any suggestions to address this dimensionality problem?

Thanks for your support.

@yarinbar
Copy link

yarinbar commented Oct 8, 2024

I get the same error. Did you fix that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants