python 内存错误_Python中的多处理内存错误

在尝试使用Python的Multiprocessing库处理大量科学计算时,遇到内存错误。当处理400x400大小的数据集时,get()方法调用失败。问题可能源于数据规模过大导致内存溢出。寻求解决内存管理的方法。
摘要由CSDN通过智能技术生成

我试图用Python进行一些昂贵的科学计算。我必须读取一堆存储在csv文件中的数据,然后进行处理。由于每个进程都需要很长时间,而且我有大约8个处理器要使用,所以我试图使用Multiprocessing中的Pool方法。

这就是我构造多处理调用的方式:pool = Pool()

vector_components = []

for sample in range(samples):

vector_field_x_i = vector_field_samples_x[sample]

vector_field_y_i = vector_field_samples_y[sample]

vector_component = pool.apply_async(vector_field_decomposer, args=(x_dim, y_dim, x_steps, y_steps,

vector_field_x_i, vector_field_y_i))

vector_components.append(vector_component)

pool.close()

pool.join()

vector_components = map(lambda k: k.get(), vector_components)

for vector_component in vector_components:

CsvH.write_vector_field(vector_component, '../CSV/RotationalFree/rotational_free_x_'+str(sample)+'.csv')

我正在运行一个500个样本的数据集,其大小等于100(x_dim)乘以100(y_dim)。

在那之前一切都很好。

然后我收到一组数据,500个样本,400 x 400。

运行时,调用get时出错。

我还试着运行一个400x 400的样本,得到了同样的错误。Traceback (most recent call last):

File "__init__.py", line 33, in

VfD.samples_vector_field_decomposer(samples, x_dim, y_dim, x_steps, y_steps, vector_field_samples_x, vector_field_samples_y)

File "/export/home/pceccon/VectorFieldDecomposer/Sources/Controllers/VectorFieldDecomposerController.py", line 43, in samples_vector_field_decomposer

vector_components = map(lambda k: k.get(), vector_components)

File "/export/home/pceccon/VectorFieldDecomposer/Sources/Controllers/VectorFieldDecomposerController.py", line 43, in

vector_components = map(lambda k: k.get(), vector_components)

File "/export/home/pceccon/.pyenv/versions/2.7.5/lib/python2.7/multiprocessing/pool.py", line 554, in get

raise self._value

MemoryError

我该怎么办?

提前谢谢你。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值