daniilidis-group / neural_renderer

A PyTorch port of the Neural 3D Mesh Renderer
Other
1.12k stars 248 forks source link

dist_coeffs initialized with cuda:0, which causes error "expected device cuda:0 but got device cuda:2" #109

Closed xhuan8 closed 2 years ago

xhuan8 commented 3 years ago

File "/home/xiehuan/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(*input, kwargs) File "/home/xiehuan/anaconda3/lib/python3.8/site-packages/neural_renderer/renderer.py", line 76, in forward return self.render_silhouettes(vertices, faces, K, R, t, dist_coeffs, orig_size) File "/home/xiehuan/anaconda3/lib/python3.8/site-packages/neural_renderer/renderer.py", line 110, in render_silhouettes vertices = nr.projection(vertices, K, R, t, dist_coeffs, orig_size) File "/home/xiehuan/anaconda3/lib/python3.8/site-packages/neural_renderer/projection.py", line 33, in projection x_ = x(1 + k1(r2) + k2*(r4) + k3*(r6)) + 2p1x*y + p2*(r2 + 2*x_2) RuntimeError: expected device cuda:0 but got device cuda:2

renderer.py, line 41 self.dist_coeffs = torch.cuda.FloatTensor([[0., 0., 0., 0., 0.]])

zqq-judy commented 2 years ago

Have you solved this problem?

xhuan8 commented 2 years ago

Have you solved this problem?

set the visible devices like this

os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" os.environ["CUDA_VISIBLE_DEVICES"] = '0'