Skip to content

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

Open
hdnh2006 wants to merge 1 commit into
ahmedbesbes:mainfrom
hdnh2006:main
Open

This PR solves allow all tensors will be in the same device#8
hdnh2006 wants to merge 1 commit into
ahmedbesbes:mainfrom
hdnh2006:main

Conversation

@hdnh2006

@hdnh2006 hdnh2006 commented Mar 30, 2023

Copy link
Copy Markdown

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