Here is my neural network code, using pytorch:
class BLSTM(nn.Module):
def __init__(self,vocab_size):
super(BLSTM,self).__init__()
self.Embeddings = nn.Embedding(vocab_size,100)
self.LSTM = nn.LSTM(100,128,bidirectional=True)
self.fc = nn.Linear(128*2,3)
self.dropout = nn.Dropout(0.5)
self.tanh = nn.Tanh()
def forward(self,X):
embed = self.Embeddings(X)
print(embed)
output , (hidden , cell) = self.LSTM(embed)
last_hidden = output[:, -1,:]
logits = self.fc(self.dropout(last_hidden))
self.tanh(logits)
return logits
I am getting cuda assertion error at model.to(“device”). Is there any problem with the dimensions specified or the network. I have checked with the memory allocation it’s fine I will post the error below
Cell In[52], line 10
7 device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
8 print(device)
---> 10 model.to(device)
11 X_train = np.squeeze(torch.tensor(X_train,dtype=torch.long))
12 X_val = np.squeeze(torch.tensor(X_val,dtype=torch.long))
File C:Python312Libsite-packagestorchnnmodulesmodule.py:1340, in Module.to(self, *args, **kwargs)
...
RuntimeError: CUDA error: device-side assert triggered
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.
Can anyone explain the real cause of this one?
I have to train the model with the given network but while allocating the model to gpu I have been facing this error. I can’t figure out. Otherwise they have been showing me error with tensors. The dimension of the tensors is 1.
02 Abinayasankar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.