Could you print the idx inside __getitem__, use num_workers=0 and retry the code?
Based on the error message it seems some indices yield invalid data using your hdf5 file.
The last printed index should point to the failing operation.