Why can’t you stop buying 618?From the technical dimension to explore>>>
This error occurred while running torch
The error content probably means that the input type is CPU (torch. Floattensor), and the parameter type is GPU (torch. CUDA. Floattensor)
links to data types: Official links
First of all, please check whether CUDA is used correctly
We usually specify CUDA as follows:
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
inputs.to(device)
In this way, input is converted into CUDA type The correct way is to:device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
inputs = inputs.to(device)
Reason:
tensor. To() is used to generate a new tensor without changing the original data
However, note that
module. To() is an “in place” method, while the tensor. To() function is not
undertake MATLAB, Python and C + + programming, machine learning, computer vision theory implementation and guidance, undergraduate and master can, salted fish trading, professional answer please go to know, for details, please contact QQ number 757160542, if you are the one
This article shares in the blog “Yu Xiaoyong” (CSDN).
Similar Posts:
- Error in loading pre training weight in torch. Load() in pytorch
- [Solved] torch.cuda.CudaError: CUDA driver version is insufficient for CUDA runtime version (35) [ WARN:0
- Solutions to errors encountered by Python
- [Solved] RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
- [Solved] RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same
- [Solved] RuntimeError: Attempting to deserialize object on CUDA device 2 but torch.cuda.device_count() is 1
- RuntimeError: cuda runtime error (30) : unknown errorr
- Examples of torch.NN.Functional.Relu() and torch.NN.Relu()
- InternalError: cudaGetDevice() failed. Status: CUDA driver version is insufficient for CUDA runti…
- [Solved] pytorchImportError: numpy.core.multiarray failed to import