Python ERROR h5py objects cannot be pickled

adeljalal: <p>Can any one help me</p>
<h2>
<a name="i-am-facing-this-error-h5py-objects-cannot-be-pickled-while-running-trainpy-on-httpsgithubcomroyalskyeimage-caption-1" class="anchor" href="#i-am-facing-this-error-h5py-objects-cannot-be-pickled-while-running-trainpy-on-httpsgithubcomroyalskyeimage-caption-1"></a>I am facing this error “h5py objects cannot be pickled” while running (train.py) on <a href="https://github.com/RoyalSkye/Image-Caption" class="inline-onebox" rel="noopener nofollow ugc">GitHub - RoyalSkye/Image-Caption: Using LSTM or Transformer to solve Image Captioning in Pytorch</a>
</h2>
<p>Traceback (most recent call last):</p>
<p>File D:\COCO\imge_captioning_transform_github\3\Image-Caption-master\train.py:394 in <br>
train(args, train_loader=train_loader, encoder=encoder, decoder=decoder, criterion=criterion,</p>
<p>File D:\COCO\imge_captioning_transform_github\3\Image-Caption-master\train.py:44 in train<br>
for i, (imgs, caps, caplens) in enumerate(train_loader):</p>
<p>File ~\anaconda3\envs\my_envir_gpu\lib\site-packages\torch\utils\data\dataloader.py:368 in <strong>iter</strong><br>
return self._get_iterator()</p>
<p>File ~\anaconda3\envs\my_envir_gpu\lib\site-packages\torch\utils\data\dataloader.py:314 in _get_iterator<br>
return _MultiProcessingDataLoaderIter(self)</p>
<p>File ~\anaconda3\envs\my_envir_gpu\lib\site-packages\torch\utils\data\dataloader.py:927 in <strong>init</strong><br>
w.start()</p>
<p>File ~\anaconda3\envs\my_envir_gpu\lib\multiprocessing\process.py:121 in start<br>
self._popen = self._Popen(self)</p>
<p>File ~\anaconda3\envs\my_envir_gpu\lib\multiprocessing\context.py:224 in _Popen<br>
return _default_context.get_context().Process._Popen(process_obj)</p>
<p>File ~\anaconda3\envs\my_envir_gpu\lib\multiprocessing\context.py:327 in _Popen<br>
return Popen(process_obj)</p>
<p>File ~\anaconda3\envs\my_envir_gpu\lib\multiprocessing\popen_spawn_win32.py:93 in <strong>init</strong><br>
reduction.dump(process_obj, to_child)</p>
<p>File ~\anaconda3\envs\my_envir_gpu\lib\multiprocessing\reduction.py:60 in dump<br>
ForkingPickler(file, protocol).dump(obj)</p>
<p>File ~\anaconda3\envs\my_envir_gpu\lib\site-packages\h5py_hl\base.py:368 in <strong>getnewargs</strong><br>
raise TypeError(“h5py objects cannot be pickled”)</p>
<p>TypeError: h5py objects cannot be pickled</p>
<p>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<br>
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.<br>
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<br>
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:<br>
type_id: TFT_OPTIONAL<br>
args {<br>
type_id: TFT_PRODUCT<br>
args {<br>
type_id: TFT_TENSOR<br>
args {<br>
type_id: TFT_LEGACY_VARIANT<br>
}<br>
}<br>
}<br>
is neither a subtype nor a supertype of the combined inputs preceding it:<br>
type_id: TFT_OPTIONAL<br>
args {<br>
type_id: TFT_PRODUCT<br>
args {<br>
type_id: TFT_TENSOR<br>
args {<br>
type_id: TFT_INT32<br>
}<br>
}<br>
}</p>
<pre><code>while inferring type of node 'cond_40/output/_25'
</code></pre>
<p>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.<br>
Traceback (most recent call last):<br>
File “”, line 1, in <br>
File “C:\Users\MSI\anaconda3\envs\my_envir_gpu\lib\multiprocessing\spawn.py”, line 116, in spawn_main<br>
exitcode = _main(fd, parent_sentinel)<br>
File “C:\Users\MSI\anaconda3\envs\my_envir_gpu\lib\multiprocessing\spawn.py”, line 126, in _main<br>
self = reduction.pickle.load(from_parent)<br>
EOFError: Ran out of input</p>
<p>I am using Python 3.9, PyTorch 1.10 with Cuda 11.3 (WINDOWS 10)</p>
<p>Thanks,</p>
<p>I am trying ( num_workers=0 ) , but still same error</p>

yanjun_guo: <p>Hi, have you found a solution to this problem?</p>