内存错误-Jupyter Python3-AWS实例

时间:2018-12-21 23:27:17

标签: python-3.x amazon-ec2 jupyter-notebook

我正在t2.2xlarge AWS实例上运行Jupyter笔记本,并在处理以下功能(在第一行'dataset ='上)时遇到“内存错误”:

def tensor_maker(image_list):

    dataset = np.ndarray(shape=(len(image_list), 1, 16384))
    print('Images to process: ' + str(len(image_list)))
    i = 0
    for file in image_list:
        img = load_img(file, color_mode = "grayscale")  # this is a PIL image
        x = img_to_array(img)
        reshaped = x.reshape(1, 16384)
        dataset[i] = reshaped
        i += 1
        if i % 10000 == 0:
            print("%d images to array" % i)
    print('Processing Complete -')
    return(dataset)

这是AWS,Jupyter还是代码本身的问题?

psutil.virtual_memory()的输出是:

svmem(total=33731997696, 
available=33273999360, 
percent=1.4, 
used=753344512, 
free=32978653184, 
active=388292608, 
inactive=188358656, 
buffers=2138112, 
cached=293208064, 
shared=438272)

0 个答案:

没有答案