Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

内存分配不够,Unable to allocate 29.0 GiB for an array with shape (7790126400,) and data type float32 #56

Closed
XieLinMofromsomewhere opened this issue Jun 11, 2020 · 7 comments

Comments

@XieLinMofromsomewhere
Copy link

当运行python data_gen/gen_bone_data.py这据代码时,会在
File "data_gen/gen_bone_data.py", line 62, in
data = np.load('./data/{}/{}_data.npy'.format(dataset, set))
处遇到
MemoryError: Unable to allocate 29.0 GiB for an array with shape (7790126400,) and data type float32
这样的错误,请问该如何解决呢?

@erinchen824
Copy link

erinchen824 commented Jul 10, 2020

当运行python data_gen/gen_bone_data.py这据代码时,会在
File "data_gen/gen_bone_data.py", line 62, in
data = np.load('./data/{}/{}_data.npy'.format(dataset, set))
处遇到
MemoryError: Unable to allocate 29.0 GiB for an array with shape (7790126400,) and data type float32
这样的错误,请问该如何解决呢?

请问是怎么解决的啊?谢谢!

@XieLinMofromsomewhere
Copy link
Author

当运行python data_gen/gen_bone_data.py这据代码时,会在
File "data_gen/gen_bone_data.py", line 62, in
data = np.load('./data/{}/{}_data.npy'.format(dataset, set))
处遇到
MemoryError: Unable to allocate 29.0 GiB for an array with shape (7790126400,) and data type float32
这样的错误,请问该如何解决呢?

请问是怎么解决的啊?谢谢!

我的内存是16G,而这里投入的训练数据是30G,所以就超内存了,目前除了用更大的内存外还没找到其他方法。

@erinchen824
Copy link

当运行python data_gen/gen_bone_data.py这据代码时,会在
File "data_gen/gen_bone_data.py", line 62, in
data = np.load('./data/{}/{}_data.npy'.format(dataset, set))
处遇到
MemoryError: Unable to allocate 29.0 GiB for an array with shape (7790126400,) and data type float32
这样的错误,请问该如何解决呢?

请问是怎么解决的啊?谢谢!

我的内存是16G,而这里投入的训练数据是30G,所以就超内存了,目前除了用更大的内存外还没找到其他方法。

好的,谢谢啦

@lshiwjx
Copy link
Owner

lshiwjx commented Jul 10, 2020

np.load函数有一个mmap_mode参数,可以不用将数据全部加载。
类似于

self.data = np.load(self.data_path, mmap_mode='r')

@XieLinMofromsomewhere
Copy link
Author

np.load函数有一个mmap_mode参数,可以不用将数据全部加载。
类似于

self.data = np.load(self.data_path, mmap_mode='r')

感谢!

@erinchen824
Copy link

erinchen824 commented Jul 10, 2020

np.load函数有一个mmap_mode参数,可以不用将数据全部加载。
类似于

self.data = np.load(self.data_path, mmap_mode='r')

谢谢,处理好了

`for dataset in datasets:
for set in sets:
print(dataset, set)

    #change the load mode to mmap_mode
    data = np.load('./data/{}/{}_data_joint.npy'.format(dataset, set), mmap_mode='r')
    data_out_path = './data/{}/{}_data_bone.npy'.format(dataset, set)
    N, C, T, V, M = data.shape

    fp_sp = open_memmap(
        './data/{}/{}_data_bone.npy'.format(dataset, set),
        dtype='float32',
        mode='w+',
        shape=(N, 3, T, V, M))

    for rr in range(N):
    	print(rr,N)
    	fp_sp[rr, :C, :, :, :] = data[rr]
    	for v1, v2 in tqdm(paris[dataset]):
    		if dataset != 'kinetics':
    			v1 -= 1
    			v2 -= 1
    		fp_sp[rr, :, :, v1, :] = data[rr, :, :, v1, :] - data[rr, :, :, v2, :]`

@XieLinMofromsomewhere
Copy link
Author

data_out_path

这个好像增大电脑的虚拟内存和pycharm可用的内存后也可以处理。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants