Device-side assert triggered when indexing Variable

I have a problem.

X is a Variable with data type torch.cuda.FloatTensor of size [batch, channel, height, width], I need to index X with another array, e.g., Y = X[[0,0,1,1], [0,0,1,2]]. Just like the indexing function implemented in numpy. Here is the link: https://docs.scipy.org/doc/numpy-1.13.0/reference/arrays.indexing.html

However, the following cuda runtime error occurs:
RuntimeError: cuda runtime error (59) : device-side assert triggered at /opt/conda/conda-bld/pytorch_1513368888240/work/torch/lib/THC/generic/THCTensorCopy.c:u6708:

Can anybody help me? Thank you!

can you provide some detailed codes?
I successfully ran the code:

In [5]: x = Variable(torch.rand(4,4,6,6).float().cuda())
In [6]: x[[0,0,1,1], [0,0,1,2]]
Out[6]:
Variable containing:
(0 ,.,.) =
  0.0536  0.8146  0.2198  0.8843  0.0909  0.5957
  0.5594  0.5765  0.4912  0.1037  0.6114  0.5850
  0.2046  0.9204  0.6541  0.9111  0.7655  0.0295
  0.4252  0.0390  0.3985  0.3781  0.1474  0.4645
  0.3400  0.5792  0.9092  0.8746  0.7981  0.2196
  0.9684  0.0403  0.4658  0.1431  0.1791  0.5528

(1 ,.,.) =
  0.0536  0.8146  0.2198  0.8843  0.0909  0.5957
  0.5594  0.5765  0.4912  0.1037  0.6114  0.5850
  0.2046  0.9204  0.6541  0.9111  0.7655  0.0295
  0.4252  0.0390  0.3985  0.3781  0.1474  0.4645
  0.3400  0.5792  0.9092  0.8746  0.7981  0.2196
  0.9684  0.0403  0.4658  0.1431  0.1791  0.5528

(2 ,.,.) =
  0.1920  0.1025  0.8752  0.1457  0.4408  0.6199
  0.4907  0.2977  0.5841  0.9648  0.4388  0.7658
  0.1677  0.4246  0.8092  0.4428  0.6915  0.9568
  0.3977  0.4039  0.6715  0.3573  0.8866  0.5088
  0.4417  0.6852  0.3386  0.3615  0.3620  0.1906
  0.1631  0.8739  0.4914  0.0973  0.5423  0.5640

(3 ,.,.) =
  0.0175  0.1227  0.9219  0.3272  0.9943  0.3625
  0.9067  0.8286  0.7752  0.2652  0.0888  0.1214
  0.9223  0.6107  0.3258  0.7162  0.1455  0.4190
  0.3259  0.5121  0.2324  0.7902  0.8987  0.9333
  0.9374  0.2191  0.1943  0.8746  0.5152  0.5083
  0.4812  0.3931  0.6239  0.0956  0.9269  0.8745
[torch.cuda.FloatTensor of size 4x6x6 (GPU 0)]

I can also succeessfully run your code after opening a new console and do not train the network. While in my case, the error occurs during the training, e.g., output = net_G(input), output_indexed = output[[0,0,1,1], [0,0,1,2]], that’s it.