'torch.to(device) Not in effect

    token_embeddings.to(device)
    print(device)
    print(token_embeddings.device)

cuda:0 cpu

I use 'torch.to(device)', but it is not in effect.



Solution 1:[1]

.to() is not an in-place operation. So you need to do:

token_embeddings = token_embeddings.to(device)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DerekG