F.cross_entropy raised "RuntimeError: CUDA error: device-side assert triggered. Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions."
I met this error in loss function. An example below: import torch device = "cuda" if torch.cuda.is_available() else "cpu" a = torch.Tensor([[-10.3353, -28.4371, 2.0768, -4.2789, -8.6644, -6.0815], [-10.3353, -28.4371, 2.0768, -4.2789, -8.6644, -6.0815], [-10.3353, -28.4371, 2.0768, -4.2789, -8.6644, -6.0815], [-10.3353, -28.4371, 2.0768, -4.2789, -8.6644, -6.0815]]).to(device) b = torch.Tensor([ -100, -1, -100, 2456]).long().to(device) loss = torch.nn.functional.cross_entropy(a,b,ignore_index=-1) print(loss) Then the error is: -------------------------------------------------------------------
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.