cxliu0 / PET

[ICCV 2023] Point-Query Quadtree for Crowd Counting, Localization, and More
MIT License
53 stars 5 forks source link

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

Closed xiaotongtongxue closed 7 months ago

xiaotongtongxue commented 8 months ago

The code running in the 5th epoch showed the above problem. The pet.py in models: points_queries_win = points_queries_win[:, v_idx].reshape(-1, 2)

cxliu0 commented 8 months ago

It seems that points_queries_win and v_idx were not in the same device. Did you run the model on CPU? You can check the status of points_queries_win and v_idx.

heeeyk commented 7 months ago

Add v_idx = v_idx.cpu() before points_queries_win = points_queries_win[:, v_idx].reshape(-1, 2).

cxliu0 commented 7 months ago

Glad to see you solve this issue. As I expected, this error occurs when the model is running on the CPU.