mac上的设备上没有剩余空间

时间:2017-09-07 02:12:18

标签: python macos file

我想用h5py来存储我的数据,所以我写了那段代码

import h5py
import pandas as pd
import os
import cv2

h5_path = 'deep_tesla1.hdf5'
if os.path.exists(h5_path):
    os.remove(h5_path)

f = h5py.File(h5_path, "w")
lenth = 24300

images = f.create_dataset('image', (lenth,720,1280,3), dtype='float32')
landmark = f.create_dataset('landmark', (lenth,), dtype='float32')


x_train = []
y_train = []

image_index = 0
landmark_index = 0
for i in range(1, 2):
    y_train_original = []
    pathY = '../epochs/epoch0' + str(i) + '_steering.csv'
    wheel_sig = pd.read_csv(pathY)
    y_train_original.extend(wheel_sig['wheel'].values)
    length = len(y_train_original)
    f['landmark'][landmark_index:landmark_index+length] = y_train_original
    landmark_index+=len(y_train_original)

    pathX = '../epochs/epoch0' + str(i) + '_front.mkv'
    cap = cv2.VideoCapture(pathX)

    while True:
        ret, img = cap.read()
        if(ret and image_index < 3):
            f['image'][image_index] = img
            image_index += 1
        else:
            break
    cap.release()
del images
del landmark
f.close()

首先,没有任何问题,但在运行代码几次后运行f.close时失败。

错误低于

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-1-9adabf5d88fe> in <module>()
     44 del images
     45 del landmark
---> 46 f.close()

/Users/lintao/anaconda/lib/python3.6/site-packages/h5py/_hl/files.py in close(self)
    297             for id_ in file_list:
    298                 while id_.valid:
--> 299                     h5i.dec_ref(id_)
    300 
    301             self.id.close()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper 
(/Users/ilan/minonda/conda-
bld/h5py_1496887972496/work/h5py/_objects.c:2846)()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper 
(/Users/ilan/minonda/conda-
bld/h5py_1496887972496/work/h5py/_objects.c:2804)()

h5py/h5i.pyx in h5py.h5i.dec_ref (/Users/ilan/minonda/conda-
bld/h5py_1496887972496/work/h5py/h5i.c:2497)()

RuntimeError: Can't decrement id ref count (Unable to extend file properly, errno = 28, error message = 'no space left on device')

我的操作系统是macOS Sierra 10.12.5,而我的空间仍为20GB。所以我不知道发生了什么。我在谷歌搜索,有人说inode没用了,我试图删除一些文件,但它没有用。

0 个答案:

没有答案