You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issues raises in pytorch_lightning/utilities/apply_func.py which assumes that the attributes of a Batch from trochtext are Tensors, however if torchtext.data.Field is configured to include a length Tensor (include_lengths=True) the field is a tuple.
A bugfix is prepared and a PR can be submitted soon.
To Reproduce
Steps to reproduce the behavior:
Use Torchtext Field with include_lengths=True on a GPU machine and fit model.
Training works on CPU but fails on GPU with: TypeError: cannot unpack non-iterable NoneType object
Full Error Message
Traceback (most recent call last):
File "debug_torchtext.py", line 105, in <module>
trainer.fit(model)
File "/home1/thschaaf/miniconda3/envs/p37/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1003, in fit
results = self.single_gpu_train(model)
File "/home1/thschaaf/miniconda3/envs/p37/lib/python3.7/site-packages/pytorch_lightning/trainer/distrib_parts.py", line 186, in single_gpu_train
results = self.run_pretrain_routine(model)
File "/home1/thschaaf/miniconda3/envs/p37/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1213, in run_pretrain_routine
self.train()
File "/home1/thschaaf/miniconda3/envs/p37/lib/python3.7/site-packages/pytorch_lightning/trainer/training_loop.py", line 370, in train
self.run_training_epoch()
File "/home1/thschaaf/miniconda3/envs/p37/lib/python3.7/site-packages/pytorch_lightning/trainer/training_loop.py", line 452, in run_training_epoch
batch_output = self.run_training_batch(batch, batch_idx)
File "/home1/thschaaf/miniconda3/envs/p37/lib/python3.7/site-packages/pytorch_lightning/trainer/training_loop.py", line 632, in run_training_batch
self.hiddens
File "/home1/thschaaf/miniconda3/envs/p37/lib/python3.7/site-packages/pytorch_lightning/trainer/training_loop.py", line 776, in optimizer_closure
hiddens)
File "/home1/thschaaf/miniconda3/envs/p37/lib/python3.7/site-packages/pytorch_lightning/trainer/training_loop.py", line 944, in training_forward
batch = self.transfer_batch_to_gpu(batch, gpu_id)
File "/home1/thschaaf/miniconda3/envs/p37/lib/python3.7/site-packages/pytorch_lightning/trainer/distrib_parts.py", line 159, in transfer_batch_to_gpu
return self.__transfer_batch_to_device(batch, device)
File "/home1/thschaaf/miniconda3/envs/p37/lib/python3.7/site-packages/pytorch_lightning/trainer/distrib_parts.py", line 164, in __transfer_batch_to_device
return model.transfer_batch_to_device(batch, device)
File "/home1/thschaaf/miniconda3/envs/p37/lib/python3.7/site-packages/pytorch_lightning/core/hooks.py", line 242, in transfer_batch_to_device
return move_data_to_device(batch, device)
File "/home1/thschaaf/miniconda3/envs/p37/lib/python3.7/site-packages/pytorch_lightning/utilities/apply_func.py", line 128, in move_data_to_device
return apply_to_collection(batch, dtype=(TransferableDataType, Batch), function=batch_to)
File "/home1/thschaaf/miniconda3/envs/p37/lib/python3.7/site-packages/pytorch_lightning/utilities/apply_func.py", line 35, in apply_to_collection
return function(data, *args, **kwargs)
File "/home1/thschaaf/miniconda3/envs/p37/lib/python3.7/site-packages/pytorch_lightning/utilities/apply_func.py", line 103, in batch_to
device_field = getattr(data, field).to(device, non_blocking=True)
AttributeError: 'tuple' object has no attribute 'to'
Exception ignored in: <function tqdm.__del__ at 0x7fcb5e0b2680>
Traceback (most recent call last):
File "/home1/thschaaf/miniconda3/envs/p37/lib/python3.7/site-packages/tqdm/std.py", line 1086, in __del__
File "/home1/thschaaf/miniconda3/envs/p37/lib/python3.7/site-packages/tqdm/std.py", line 1293, in close
File "/home1/thschaaf/miniconda3/envs/p37/lib/python3.7/site-packages/tqdm/std.py", line 1471, in display
File "/home1/thschaaf/miniconda3/envs/p37/lib/python3.7/site-packages/tqdm/std.py", line 1089, in __repr__
File "/home1/thschaaf/miniconda3/envs/p37/lib/python3.7/site-packages/tqdm/std.py", line 1433, in format_dict
TypeError: cannot unpack non-iterable NoneType object
* Test using torchtext.data.Field with include_lengths=True/False
* Fix issue that Tensors in a Batch generated by torchtext with torchtext.data.Field configured as include_lengths=True
* Add description for fix of issue #2688
* changes to accomodate CodeFactor issues
* Another attemt to make last CodeFactor issue pass (it's a false alarm)
* temporarly disable test of test_grad_tracking to check if testing will pass
* reenable test in test_grad_norm
* Update CHANGELOG.md
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
* Renamed get_torchtext_data_iterator to _get_torchtext_data_iterator as suggested by @Borda
* Update pytorch_lightning/utilities/apply_func.py
Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com>
* adding tests more specific to batch_move_data_to_device with tochtext Batch
* added check that Tensors were moved to target device
* removed tests using RNN models to be moved into a separate PR
* fixing FLAKE8 errors that showed up after merge from master branch
modified: tests/base/datamodules.py
modified: tests/callbacks/test_model_checkpoint.py
* parameterized test to reduce code duplication
* Added check only if length tensor exist. Removed left over comments.
* rearranged device parameterization and added pytest.param
* Try to figure out why only one device is tested on Linux machines
* Testing on CPU and GPU devices (GPU test is skip if no cuda device is available.
* added test for TPU device (experimental)
* Adding test parameterization for TPU test (experimental)
* change import statement to limit what is imported for a TPU environment
* made test work with TPU
* Change to trigger CI
* Change to trigger CI
* uncommented TPU test to check CI
* reenabling TPU test
* small change to trigger CI build
* small change to trigger CI build
* small change to trigger CI build
* adding tests/utilities/test_apply_func_torchtext.py to CI TPU test
* try to make test not skipped on CI with TPU
* remove testing on TPU
* undo an accidental change to test_tpu.py (file should not have been touched)
* small change to trigger CI build
* small change to trigger CI build
* Update tests/utilities/test_apply_func_torchtext.py
* Revert to previous version
* Apply suggestions from code review
* Change to trigger CI
Co-authored-by: Thomas Schaaf <tschaaf@mmm.com>
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com>
Co-authored-by: Thomas Schaaf <tschaaf@cs.cmu.edu>
🐛 Bug
The issues raises in pytorch_lightning/utilities/apply_func.py which assumes that the attributes of a Batch from trochtext are Tensors, however if torchtext.data.Field is configured to include a length Tensor (include_lengths=True) the field is a tuple.
A bugfix is prepared and a PR can be submitted soon.
To Reproduce
Steps to reproduce the behavior:
TypeError: cannot unpack non-iterable NoneType object
Full Error Message
Code sample
Expected behavior
Should not raise an error :-)
Environment
Additional context
The text was updated successfully, but these errors were encountered: