monniert/differentiable-blocksworld

Cpu and Cuda device mismatch error

Closed this issue · 3 comments

louhz commented

So in the line 422 in dbw.py
I notice that you define a val_blocks which is on cpu and the self.get_opacities() is on the gpu
so there will be a error raised
My personal solution is to revise the line 422 from val_blocks = torch.linspace(0, 1, self.n_blocks + 1)[1:]
to
val_blocks = torch.linspace(0, 1, self.n_blocks + 1)[1:].to(self.bkg.device)

and line 429 from values = torch.cat([torch.zeros(NFE) , val_blocks.repeat_interleave(self.BNF)])

to
values = torch.cat([torch.zeros(NFE).to(self.bkg.device) , val_blocks.repeat_interleave(self.BNF)])

and the problem is solved

i am not sure whether this is a common issue or just happened on my device
so just remark it here.

Hi louhz, what is your pytorch version? I have never encountered the issue so it may be linked with a new pytorch behavior related to indexing

Anyway I will fix it tomorrow, thanks for the feedback and solution!

louhz commented

Hi louhz, what is your pytorch version? I have never encountered the issue so it may be linked with a new pytorch behavior related to indexing

Anyway I will fix it tomorrow, thanks for the feedback and solution!

I am using pytorch1.13+cuda 11.7,which is the environment i used for nerfstudio 0.3.1

Got it thanks, it is indeed a new feature implemented in pytorch 1.13 as explained below (screenshot from this release note)

screenshot