Device-side assert triggered at /pytorch/aten/src/THC/generic/THCTensorMathPointwise.cu:59

PrudviRaj_J: <p>I’m getting this error in evaluation!!</p>
<p>Here is error snippet</p>
<p>/pytorch/aten/src/THC/THCTensorIndex.cu:362: void indexSelectLargeIndex(TensorInfo&lt;T, IndexType&gt;, TensorInfo&lt;T, IndexType&gt;, TensorInfo&lt;long, IndexType&gt;, int, int, IndexType, IndexType, long) [with T = float, IndexType = unsigned int, DstDim = 2, SrcDim = 2, IdxDim = -2, IndexIsMajor = true]: block: [7,0,0], thread: [127,0,0] Assertion <code>srcIndex &lt; srcSelectDimSize</code> failed.<br>
THCudaCheck FAIL file=/pytorch/aten/src/THC/generic/THCTensorMathPointwise.cu line=59 error=59 : device-side assert triggered</p>
<p>Traceback (most recent call last):<br>
File “evaluate.py”, line 102, in <br>
main()<br>
File “evaluate.py”, line 93, in main<br>
results = evaluate(model, val_loader, maps[“aid_to_ans”], device)<br>
File “/home/cs15resch01005/.local/lib/python2.7/site-packages/torch/autograd/grad_mode.py”, line 43, in decorate_no_grad<br>
return func(*args, **kwargs)<br>
File “evaluate.py”, line 30, in evaluate<br>
output = model(img, q, lengths)<br>
File “/home/cs15resch01005/.local/lib/python2.7/site-packages/torch/nn/modules/module.py”, line 489, in <strong>call</strong><br>
result = self.forward(*input, **kwargs)<br>
File “/raid/cs15resch01005/vqa/VisualQA/models/mcb.py”, line 118, in forward<br>
q = self.embedding(ques)  # BxTxD<br>
File “/home/cs15resch01005/.local/lib/python2.7/site-packages/torch/nn/modules/module.py”, line 489, in <strong>call</strong><br>
result = self.forward(*input, **kwargs)<br>
File “/home/cs15resch01005/.local/lib/python2.7/site-packages/torch/nn/modules/container.py”, line 92, in forward<br>
input = module(input)<br>
File “/home/cs15resch01005/.local/lib/python2.7/site-packages/torch/nn/modules/module.py”, line 489, in <strong>call</strong><br>
result = self.forward(*input, **kwargs)<br>
File “/home/cs15resch01005/.local/lib/python2.7/site-packages/torch/nn/modules/activation.py”, line 292, in forward<br>
return torch.tanh(input)<br>
RuntimeError: cuda runtime error (59) : device-side assert triggered at /pytorch/aten/src/THC/generic/THCTensorMathPointwise.cu:59</p>
<p>Can any one tell me how to go about it…? Thanks in advance</p>
<p>p.s.: used “CUDA_LAUNCH_BLOCKING=1”</p>

albanD: <p>Hi,</p>
<p>The error comes from <code>q = self.embedding(ques) # BxTxD</code> so inside your embedding layer and the assert states <code>Assertion srcIndex &lt; srcSelectDimSize failed.</code><br>
So I would guess that one of the index given to your embedding layer in <code>ques</code> is larger than the number of classes it was created with?</p>

PrudviRaj_J: <p>Hi…thank you,</p>
<p>I’m bit confused with the answer… am I trying to embed a token which is not in vocabulary or is it issue with the length of the question!!</p>
<p>here is my embedding layer initialization…</p>
<pre><code>    self.embedding = nn.Sequential(
        nn.Embedding(vocab_size, embed_dim, padding_idx=0),
        # nn.Linear(vocab_size, embed_dim),
        nn.Tanh())</code></pre>

albanD: <p>All the indices passed to the forward should be in [0, vocab_size - 1].<br>
This error happens because <code>ques</code> contains a value that is not in that range.</p>