# Python ERROR h5py objects cannot be pickled

**URL:** <https://discuss.pytorch.org/t/python-error-h5py-objects-cannot-be-pickled/155462>\
**Category:** Uncategorized\
**Created:** [June 30, 2022, 4:43pm UTC](https://discuss.pytorch.org/t/python-error-h5py-objects-cannot-be-pickled/155462 "2022-06-30T16:43:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adeljalal](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/a/58956e/32.png) [@adeljalal](https://discuss.pytorch.org/u/adeljalal)\
**Post date:** [June 30, 2022, 4:43pm UTC](https://discuss.pytorch.org/t/python-error-h5py-objects-cannot-be-pickled/155462/1 "2022-06-30T16:43:29Z")

</div>

Can any one help me

## I am facing this error “h5py objects cannot be pickled” while running (train.py) on [GitHub - RoyalSkye/Image-Caption: Using LSTM or Transformer to solve Image Captioning in Pytorch](https://github.com/RoyalSkye/Image-Caption)

Traceback (most recent call last):

File D:\COCO\imge\_captioning\_transform\_github\3\Image-Caption-master\train.py:394 in   
train(args, train\_loader=train\_loader, encoder=encoder, decoder=decoder, criterion=criterion,

File D:\COCO\imge\_captioning\_transform\_github\3\Image-Caption-master\train.py:44 in train  
for i, (imgs, caps, caplens) in enumerate(train\_loader):

File ~\anaconda3\envs\my\_envir\_gpu\lib\site-packages\torch\utils\data\dataloader.py:368 in **iter**  
return self.\_get\_iterator()

File ~\anaconda3\envs\my\_envir\_gpu\lib\site-packages\torch\utils\data\dataloader.py:314 in \_get\_iterator  
return \_MultiProcessingDataLoaderIter(self)

File ~\anaconda3\envs\my\_envir\_gpu\lib\site-packages\torch\utils\data\dataloader.py:927 in **init**  
w.start()

File ~\anaconda3\envs\my\_envir\_gpu\lib\multiprocessing\process.py:121 in start  
self.\_popen = self.\_Popen(self)

File ~\anaconda3\envs\my\_envir\_gpu\lib\multiprocessing\context.py:224 in \_Popen  
return \_default\_context.get\_context().Process.\_Popen(process\_obj)

File ~\anaconda3\envs\my\_envir\_gpu\lib\multiprocessing\context.py:327 in \_Popen  
return Popen(process\_obj)

File ~\anaconda3\envs\my\_envir\_gpu\lib\multiprocessing\popen\_spawn\_win32.py:93 in **init**  
reduction.dump(process\_obj, to\_child)

File ~\anaconda3\envs\my\_envir\_gpu\lib\multiprocessing\reduction.py:60 in dump  
ForkingPickler(file, protocol).dump(obj)

File ~\anaconda3\envs\my\_envir\_gpu\lib\site-packages\h5py\_hl\base.py:368 in **getnewargs**  
raise TypeError(“h5py objects cannot be pickled”)

TypeError: h5py objects cannot be pickled

2022-06-30 17:24:41.206091: I tensorflow/core/platform/cpu\_feature\_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2  
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.  
2022-06-30 17:24:41.525476: I tensorflow/core/common\_runtime/gpu/gpu\_device.cc:1532] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 3497 MB memory: → device: 0, name: NVIDIA GeForce RTX 3060 Laptop GPU, pci bus id: 0000:01:00.0, compute capability: 8.6  
2022-06-30 17:24:44.486920: W tensorflow/core/common\_runtime/forward\_type\_inference.cc:231] Type inference failed. This indicates an invalid graph that escaped type checking. Error message: INVALID\_ARGUMENT: expected compatible input types, but input 1:  
type\_id: TFT\_OPTIONAL  
args {  
type\_id: TFT\_PRODUCT  
args {  
type\_id: TFT\_TENSOR  
args {  
type\_id: TFT\_LEGACY\_VARIANT  
}  
}  
}  
is neither a subtype nor a supertype of the combined inputs preceding it:  
type\_id: TFT\_OPTIONAL  
args {  
type\_id: TFT\_PRODUCT  
args {  
type\_id: TFT\_TENSOR  
args {  
type\_id: TFT\_INT32  
}  
}  
}

```
while inferring type of node 'cond_40/output/_25'

```

2022-06-30 17:24:45.077383: I tensorflow/stream\_executor/cuda/cuda\_blas.cc:1786] TensorFloat-32 will be used for the matrix multiplication. This will only be logged once.  
Traceback (most recent call last):  
File “”, line 1, in   
File “C:\Users\MSI\anaconda3\envs\my\_envir\_gpu\lib\multiprocessing\spawn.py”, line 116, in spawn\_main  
exitcode = \_main(fd, parent\_sentinel)  
File “C:\Users\MSI\anaconda3\envs\my\_envir\_gpu\lib\multiprocessing\spawn.py”, line 126, in \_main  
self = reduction.pickle.load(from\_parent)  
EOFError: Ran out of input

I am using Python 3.9, PyTorch 1.10 with Cuda 11.3 (WINDOWS 10)

Thanks,

I am trying ( num\_workers=0 ) , but still same error

---

<div class="post-metadata">

**Author:** ![yanjun\_guo](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/yanjun_guo/32/55428_2.png) [@yanjun\_guo](https://discuss.pytorch.org/u/yanjun_guo)\
**Post date:** [December 5, 2022, 7:48pm UTC](https://discuss.pytorch.org/t/python-error-h5py-objects-cannot-be-pickled/155462/2 "2022-12-05T19:48:35Z")

</div>

Hi, have you found a solution to this problem?
