question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: can't pickle _thread._local objects

See original GitHub issue

Thank you for your code.When I run train.py,I met a problem as following:

C:\Users\Administrator\Anaconda3\lib\site-packages\h5py_init_.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters Traceback (most recent call last): File “C:/image_captioning/code/a-PyTorch-Tutorial-to-Image-Captioning-master/train.py”, line 328, in <module> main() File “C:/image_captioning/code/a-PyTorch-Tutorial-to-Image-Captioning-master/train.py”, line 116, in main epoch=epoch) File “C:/image_captioning/code/a-PyTorch-Tutorial-to-Image-Captioning-master/train.py”, line 162, in train for i, imgs, caps, caplens in enumerate(train_loader): File “C:\Users\Administrator\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py”, line 501, in iter return _DataLoaderIter(self) File “C:\Users\Administrator\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py”, line 289, in init w.start() File “C:\Users\Administrator\Anaconda3\lib\multiprocessing\process.py”, line 105, in start self._popen = self._Popen(self) File “C:\Users\Administrator\Anaconda3\lib\multiprocessing\context.py”, line 223, in _Popen return _default_context.get_context().Process._Popen(process_obj) File “C:\Users\Administrator\Anaconda3\lib\multiprocessing\context.py”, line 322, in _Popen return Popen(process_obj) File “C:\Users\Administrator\Anaconda3\lib\multiprocessing\popen_spawn_win32.py”, line 65, in init reduction.dump(process_obj, to_child) File “C:\Users\Administrator\Anaconda3\lib\multiprocessing\reduction.py”, line 60, in dump ForkingPickler(file, protocol).dump(obj) TypeError: can’t pickle _thread._local objects

Could you give me some advice?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
sgrvinodcommented, Nov 22, 2018

Yes, it happens because h5py won’t read from multiple processes. By omitting num_workers, you’re setting it to the default of 0, which uses only the main process. You could also set it to 1 (on Linux, at least).

0reactions
JindongGucommented, Jan 17, 2021

I have run into a similar issue. However, I have to use more than one worker to load my dataset (One process is too slow in my case). Any suggestion? Thanks in Advance.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: can't pickle _thread._local objects when using dask ...
The problem is that I get stuck in this TypeError: can't pickle _thread._local objects error as soon as it starts running.
Read more >
can't pickle _thread._local objects>> working with tensorflow2 ...
It creates an attribute which is a local threading wrapper that cannot be serialized by pickle. Unfortunately that line is there for a...
Read more >
Pandas : TypeError: can't pickle _thread._local objects when ...
Pandas : TypeError : can't pickle _thread._local objects when using dask on pandas DataFrame [ Beautify Your Computer ...
Read more >
cannot pickle '_thread.lock' object when trying to start process ...
The problem here is that self in function run_parallel() can't be pickled as it is a class instance. Moving this parallelized function run_parallel()...
Read more >
How to Check Which Object Cause TypeError: cannot pickle ...
Also, just note that the error indicates you have a lock object in your remote method that's serialized. Lock objects are famous by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found