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: Could not infer dtype of numpy.int64 #66

Open
sahikabetul opened this issue Oct 29, 2024 · 1 comment
Open

RuntimeError: Could not infer dtype of numpy.int64 #66

sahikabetul opened this issue Oct 29, 2024 · 1 comment

Comments

@sahikabetul
Copy link

sahikabetul commented Oct 29, 2024

Hello, thanks for great work!

I am trying to running the code with 3D data you provided, but I got this error. I set up Ubuntu Docker:
Operating System: Ubuntu 22.04 (FROM ubuntu:22.04)
Conda Version: 24.9.2
Python Version: 3.12.4
PyTorch: 2.4
CUDA: 12.1 (Cunda suggests that or 11.8 version for pytorch 2.4)

It seems problem related to data loader. Do you have any recommendations?

Epoch 0:   0%|                                                                                                                                                                                    | 0/25 [00:04<?, ?img/s]
Traceback (most recent call last):
  File "/data/medicalSAM2/Medical-SAM2/train_3d.py", line 112, in <module>
    main()
  File "/data/medicalSAM2/Medical-SAM2/train_3d.py", line 95, in main
    loss, prompt_loss, non_prompt_loss = function.train_sam(args, net, optimizer1, optimizer2, nice_train_loader, epoch)
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/medicalSAM2/Medical-SAM2/func_3d/function.py", line 73, in train_sam
    for pack in train_loader:
  File "/opt/miniconda/envs/medsam2/lib/python3.12/site-packages/torch/utils/data/dataloader.py", line 701, in __next__
    data = self._next_data()
           ^^^^^^^^^^^^^^^^^
  File "/opt/miniconda/envs/medsam2/lib/python3.12/site-packages/torch/utils/data/dataloader.py", line 1465, in _next_data
    return self._process_data(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda/envs/medsam2/lib/python3.12/site-packages/torch/utils/data/dataloader.py", line 1491, in _process_data
    data.reraise()
  File "/opt/miniconda/envs/medsam2/lib/python3.12/site-packages/torch/_utils.py", line 715, in reraise
    raise exception
RuntimeError: Caught RuntimeError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/opt/miniconda/envs/medsam2/lib/python3.12/site-packages/torch/utils/data/_utils/worker.py", line 351, in _worker_loop
    data = fetcher.fetch(index)  # type: ignore[possibly-undefined]
           ^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda/envs/medsam2/lib/python3.12/site-packages/torch/utils/data/_utils/fetch.py", line 55, in fetch
    return self.collate_fn(data)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda/envs/medsam2/lib/python3.12/site-packages/torch/utils/data/_utils/collate.py", line 398, in default_collate
    return collate(batch, collate_fn_map=default_collate_fn_map)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda/envs/medsam2/lib/python3.12/site-packages/torch/utils/data/_utils/collate.py", line 172, in collate
    key: collate(
         ^^^^^^^^
  File "/opt/miniconda/envs/medsam2/lib/python3.12/site-packages/torch/utils/data/_utils/collate.py", line 172, in collate
    key: collate(
         ^^^^^^^^
  File "/opt/miniconda/envs/medsam2/lib/python3.12/site-packages/torch/utils/data/_utils/collate.py", line 172, in collate
    key: collate(
         ^^^^^^^^
  File "/opt/miniconda/envs/medsam2/lib/python3.12/site-packages/torch/utils/data/_utils/collate.py", line 155, in collate
    return collate_fn_map[elem_type](batch, collate_fn_map=collate_fn_map)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda/envs/medsam2/lib/python3.12/site-packages/torch/utils/data/_utils/collate.py", line 285, in collate_numpy_array_fn
    return collate([torch.as_tensor(b) for b in batch], collate_fn_map=collate_fn_map)
                    ^^^^^^^^^^^^^^^^^^
RuntimeError: Could not infer dtype of numpy.int64
@sahikabetul
Copy link
Author

sahikabetul commented Nov 7, 2024

And, when running 2D code with your provided dataset and weights, I don't face any problem like this. For your information

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

1 participant