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

CUDA -> CPU issue #32

Closed
kamwoh opened this issue Jun 20, 2019 · 3 comments
Closed

CUDA -> CPU issue #32

kamwoh opened this issue Jun 20, 2019 · 3 comments

Comments

@kamwoh
Copy link

kamwoh commented Jun 20, 2019

def drop_connect(inputs, p, training):
    """ Drop connect. """
    if not training: return inputs
    batch_size = inputs.shape[0]
    keep_prob = 1 - p
    random_tensor = keep_prob
    random_tensor += torch.rand([batch_size, 1, 1, 1], dtype=inputs.dtype)  # uniform [0,1)
    binary_tensor = torch.floor(random_tensor)
    output = inputs / keep_prob * binary_tensor # error happens here
    return output

Faced error: RuntimeError: expected backend CUDA and dtype Float but got backend CPU and dtype Float

when I try to run on GPU, this error happens, the error direct me to this line, I think we should convert binary_tensor to inputs.device:

binary_tensor = torch.floor(random_tensor).to(inputs.device)

@dami23
Copy link

dami23 commented Jun 20, 2019

Hi kamwoh, do you use the efficientnet to train your own model or use pretrained models? If you use the pretrained models, the newly released version demands to add model.eval() after the model load.

@kamwoh
Copy link
Author

kamwoh commented Jun 20, 2019

Hi @dami23 , using pretrained models to finetune, yes I did model.eval()

@lukemelas
Copy link
Owner

Yup, this is now fixed in master. See #29
I'll push out another release to pip soon.

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

3 participants