Complete the code to move the tensor to GPU using the recommended method.
import torch x = torch.tensor([1, 2, 3]) x_gpu = x.[1]('cuda')
The to method is the recommended way to move tensors to a device like GPU by specifying 'cuda'.
Complete the code to check if CUDA is available before moving the tensor to GPU.
import torch x = torch.tensor([4, 5, 6]) if torch.cuda.is_available(): x_gpu = x.[1]('cuda')
Using to('cuda') moves the tensor to GPU if CUDA is available.
Fix the error in the code to move the tensor to GPU correctly.
import torch x = torch.tensor([7, 8, 9]) x_gpu = x.[1]()
The cuda() method moves the tensor to the default CUDA device without arguments.
Fill both blanks to create a tensor on GPU and then move it back to CPU.
import torch x_gpu = torch.tensor([10, 11, 12], device=[1]) x_cpu = x_gpu.[2]()
Specify device='cuda' to create tensor on GPU, then use cpu() to move it back to CPU.
Fill all three blanks to create a tensor on CPU, then move it to GPU.
import torch x = torch.tensor([13, 14, 15], device=[1]) x_gpu = x.[2]([3])
Create tensor on CPU with device='cpu', move to GPU with to('cuda').
