Question 2
You have a PyTorch tensor
gpu_tensor = torch.tensor([1, 2, 3]).to('cuda')residing on the GPU. You then attempt to convert it directly to a NumPy array using
numpy_array = gpu_tensor.numpy()What will be the outcome of this operation?
It will successfully convert gpu_tensor to a NumPy array on the CPU.
It will successfully convert gpu_tensor to a NumPy array that also resides on the GPU.
It will raise a RuntimeError because NumPy arrays cannot directly operate on GPU memory.
It will create a view of the gpu_tensor on the CPU without copying data.
The numpy() method is not available for GPU tensors.