Running Error Messages
Error Message |
Solution |
||||
|---|---|---|---|---|---|
Running error message: "RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU." |
To avoid this error, add map_location=torch.device('cpu') to the error code line. |
||||
Running error message: "Unsupport data type: at::ScalarType::Double." |
To avoid this error, add the data type conversion statement before the error code line. If the error code line is pos = label.data.eq(1).nonzero(as_tuple =False).squeeze().npu(), which does not support data type conversion, add label = label.cpu().float().npu() to the previous line of the code. |
||||
Running error message: "IndexError: invalid index of a 0-dim tensor. Use tensor.item() in Python or tensor.item<T>() in C++ to convert a 0-dim tensor to a number." |
If such an error occurs, change .data[0] to .item() in the code. For example:
is changed to:
|
||||
Running error message: "Could not run 'aten::empty_with_format' with arguments from the 'CPUTensorId' backend. 'aten::empty_with_format' is only available for these backend "CUDA, NPU"." |
Place the tensors on the NPU, for example, input = input.npu(). |
||||
Running error message: "options.device().type() == DeviceType::NPU INTERNAL ASSERT FAILED xxx:" |
Place the tensors on the NPU, for example, input = input.npu(). |
||||
Running error message: "Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False." |
This error is generally caused by the torch.load() API. The keyword map_location needs to be added, for example, map_location='cpu' or map_location='npu'. |
||||
Running error message: "RuntimeError: Incoming model is an instance of torch.nn.parallel.DistributedDataParallel. Parallel wrappers should only be applied to the model(s) AFTER." |
This error occurs because the torch.nn.parallel.DistributedDataParallel API is called before the apex.amp.initial API. To solve this problem, manually move the APIs to ensure that the apex.amp.initial API is called before the torch.nn.parallel.DistributedDataParallel API. |