Error while using DataParallel in LSTM units

Ameen_Ali: <p>Hello All,<br>
I’m trying to use  DataParallel as in the following picture<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/1/1796fa5f75b92845d8c88ad85bd239c968d00e0f.png" data-download-href="https://discuss.pytorch.org/uploads/default/1796fa5f75b92845d8c88ad85bd239c968d00e0f" title="Screenshot%20from%202019-08-30%2019-53-35"><img src="https://discuss.pytorch.org/uploads/default/optimized/2X/1/1796fa5f75b92845d8c88ad85bd239c968d00e0f_2_690x239.png" alt="Screenshot%20from%202019-08-30%2019-53-35" data-base62-sha1="3mGrWCDoXMGXMQg2KYxtu2ump79" width="690" height="239" srcset="https://discuss.pytorch.org/uploads/default/optimized/2X/1/1796fa5f75b92845d8c88ad85bd239c968d00e0f_2_690x239.png, https://discuss.pytorch.org/uploads/default/optimized/2X/1/1796fa5f75b92845d8c88ad85bd239c968d00e0f_2_1035x358.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/2X/1/1796fa5f75b92845d8c88ad85bd239c968d00e0f_2_1380x478.png 2x" data-dominant-color="2C2D27"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screenshot%20from%202019-08-30%2019-53-35</span><span class="informations">2938×1020 225 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>but when training i get the following error (which clearly happens at line 28 in the previous picture)</p>
<pre><code class="lang-auto">    s, _ = self.lstm(s)
  File "/home/pavelameen/miniconda3/envs/TD2/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/pavelameen/miniconda3/envs/TD2/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 152, in forward
    outputs = self.parallel_apply(replicas, inputs, kwargs)
  File "/home/pavelameen/miniconda3/envs/TD2/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 162, in parallel_apply
    return parallel_apply(replicas, inputs, kwargs, self.device_ids[:len(replicas)])
  File "/home/pavelameen/miniconda3/envs/TD2/lib/python3.6/site-packages/torch/nn/parallel/parallel_apply.py", line 83, in parallel_apply
    raise output
  File "/home/pavelameen/miniconda3/envs/TD2/lib/python3.6/site-packages/torch/nn/parallel/parallel_apply.py", line 59, in _worker
    output = module(*input, **kwargs)
  File "/home/pavelameen/miniconda3/envs/TD2/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/pavelameen/miniconda3/envs/TD2/lib/python3.6/site-packages/torch/nn/modules/rnn.py", line 193, in forward
    max_batch_size = input.size(0) if self.batch_first else input.size(1)
AttributeError: 'tuple' object has no attribute 'size'
</code></pre>
<p>The type of s (which is input in the error message ) is : &lt;class ‘torch.nn.utils.rnn.PackedSequence’&gt;                                                                                                                                                    Any idea why this happens?</p>