How to resolve _pickle.UnpicklingError

265 views Asked by At

I was trying to download and run the 2s-AGCN code from this GitHub link: I have generated data successfully But when trying to train the model by running main.py, I am facing this error:


[ Mon Feb 20 21:32:20 2023 ] Training epoch: 1
  0%|          | 0/588 [00:22<?, ?it/s]
Traceback (most recent call last):

  File "C:\Users\PC\anaconda3\envs\gcn\lib\site-packages\spyder_kernels\py3compat.py", line 356, in compat_exec
    exec(code, globals, locals)

  File "c:\users\pc\projects\2s-agcn\main.py", line 579, in <module>
    processor.start()

  File "c:\users\pc\projects\2s-agcn\main.py", line 520, in start
    self.train(epoch, save_model=save_model)

  File "c:\users\pc\projects\2s-agcn\main.py", line 380, in train
    for batch_idx, (data, label, index) in enumerate(process):

  File "C:\Users\PC\anaconda3\envs\gcn\lib\site-packages\tqdm\std.py", line 1195, in __iter__
    for obj in iterable:

  File "C:\Users\PC\anaconda3\envs\gcn\lib\site-packages\torch\utils\data\dataloader.py", line 435, in __iter__
    return self._get_iterator()

  File "C:\Users\PC\anaconda3\envs\gcn\lib\site-packages\torch\utils\data\dataloader.py", line 381, in _get_iterator
    return _MultiProcessingDataLoaderIter(self)

  File "C:\Users\PC\anaconda3\envs\gcn\lib\site-packages\torch\utils\data\dataloader.py", line 1034, in __init__
    w.start()

  File "C:\Users\PC\anaconda3\envs\gcn\lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)

  File "C:\Users\PC\anaconda3\envs\gcn\lib\multiprocessing\context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)

  File "C:\Users\PC\anaconda3\envs\gcn\lib\multiprocessing\context.py", line 327, in _Popen
    return Popen(process_obj)

  File "C:\Users\PC\anaconda3\envs\gcn\lib\multiprocessing\popen_spawn_win32.py", line 93, in __init__
    reduction.dump(process_obj, to_child)

  File "C:\Users\PC\anaconda3\envs\gcn\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)

OSError: [Errno 22] Invalid argument


Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\PC\anaconda3\envs\gcn\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "C:\Users\PC\anaconda3\envs\gcn\lib\multiprocessing\spawn.py", line 126, in _main
    self = reduction.pickle.load(from_parent)
_pickle.UnpicklingError: pickle data was truncated

I have tried to change the line in reduction.py file

ForkingPickler(file, protocol).dump(obj) 

to this line:

ForkingPickler(file, protocol).dumps(obj)

But it is showing EOF runtime error.

ALso, attempted to remove

pin_memory = True num_workers = 4

according to text. But I could not find it in dataloader.py file.

1

There are 1 answers

2
Fareed Khan On

Even though you have generated the data successfully, double-check whether is it the same as the actual size.


Moreover, in main.py, you can find the num_workers parameter on line 227 (for the train) and line 234 (for the test).

Since you are having a problem with training purposes you can change it from

num_workers=self.arg.num_worker to num_workers=0

It may worked for you or play around with this parameter in case the 0 value does not work.