首页 > 解决方案 > Google colab 无法处理 hdf5 文件

问题描述

我的驱动器中有 4 个 hdf5 文件。在使用 colab 时,db=h5py.File(path_to_file, "r")有时会工作,但不会在其余时间工作。在编写 hdf5 文件时,我确保在写入后将其关闭。假设 File1 适用于 notebook_#1,当我尝试在 notebook_#2 上使用它时,它有时会起作用,而其他时候则不起作用。当我在 notebook_#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-colaboratoryhdf5

解决方案


直接从 Google Drive 读取可能会导致问题。

尝试将其复制到本地目录,例如/content/首先。


推荐阅读