AttributeError: Can't pickle local object 'Settings._validator_factory.<locals>.helper'

18 views Asked by At

I am new to conda and I usually use colab, I using the Non-parametric transformer repository on my defect dataset on jupyter notebook. I am running the code trainer.train_and_eval() and I get the atribute error: Can't pickle local object 'Settings._validator_factory..helper'. I am using python version 3.8 on Windows 10.

Full error message:

Cell In[29], line 1
----> 1 trainer.train_and_eval()

File ~\miniconda3\envs\npt\non-parametric-transformers\npt\train.py:217, in Trainer.train_and_eval(self)
    215 else:
    216     for epoch in range(1, self.max_epochs + 1):
--> 217         if self.per_epoch_train_eval(epoch=epoch):
    218             break

File ~\miniconda3\envs\npt\non-parametric-transformers\npt\train.py:172, in Trainer.per_epoch_train_eval(self, epoch)
    167     train_loss = None
    168 else:
    169     # The returned train loss is used for logging at eval time
    170     # It is None if minibatch_sgd is enabled, in which case we
    171     # perform an additional forward pass over all train entries
--> 172     train_loss = self.run_epoch(dataset_mode='train', epoch=epoch,
    173                                 eval_model=False)
    175 if eval_model:
    176     early_stop = self.eval_model(
    177         train_loss, epoch, end_experiment)

File ~\miniconda3\envs\npt\non-parametric-transformers\npt\train.py:352, in Trainer.run_epoch(self, dataset_mode, epoch, eval_model)
    349     if self.c.debug_eval_row_interactions_timer is not None:
    350         self.set_row_corruption_timer()
--> 352 for batch_index, batch_dict_ in enumerate(batch_iter):
    353     if self.c.debug_row_interactions:
    354         batch_dict_ = debug.modify_data(
    355             self.c, batch_dict_, dataset_mode,
    356             self.scheduler.num_steps)

File ~\miniconda3\envs\npt\lib\site-packages\tqdm\std.py:1181, in tqdm.__iter__(self)
   1178 time = self._time
   1180 try:
-> 1181     for obj in iterable:
   1182         yield obj
   1183         # Update and possibly print the progressbar.
   1184         # Note: does not call self.update(1) for speed optimisation.

File ~\miniconda3\envs\npt\lib\site-packages\torch\utils\data\dataloader.py:439, in DataLoader.__iter__(self)
    437     return self._iterator
    438 else:
--> 439     return self._get_iterator()

File ~\miniconda3\envs\npt\lib\site-packages\torch\utils\data\dataloader.py:387, in DataLoader._get_iterator(self)
    385 else:
    386     self.check_worker_number_rationality()
--> 387     return _MultiProcessingDataLoaderIter(self)

File ~\miniconda3\envs\npt\lib\site-packages\torch\utils\data\dataloader.py:1040, in _MultiProcessingDataLoaderIter.__init__(self, loader)
   1033 w.daemon = True
   1034 # NB: Process.start() actually take some time as it needs to
   1035 #     start a process and pass the arguments over via a pipe.
   1036 #     Therefore, we only add a worker to self._workers list after
   1037 #     it started, so that we do not call .join() if program dies
   1038 #     before it starts, and __del__ tries to join but will get:
   1039 #     AssertionError: can only join a started process.
-> 1040 w.start()
   1041 self._index_queues.append(index_queue)
   1042 self._workers.append(w)

File ~\miniconda3\envs\npt\lib\multiprocessing\process.py:121, in BaseProcess.start(self)
    118 assert not _current_process._config.get('daemon'), \
    119        'daemonic processes are not allowed to have children'
    120 _cleanup()
--> 121 self._popen = self._Popen(self)
    122 self._sentinel = self._popen.sentinel
    123 # Avoid a refcycle if the target function holds an indirect
    124 # reference to the process object (see bpo-30775)

File ~\miniconda3\envs\npt\lib\multiprocessing\context.py:224, in Process._Popen(process_obj)
    222 @staticmethod
    223 def _Popen(process_obj):
--> 224     return _default_context.get_context().Process._Popen(process_obj)

File ~\miniconda3\envs\npt\lib\multiprocessing\context.py:327, in SpawnProcess._Popen(process_obj)
    324 @staticmethod
    325 def _Popen(process_obj):
    326     from .popen_spawn_win32 import Popen
--> 327     return Popen(process_obj)

File ~\miniconda3\envs\npt\lib\multiprocessing\popen_spawn_win32.py:93, in Popen.__init__(self, process_obj)
     91 try:
     92     reduction.dump(prep_data, to_child)
---> 93     reduction.dump(process_obj, to_child)
     94 finally:
     95     set_spawning_popen(None)

File ~\miniconda3\envs\npt\lib\multiprocessing\reduction.py:60, in dump(obj, file, protocol)
     58 def dump(obj, file, protocol=None):
     59     '''Replacement for pickle.dump() using ForkingPickler.'''
---> 60     ForkingPickler(file, protocol).dump(obj)

AttributeError: Can't pickle local object 'Settings._validator_factory.<locals>.helper'
`
0

There are 0 answers