【问题标题】:Google colab unable to work with hdf5 filesGoogle colab 无法处理 hdf5 文件
【发布时间】:2020-09-05 13:23:41
【问题描述】:

我的驱动器中有 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-colaboratory hdf5


    【解决方案1】:

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

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

    【讨论】:

    • 我无法复制,文件分别为 32gb 和 4gb。正在取消错误操作
    • 我也有同样的问题。路径是“/content/drive/My Drive/Brain-Tumor-Segmentation-Project/brainTumorData/1457.mat”。我收到此错误:“OSError:无法打开文件(文件读取失败:”