Reputation: 1044
I would like to figure out, whether the PyTorch
model is on cpu
or cuda
in order to
initialize some other variable as Torch.Tensor
or Torch.cuda.Tensor
depending on the model.
However, looking at the output of the dir()
function I see only .cpu()
, .cuda()
, to()
methods which put the model on device, GPU or other device, specified in to. For PyTorch
tensor there is is_cuda
attribute, but no analogue for the whole model.
Is there some way to deduce this for a model, or one needs to refer to a particular weight?
Upvotes: 3
Views: 5318