Pytorch and titan v

I am installing ‘pytorch’ on the computer where ‘titan v’ is installed.

This is what i used.

Linux ubuntu 18.04
pytorch 0.4.1
cuda 9.2

And I confirmed that the basic example code (gpu version) provided by ‘pytorch’ works well.
But when i run my code, the following error has occurred.

# RuntimeError "sizes must be non-negative"

My code works fine in “cuda 8.0, torch 0.4.0”.
What should I do?
Should i need to change version for pytorch or cuda?
Or win10 is better to use titanv then linux…? (I’m comfortable with ‘win10’)


This looks like an unrelated error. Are you sure you did not changed anything in your code/input?
Could you give some context on where the error is raised?

Thank you. I need check my code again.

But, I have repeated the process of deleting and installing various versions. As a result, there seems to be a problem of conflicting versions.

If you do not mind, I would be grateful if you could recommend a blog that is well documented for installing the “graphics driver” and “Kuda” on Linux for titna v. I am not familiar with Linux, so I suspect that I installed it properly … Thank you.

The address below is for my reference.

The instructions to install Cuda look right.
Make sure to pip uninstall torch before reinstalling it.
But here again, there is 99% chance that this is a bug in your code (or the inputs/dataset) and not an installation problem.

I really appreciate you very, very much. Thank you!

Traceback (most recent call last):
File “”, line 322, in
File “”, line 314, in main
train_model(model, data, optim, i, params)
File “”, line 119, in train_model
for src, tgt, src_len, tgt_len, original_src, original_tgt in trainloader:
File “/home/mu/.conda/envs/dym/lib/python3.5/site-packages/torch/utils/data/”, line 314, in next
batch = self.collate_fn([self.dataset[i] for i in indices])
File “/home/mu/global-encoding/utils/”, line 84, in padding
src_pad = torch.zeros(len(src), max(src_len)).long()
RuntimeError: sizes must be non-negative
it’s my error ,I don’t know how to solve it

I guess max(src_len) is negative and a tensor with a negative size does not make sense,.