Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: Can't pickle local object 'FewShotDataloader.get_iterator.<locals>.load_function' #3

Open
Jiawen-huang opened this issue Jan 7, 2020 · 2 comments

Comments

@Jiawen-huang
Copy link

0%| | 0/1000 [00:00<?, ?it/s]

----pre-train----
----epoch: 0----


AttributeError Traceback (most recent call last)
in
28 classifier.train()
29
---> 30 for batch in tqdm(dloader_train(ep)):
31 assert(len(batch)==4)
32

F:\Program\Anaconda3\lib\site-packages\tqdm\std.py in iter(self)
1091 fp_write=getattr(self.fp, 'write', sys.stderr.write))
1092
-> 1093 for obj in iterable:
1094 yield obj
1095 # Update and possibly print the progressbar.

F:\Program\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py in iter(self)
276 return _SingleProcessDataLoaderIter(self)
277 else:
--> 278 return _MultiProcessingDataLoaderIter(self)
279
280 @Property

F:\Program\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py in init(self, loader)
680 # before it starts, and del tries to join but will get:
681 # AssertionError: can only join a started process.
--> 682 w.start()
683 self.index_queues.append(index_queue)
684 self.workers.append(w)

F:\Program\Anaconda3\lib\multiprocessing\process.py in start(self)
110 'daemonic processes are not allowed to have children'
111 _cleanup()
--> 112 self._popen = self._Popen(self)
113 self._sentinel = self._popen.sentinel
114 # Avoid a refcycle if the target function holds an indirect

F:\Program\Anaconda3\lib\multiprocessing\context.py in _Popen(process_obj)
221 @staticmethod
222 def _Popen(process_obj):
--> 223 return _default_context.get_context().Process._Popen(process_obj)
224
225 class DefaultContext(BaseContext):

F:\Program\Anaconda3\lib\multiprocessing\context.py in _Popen(process_obj)
320 def _Popen(process_obj):
321 from .popen_spawn_win32 import Popen
--> 322 return Popen(process_obj)
323
324 class SpawnContext(BaseContext):

F:\Program\Anaconda3\lib\multiprocessing\popen_spawn_win32.py in init(self, process_obj)
87 try:
88 reduction.dump(prep_data, to_child)
---> 89 reduction.dump(process_obj, to_child)
90 finally:
91 set_spawning_popen(None)

F:\Program\Anaconda3\lib\multiprocessing\reduction.py 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)
61
62 #

AttributeError: Can't pickle local object 'FewShotDataloader.get_iterator..load_function'

@WithHades
Copy link

hello, i face the same problem. did u solve this problem?

@Johanan528
Copy link

0%| | 0/1000 [00:00<?, ?it/s]

----pre-train----
----epoch: 0----

AttributeError Traceback (most recent call last)
in
28 classifier.train()
29
---> 30 for batch in tqdm(dloader_train(ep)):
31 assert(len(batch)==4)
32

F:\Program\Anaconda3\lib\site-packages\tqdm\std.py in iter(self)
1091 fp_write=getattr(self.fp, 'write', sys.stderr.write))
1092
-> 1093 for obj in iterable:
1094 yield obj
1095 # Update and possibly print the progressbar.

F:\Program\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py in iter(self)
276 return _SingleProcessDataLoaderIter(self)
277 else:
--> 278 return _MultiProcessingDataLoaderIter(self)
279
280 @Property

F:\Program\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py in init(self, loader)
680 # before it starts, and del tries to join but will get:
681 # AssertionError: can only join a started process.
--> 682 w.start()
683 self.index_queues.append(index_queue)
684 self.workers.append(w)

F:\Program\Anaconda3\lib\multiprocessing\process.py in start(self)
110 'daemonic processes are not allowed to have children'
111 _cleanup()
--> 112 self._popen = self._Popen(self)
113 self._sentinel = self._popen.sentinel
114 # Avoid a refcycle if the target function holds an indirect

F:\Program\Anaconda3\lib\multiprocessing\context.py in _Popen(process_obj)
221 @staticmethod
222 def _Popen(process_obj):
--> 223 return _default_context.get_context().Process._Popen(process_obj)
224
225 class DefaultContext(BaseContext):

F:\Program\Anaconda3\lib\multiprocessing\context.py in _Popen(process_obj)
320 def _Popen(process_obj):
321 from .popen_spawn_win32 import Popen
--> 322 return Popen(process_obj)
323
324 class SpawnContext(BaseContext):

F:\Program\Anaconda3\lib\multiprocessing\popen_spawn_win32.py in init(self, process_obj)
87 try:
88 reduction.dump(prep_data, to_child)
---> 89 reduction.dump(process_obj, to_child)
90 finally:
91 set_spawning_popen(None)

F:\Program\Anaconda3\lib\multiprocessing\reduction.py 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)
61
62 #

AttributeError: Can't pickle local object 'FewShotDataloader.get_iterator..load_function'

Maybe you can try to change num_works in 'FewShotDataloader' from 1 to 0
and the problem lies in the difference between ubuntu and windows system

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants