OpenNMT Forum

Problem with

Hi, I am training an Arabic-English model. I am using Colab. Everything used to go smoothly with all my experiments but now I get this error at after the command:

RuntimeError: Integer division of tensors using div or / is no longer supported, and in a future release div will perform true division as in Python 3. Use true_divide or floor_divide (// in Python) instead

This is my translate code:

!python /content/ar_OpenNMT-py/
-model /content/model/
-src /content/data/test.txt
-output /content/data/predict.txt
-replace_unk -verbose

I am also getting the same error with the alternative command:

!onmt_translate -model /content/model/ -src /content/ar_OpenNMT-py/data/src-test.txt -output pred.txt -replace_unk -verbose

Can someone help pls.

Thank you

Try installing a previous version of pytorch rather than the latest. For instance try 1.3 which should still work.

Thank you. pytorch 1.3 didn’t work, not compatible with OpenNMT. This worked:

!pip install torch==1.4.0 torchvision==0.5.0

and I also had to change the torchtext version:
!pip install torchtext==0.4.0

Thank you for the help, hope OpenNMT team could fix this problem as even their demo data won’t work unless the pytorch is downgraded

Yeah, wasn’t sure about the version numbers. The error you gave has been a depreciation warning for a while. Seems like it now has become a full-on error. @guillaumeklnThis should probably get fixed across the board.

cc @francoishernandez @Zenglinxiao

Hello @sadanyh ,
This error is due to the latest release of PyTorch 1.6. I’ve opened a PR for fixing this issue. You can then use the latest PyTorch when it’s merged.

Thanks a lot for your prompt response.

For reference, this is fixed in OpenNMT-py 1.2.