我的硬盘里有4个hdf5文件。当使用colab。db=h5py.File(path_to_file, "r")
有时工作,其余时间不工作。在写hdf5文件的时候,我已经确保写完后关闭它。比如说File1在笔记本_#1上能用,当我尝试在笔记本_#2上使用它时,它有时能用,有时不能用,当我在笔记本_#1上再次运行它时,它可能能用,也可能不能用。当我再次在笔记本_#1上运行它时,它可能工作,也可能不工作。
可能大小不是问题,因为我的4个文件是32GB的,其他的是4GB的,大部分的问题是4GB的文件。
hdf5文件是用colab自己生成的。我得到的错误是
OSError: Unable to open file (file read failed: time = Tue May 19 12:58:36 2020
, filename = '/content/drive/My Drive/Hrushi/dl4cv/hdf5_files/train.hdf5', file descriptor = 61, errno = 5, error message = 'Input/output error', buf = 0x7ffc437c4c20, total read size = 8, bytes this sub-read = 8, bytes actually read = 18446744073709551615, offset = 0
或者...
/usr/local/lib/python3.6/dist-packages/h5py/_hl/files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)
171 if swmr and swmr_support:
172 flags |= h5f.ACC_SWMR_READ
--> 173 fid = h5f.open(name, flags, fapl=fapl)
174 elif mode == 'r+':
175 fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)
h5py/_objects.pyx in h5py._objects.with_phil.wrapper()
h5py/_objects.pyx in h5py._objects.with_phil.wrapper()
h5py/h5f.pyx in h5py.h5f.open()
OSError: Unable to open file (bad object header version number)
将感激任何帮助,提前感谢。
直接从Google Drive读取可能会导致问题。
尝试将其复制到本地目录,例如 /content/
首先。