Skip to content

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