Error while running command train.py

pytorch

(Kamal Deep Garg) #1

Hi
i am using linux version 16 , pytorch version 0.4, and python 3.
Command that i run for training: python3 train.py -data data/data -save_model demo-model

while training model i am getting this error:


Start training…

  • number of epochs: 13, starting from Epoch 1
  • batch size: 64

Loading train dataset from data/data.train.1.pt, number of examples: 20
/home/kamal/Desktop/Linux desktop/OpenNMT-py-master/onmt/modules/GlobalAttention.py:176: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
align_vectors = self.sm(align.view(batch*targetL, sourceL))
/usr/local/lib/python3.5/dist-packages/torch/nn/modules/container.py:91: UserWarning: Implicit dimension choice for log_softmax has been deprecated. Change the call to include dim=X as an argument.
input = module(input)
/home/kamal/Desktop/Linux desktop/OpenNMT-py-master/onmt/Loss.py:144: UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
return onmt.Statistics(loss[0], non_padding.sum(), num_correct)
/home/kamal/Desktop/Linux desktop/OpenNMT-py-master/onmt/Optim.py:125: UserWarning: torch.nn.utils.clip_grad_norm is now deprecated in favor of torch.nn.utils.clip_grad_norm_.
clip_grad_norm(self.params, self.max_grad_norm)
Traceback (most recent call last):
File “train.py”, line 438, in
main()
File “train.py”, line 430, in main
train_model(model, fields, optim, data_type, model_opt)
File “train.py”, line 252, in train_model
train_stats = trainer.train(train_iter, epoch, report_func)
File “/home/kamal/Desktop/Linux desktop/OpenNMT-py-master/onmt/Trainer.py”, line 178, in train
report_stats, normalization)
File “/home/kamal/Desktop/Linux desktop/OpenNMT-py-master/onmt/Trainer.py”, line 321, in gradient_accumulation
dec_state.detach()
File “/home/kamal/Desktop/Linux desktop/OpenNMT-py-master/onmt/Models.py”, line 611, in detach
h.detach
()
RuntimeError: Can’t detach views in-place. Use detach() instead


(Guillaume Klein) #2

OpenNMT-py has not been updated to support PyTorch 0.4 yet. Try PyTorch 0.3.1 instead.


(Kamal Deep Garg) #3

Thank u sir

i have only cpu. which file should i use form this link to install in linux
https://pytorch.org/previous-versions/

and also tell how to remove pytorch 0.4

Thank you.