Skip to content
This repository has been archived by the owner on Jul 21, 2021. It is now read-only.

GPU mode is not available ! #4

Closed
shwoo93 opened this issue Jul 20, 2017 · 3 comments
Closed

GPU mode is not available ! #4

shwoo93 opened this issue Jul 20, 2017 · 3 comments

Comments

@shwoo93
Copy link

shwoo93 commented Jul 20, 2017

Hello oeway

Firstly, thanks for sharing your pytorch version code of deformable convolution.
When I tried to port your code to another code which uses CUDA mode, it gives me an error saying like below.

'Type torch.cuda.FloatTensor doesn't implement stateless method range'

However, when I change it to CPU mode, there is no error.

It seems like 'torch.range' does not fit on GPU mode in torch. Then what should be the solution?

Thanks in advance

@oeway
Copy link
Owner

oeway commented Jul 20, 2017

hi @shwoo93 , the library meant to work with GPU/cuda and cpu, in https://github.com/oeway/pytorch-deform-conv/blob/master/scaled_mnist.py you can see we use it in cuda mode, and when I test it, I use cuda as well, I am sure it will work with GPU.

Plus, I couldn't find torch.range in my code, perhaps it from your own code?

@shwoo93
Copy link
Author

shwoo93 commented Jul 21, 2017

@oeway Thanks for reply.
Actually in the deform_conv.py file there is a function called "th_batch_map_coordinates" which uses torch.range.
Anyway, you mean that there is no problem in usage of it and also did not the error occured in torch.range?

@oeway
Copy link
Owner

oeway commented Jul 21, 2017

hi, that's right, there is indeed a torch.range:

    idx = th_repeat(torch.range(0, batch_size-1), n_coords).long()
    idx = Variable(idx, requires_grad=False)
    if input.is_cuda:
        idx = idx.cuda()

however, if you read the code, you will found that my torch.range is actually working in cpu mode, and after it may convert to cuda if the input is in cuda mode. So it still doesn't mean it caused by torch.range.

Come back to your question, yes, we have no problem when running in cuda mode.

@oeway oeway closed this as completed Mar 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants