Invalid argument runtime error

Hello everybody,

I’m using python 3.6 (64 bit) with pytorch (0.3.1 post 2) on Windows 10.

I received the following run time error;

“RuntimeError: invalid argument 2: out of range at c:\anaconda2\conda-bld\pytorch_1519496000060\work\torch\lib\thc\generic/THCTensor.c:23”

if type(data[0][0])==int: <<===== This line causes the problem
return []

If anyone could propose any solution that would be fantastic.
Thanks beforehand…

Could you print the shape of data before the comparison?

This is a list object with no dimension…

So it’s something like this?

data = [[0, 1], [2, 3]]
if type(data[0][1]) == int:

In fact I’m reusing an already written code of a friend of mine and most important I’m new to this environment.

This code was written in Python 2 with Pytorch 0.2.0 _3 on Linux. I’m ported the code to my environment. It used to work with no problem in its previous environment.

I’m afraid of being confronted with a Pytorch problem…

This part of the code is preparing batches to LSTM for SRL…

It seems the error is throws from a tensor, so probably there are tensors stored in the list.
Could you print data[0][0]?

no throws the same run time error…

Ok. Could you then print data[0]?

yes no error and it sais: ""data = [torch.cuda.LongTensor with no dimension]

I saw some Pytorch problems reported for sparse matrixes which are said to be fixed in 0.4.0 version but it requires migration that I would definitely prefer to stay away. As this is not my code I would be confronted with a lot of new problems during this process.

It seems the tensor is empty.
In 0.3 you can recreate the error with:

a = torch.cuda.LongTensor()

I think you have to check, why the data is empty. Since the code was written by someone else, could you check, that all paths, directories are set to a valid location?
Maybe the data loading fails without a warning, resulting in empty tensors.

OK I will check all those thanks a lot…

Indeed, the list was not filled up because of a map function which had to be casted to list. It works now.

The reason for that is the Python 2 -> 3 migration that I’m trying to accomplish.

Thanks a lot for your guidance…