FuxiCV / MeInGame

MeInGame: Create a Game Character Face from a Single Portrait, AAAI 2021
MIT License
653 stars 119 forks source link

RuntimeError: module must have its parameters and buffers on device cuda:0 (device_ids[0]) but found one of them on device: cuda:2 #7

Open hxngiee opened 3 years ago

hxngiee commented 3 years ago

Thanks for sharing your great work

I got some error when run the code

python main.py -m test -i demo

I'd appreciate your advice

Traceback (most recent call last):
  File "main.py", line 180, in <module>
    main()
  File "main.py", line 175, in main
    face_model=config.face_model)
  File "/home/ubuntu/hongiee/MeIn/uv_inpainting.py", line 363, in predict
    image, face_model)
  File "/home/ubuntu/hongiee/MeIn/uv_inpainting.py", line 295, in preprocess
    segments = self.segmenter.segment_torch(images)
  File "/home/ubuntu/hongiee/MeIn/lib/face_segment.py", line 92, in segment_torch
    segments = self.model(images)
  File "/home/ubuntu/anaconda3/envs/MeIn/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/ubuntu/anaconda3/envs/MeIn/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 146, in forward
    "them on device: {}".format(self.src_device_obj, t.device))
RuntimeError: module must have its parameters and buffers on device cuda:0 (device_ids[0]) but found one of them on device: cuda:2
Agent-INF commented 3 years ago

Looks like you are using more than one GPU. A possible solution is to change the device from 'cuda' to a specific GPU device, e.g. 'cuda:0'.

https://github.com/FuxiCV/MeInGame/blob/da9cff0251df9cf0378f4e171f55bbd0ed22b04b/main.py#L95

cravisjan97 commented 3 years ago

Is there a way to run the code on multiple GPUs as my single GPU has low memory?