Recall & Review
beginner
What is a GPU tensor in PyTorch?
A GPU tensor is a tensor stored in the GPU's memory, allowing faster computation by using the GPU's parallel processing power.
Click to reveal answer
beginner
How do you move a tensor to the GPU using the
to() method?You call
tensor.to('cuda') to move the tensor to the GPU if available.Click to reveal answer
beginner
What does
tensor.cuda() do in PyTorch?It moves the tensor to the default GPU device, similar to
tensor.to('cuda').Click to reveal answer
intermediate
Why should you check if a GPU is available before moving tensors to it?
Because if no GPU is available, trying to move tensors to GPU will cause errors. Use
torch.cuda.is_available() to check.Click to reveal answer
intermediate
What is the difference between
tensor.to('cuda') and tensor.cuda()?tensor.to('cuda') can specify any device and is more flexible. tensor.cuda() moves tensor to the default GPU device. Both move tensors to GPU memory.Click to reveal answer
Which PyTorch method moves a tensor to the GPU?
✗ Incorrect
The
to('cuda') method moves a tensor to the GPU device.What does
torch.cuda.is_available() check?✗ Incorrect
It checks if a GPU device is available for PyTorch to use.
What happens if you try to move a tensor to GPU when no GPU is available?
✗ Incorrect
Trying to move a tensor to GPU without a GPU causes an error.
Which method is more flexible for moving tensors between devices?
✗ Incorrect
tensor.to() can move tensors to any device, not just GPU.What device does
tensor.cuda() move the tensor to?✗ Incorrect
tensor.cuda() moves the tensor to the default GPU device.Explain how to move a tensor to GPU in PyTorch and why it is useful.
Think about device names and checking if GPU exists.
You got /3 concepts.
Describe the difference between
tensor.to('cuda') and tensor.cuda().Consider device flexibility and default behavior.
You got /3 concepts.