khorrams / IGOS_pp

https://igos.eecs.oregonstate.edu/
GNU General Public License v3.0
24 stars 4 forks source link

RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu) #9

Closed Pei4579 closed 8 months ago

Pei4579 commented 8 months ago

No matter which sample code I run, it turns out RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (CPU), however, when I look into the code I found that the indices are only used when opt==LS. Is there anything I missed? Thanks in advanced!

Screenshot 2024-02-15 at 18 04 40
Pei4579 commented 8 months ago

To fix this problem, just add .cuda() at the end of every label in methods.py as follows:

Screenshot 2024-02-16 at 14 12 39

Then you might get another issue about clone(), just add .clone() in methods_helper.py behind the indices as follows:

image
Pei4579 commented 8 months ago

Another tips while using this package: The path of the image refers to a folder with plenty of images, not a single image path. It means it's the path of a folder rather than an image, like home/user/images but not home/user/images/test_picture.png.