OpenNMT Forum

Run time problem running with PyTorch 1.3 under Windows 10

I think the patch is indicated by in the error message and I am currently testing it.
Here is the screen dump:

(ling) D:\AnacondaWork\OpenNMT-py>python -data data/demo -save_model demo-model -world_size 1 -gpu_ranks 0
[2020-01-02 12:15:28,648 INFO] * src vocab size = 24997
[2020-01-02 12:15:28,663 INFO] * tgt vocab size = 35820
[2020-01-02 12:15:28,663 INFO] Building model…
[2020-01-02 12:15:33,147 INFO] NMTModel(
(encoder): RNNEncoder(
(embeddings): Embeddings(
(make_embedding): Sequential(
(emb_luts): Elementwise(
(0): Embedding(24997, 500, padding_idx=1)
(rnn): LSTM(500, 500, num_layers=2, dropout=0.3)
(decoder): InputFeedRNNDecoder(
(embeddings): Embeddings(
(make_embedding): Sequential(
(emb_luts): Elementwise(
(0): Embedding(35820, 500, padding_idx=1)
(dropout): Dropout(p=0.3, inplace=False)
(rnn): StackedLSTM(
(dropout): Dropout(p=0.3, inplace=False)
(layers): ModuleList(
(0): LSTMCell(1000, 500)
(1): LSTMCell(500, 500)
(attn): GlobalAttention(
(linear_in): Linear(in_features=500, out_features=500, bias=False)
(linear_out): Linear(in_features=1000, out_features=500, bias=False)
(generator): Sequential(
(0): Linear(in_features=500, out_features=35820, bias=True)
(1): Cast()
(2): LogSoftmax()
[2020-01-02 12:15:33,147 INFO] encoder: 16506500
[2020-01-02 12:15:33,147 INFO] decoder: 41613820
[2020-01-02 12:15:33,147 INFO] * number of parameters: 58120320
[2020-01-02 12:15:33,147 INFO] Starting training on GPU: [0]
[2020-01-02 12:15:33,147 INFO] Start training loop and validate every 10000 steps…
[2020-01-02 12:15:33,147 INFO] Loading dataset from data\
[2020-01-02 12:15:33,288 INFO] number of examples: 10000
Traceback (most recent call last):
File “”, line 200, in
File “”, line 86, in main
single_main(opt, 0)
File “D:\AnacondaWork\OpenNMT-py\onmt\”, line 139, in main
File “D:\AnacondaWork\OpenNMT-py\onmt\”, line 243, in train
File “D:\AnacondaWork\OpenNMT-py\onmt\”, line 357, in _gradient_accumulation
outputs, attns = self.model(src, tgt, src_lengths, bptt=bptt)
File “D:\Anaconda3\envs\ling\lib\site-packages\torch\nn\modules\”, line 541, in call
result = self.forward(*input, **kwargs)
File “D:\AnacondaWork\OpenNMT-py\onmt\models\”, line 46, in forward
File “D:\Anaconda3\envs\ling\lib\site-packages\torch\nn\modules\”, line 541, in call
result = self.forward(*input, **kwargs)
File “D:\AnacondaWork\OpenNMT-py\onmt\decoders\”, line 213, in forward
tgt, memory_bank, memory_lengths=memory_lengths)
File “D:\AnacondaWork\OpenNMT-py\onmt\decoders\”, line 395, in run_forward_pass
File “D:\Anaconda3\envs\ling\lib\site-packages\torch\nn\modules\”, line 541, in call
result = self.forward(*input, **kwargs)
File “D:\AnacondaWork\OpenNMT-py\onmt\modules\”, line 183, in forward
(1 - mask, -float(‘inf’))
File “D:\Anaconda3\envs\ling\lib\site-packages\torch\”, line 362, in rsub
return _C._VariableFunctions.rsub(self, other)
RuntimeError: Subtraction, the - operator, with a bool tensor is not supported. If you are trying to invert a mask, use the ~ or logical_not() operator instead.

(ling) D:\AnacondaWork\OpenNMT-py>

Will the development team apply it or should I submit it?

Your version is probably not up to date.
This change has already been made a while back for pytorch 1.2 compatibility. (PR #1527)

I downloaded the latest version and the bug was corrected.
I noticed that you changed the “façade” programs to simply a call to the main in the “onmt” code with the same name. Will the structure of the py package change in the future or is it quite stable?

The main scripts indeed were moved to allow that (see, but some dummy scripts were kept at the root of the repo to prevent existing scripts that may call them from breaking.

Apart from this change which was made to allow proper publishing on pip, the structure should remain quite stable for now.