How to register a (repeatedly) sampled random tensor? #14131
-
In my code, with each batch, I sample a random tensor. However, when I try porting to GPU, I get an error that I'm trying to multiply a tensor on CPU with a tensor on GPU. The documentation states
The example given is:
Using this example, suppose I want to randomly sample a 3x3 matrix |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
I just found this answer from 2020: https://stackoverflow.com/questions/63660624/normal-distribution-sampling-in-pytorch-lightning Is the best solution currently to specify the device? |
Beta Was this translation helpful? Give feedback.
-
That's the 2020 solution. Is there not a more modern approach?
…On Tue, Aug 9, 2022, 8:05 PM Akihiro Nitta ***@***.***> wrote:
In my code, with each batch, I sample a random tensor. However, when I try
porting to GPU, I get an error that I'm trying to multiply a tensor on CPU
with a tensor on GPU.
As the thread suggests, you need to move your tensor to GPU manually with
self.device in each iteration.
—
Reply to this email directly, view it on GitHub
<#14131 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACEHLCYYBOTRQSDD7EPBGPLVYMMBJANCNFSM56C3FX2Q>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
Ok cool thank you!
Cheers,
Rylan Schaeffer
…On Tue, Aug 9, 2022 at 8:58 PM Akihiro Nitta ***@***.***> wrote:
There's no "modern" approach I could think of, and I'd rather say that
PyTorch and PyTorch Lightning are stable enough to keep the same APIs for a
few years now :)
—
Reply to this email directly, view it on GitHub
<#14131 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACEHLCZYJOVFMVCBXAKFUILVYMSFJANCNFSM56C3FX2Q>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
I just found this answer from 2020: https://stackoverflow.com/questions/63660624/normal-distribution-sampling-in-pytorch-lightning
Is the best solution currently to specify the device?