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: indices should be either on cpu or on the same device as the indexed tensor (cpu) #11

Open
kaixin-bai opened this issue Apr 17, 2023 · 1 comment

Comments

@kaixin-bai
Copy link

while running python3 scripts/run_demo.py --gpu 0 --init_ckpt CPF_checkpoints/picr/fhb/checkpoint_200.pth.tar --honet_mano_fhb_hand, the visualization window flashes and an error occurs as below.

==============================  Options  >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
anchor_root                     :  assets/anchor
batch_size                      :  4
center_idx                      :  9
data_root                       :  data
exp_keyword                     :  None
gpu                             :  0
hand_closed_path                :  assets/closed_hand/hand_mesh_close.obj
hg_blocks                       :  1
hg_classes                      :  64
hg_stacks                       :  2
honet_mano_fhb_hand             :  True
honet_mano_lambda_pose_reg      :  5e-06
honet_mano_lambda_recov_joints3d  :  0.5
honet_mano_lambda_recov_verts3d  :  0
honet_mano_lambda_shape         :  5e-07
honet_obj_lambda_recov_verts2d  :  0.0
honet_obj_lambda_recov_verts3d  :  0.5
honet_obj_trans_factor          :  100
honet_resnet_version            :  18
init_ckpt                       :  CPF_checkpoints/picr/fhb/checkpoint_200.pth.tar
lambda_contact_loss             :  10.0
lambda_repulsion_loss           :  1.6
mano_root                       :  assets/mano
manual_seed                     :  0
obj_scale_factor                :  0.0001
palm_path                       :  assets/hand_palm_full.txt
repulsion_query                 :  0.02
repulsion_threshold             :  0.05
vertex_contact_thresh           :  0.7
workers                         :  16
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  Options  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Saving experiment logs, models, and training curves and images to checkpoints/picr_geo_example/example_example/2023_04_17_16
Got 10 samples for data_split example
==============================  example_dataset_queries  >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+------------------------------------+---------------------------------------+---------------------------------------+
|        BaseQueries.CAM_INTR        |         BaseQueries.HAND_FACES        |     BaseQueries.HAND_POSE_WRT_CAM     |
|     BaseQueries.HAND_VERTS_2D      |       BaseQueries.HAND_VERTS_3D       |           BaseQueries.IMAGE           |
|       BaseQueries.IMAGE_PATH       |         BaseQueries.JOINTS_2D         |         BaseQueries.JOINTS_3D         |
|       BaseQueries.JOINT_VIS        |       BaseQueries.OBJ_CAN_SCALE       |       BaseQueries.OBJ_CAN_TRANS       |
|     BaseQueries.OBJ_CAN_VERTS      |         BaseQueries.OBJ_FACES         |         BaseQueries.OBJ_TRANSF        |
|      BaseQueries.OBJ_VERTS_2D      |        BaseQueries.OBJ_VERTS_3D       |         BaseQueries.OBJ_VIS_2D        |
|          BaseQueries.SIDE          |     MetaQueries.SAMPLE_IDENTIFIER     |        TransQueries.AFFINETRANS       |
|       TransQueries.CAM_INTR        |         TransQueries.CENTER_3D        |       TransQueries.HAND_VERTS_2D      |
|     TransQueries.HAND_VERTS_3D     |           TransQueries.IMAGE          |         TransQueries.JOINTS_2D        |
|       TransQueries.JOINTS_3D       |        TransQueries.OBJ_TRANSF        |       TransQueries.OBJ_VERTS_2D       |
|     TransQueries.OBJ_VERTS_3D      |          TransQueries.ROTMAT          |                   -                   |
+------------------------------------+---------------------------------------+---------------------------------------+
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  example_dataset_queries  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
/home/kb/anaconda3/envs/cpf/lib/python3.8/site-packages/torch/utils/data/dataloader.py:561: UserWarning: This DataLoader will create 16 worker processes in total. Our suggested max number of worker in current system is 12, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary.
  warnings.warn(_create_warning_msg(
Loading resnet18 pretrained models !
=> loading checkpoint 'CPF_checkpoints/picr/fhb/checkpoint_200.pth.tar'
=> loaded checkpoint 'CPF_checkpoints/picr/fhb/checkpoint_200.pth.tar' (epoch 200)
Model total size == 93.72725296020508 MB
  |  HONet total size == 47.723751068115234 MB
  |  BaseNet total size == 25.7626953125 MB
  \  ContactHead total size == 20.240806579589844 MB
    |  EncodeModule total size == 4.4404296875 MB
    |  DecodeModule_VertexContact total size == 5.257816314697266 MB
    |  DecodeModule_ContactRegion total size == 5.266666412353516 MB
    |  DecodeModule_AnchorElasti total size == 5.2758941650390625 MB
Example Epoch 0
100%|██████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:01<00:00,  6.48it/s]

PICR DONE!
Got 10 samples for data_split example
Traceback (most recent call last):
  File "scripts/run_demo.py", line 715, in <module>
    main(args)
  File "scripts/run_demo.py", line 617, in main
    geo_stage(intermediate, args)
  File "scripts/run_demo.py", line 599, in geo_stage
    print_msg = run_sample(
  File "scripts/run_demo.py", line 461, in run_sample
    hoptim.set_opt_val(**opt_val_kwargs)
  File "/home/kb/Projects/CPF/hocontact/postprocess/geo_optimizer.py", line 141, in set_opt_val
    self.const_val["indexed_vertex_id"] = vertex_id[anchor_padding_mask == 1]  # TENSOR[NVALID, ]
RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)
@kaixin-bai
Copy link
Author

Problem solved by changing self.const_val["indexed_vertex_id"] = vertex_id[anchor_padding_mask == 1] to self.const_val["indexed_vertex_id"] = vertex_id.to('cpu')[anchor_padding_mask.to('cpu') == 1] on geo_optimizer.py line 141

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