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

This PR solves allow all tensors will be in the same device #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hdnh2006
Copy link

@hdnh2006 hdnh2006 commented Mar 30, 2023

If in the function transform (https://github.com/hdnh2006/cartoonify/blob/a37167c5cda7a56362395271d30aecd5098bbbcd/cartoongan/test_from_code.py#L14) we set gpu = 0. The code fails because torch.FloatTensor([n]) is not set in the same device as var, so the operation

var = var.unsqueeze(2).unsqueeze(3).expand_as(x) * (
            (n - 1) / torch.FloatTensor([n]).to(var.device)
        )

will fail...

… device

If in the function `transform` (https://github.com/hdnh2006/cartoonify/blob/a37167c5cda7a56362395271d30aecd5098bbbcd/cartoongan/test_from_code.py#L14) we set `gpu = 0`. The code fails because `torch.FloatTensor([n])` is not set in the same device as var, so the operation 

```
var = var.unsqueeze(2).unsqueeze(3).expand_as(x) * (
            (n - 1) / torch.FloatTensor([n]).to(var.device)
        )
```

will fail...
@hdnh2006 hdnh2006 changed the title This PR solves a bug about a RuntimeError, all tensors will be in the same… This PR solves allow all tensors will be in the same device Mar 30, 2023
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

Successfully merging this pull request may close these issues.

1 participant