torch icon indicating copy to clipboard operation
torch copied to clipboard

Request: provide `to(device = "cuda_pseudo")` to test that code runs on GPU

Open sebffischer opened this issue 2 years ago • 1 comments

First of all, thank you for your great package!

In order to test that code runs on CPUs and GPUs on machines (especially for CI) that does not have a GPU available, it would be convenient to have a cuda_pseudo device. The tensor would still live on the "CPU", but combining tensors on e.g. a "cpu" and "cuda_pseudo" device should throw an error.

sebffischer avatar Feb 14 '22 12:02 sebffischer

Hi @sebffischer !

Thanks for opening this issue! You can try device="meta" as mentioned here: https://github.com/pytorch/pytorch/issues/61654 It still won't error if for some reason an operation is not available on the CUDA device.

Actually we'll need https://github.com/mlverse/torch/pull/787 for this to work. But it won't be ideal because meta tensors doesn't have any data, so computations are not actually happening, making it hard to completely test the R code.

dfalbel avatar Feb 14 '22 14:02 dfalbel