reason
The reason for the error is that when calculating the loss function in pytorch, the tag is (batch, height, width). If the category is 10, the value should be 0 ~ 9, that is:
0 & lt= value<= C-1, where C is the number of channels or categories
terms of settlement
My category is 10, and the value is 1 ~ 10, so you only need to subtract 1, as shown below.
c_loss = nn.CrossEntropyLoss()
labels_v = labels_v-1
loss0 = c_loss(d0, labels_v.long())
Summary
This is mainly because the tag data of your training data may exceed the number of tags set in the configuration file. Or the number of tags in the validation set exceeds the number of tags in the training set.
Read More:
- CUDA error: device-side assert triggered
- Solve runtimeerror: reduce failed to synchronize: device side assert triggered problem
- RuntimeError: cuda runtime error (100) : no CUDA-capable device is detected at /opt/conda/conda-bld/
- [MMCV]RuntimeError: CUDA error: no kernel image is available for execution on the device
- Tensorflow 2.1.0 error resolution: failed call to cuinit: CUDA_ ERROR_ NO_ DEVICE: no CUDA-capable device is detected
- Runtimeerror using Python training model: CUDA out of memory error resolution
- [Solved] RuntimeError: CUDA error: CUBLAS_STATUS_ALLOC_FAILED when calling `cublasCreate(handle)`
- (29)RuntimeError: cuda runtime error (999)
- linux/tensorflow: failed call to cuDevicePrimaryCtxRetain: CUDA_ERROR_INVALID_DEVICE
- Resolved failed call to cuinit: CUDA_ ERROR_ NO_ DEVICE
- RuntimeError: CUDA out of memory. Tried to allocate 600.00 MiB (GPU 0; 23.69 GiB total capacity)
- CUDA Error: no kernel image is available for execution on device
- RuntimeError: CUDA error: out of memory solution (valid for pro-test)
- FCOS No CUDA runtime is found, using CUDA_HOME=’/usr/local/cuda-10.0′
- RuntimeError:cuda runtime error (11) : invalid argument at /pytorch/aten/src/THC/generic
- Successfully solved runtimeerror: CUDA runtime error (30)
- RuntimeError: reciprocal is not implemented for type torch.cuda.LongTensor
- RuntimeError: CUDA error: CUBLAS_STATUS_ALLOC_FAILED when calling `cublasCreate(handle)`
- RuntimeError: cuda runtime error (801) : operation not supported at ..
- (Solved) pytorch error: RuntimeError: cuDNN error: CUDNN_STATUS_EXECUTION_FAILED (install cuda)