以下两个循环将使用内存,直到我用完,但我不明白为什么。我在每次迭代结束时删除所有创建的变量,但它仍然泄漏。!pip3 install cupy-cuda101import cupy as cpimport numpy as npfrom sklearn.preprocessing import PolynomialFeaturesxtrain = cp.asnumpy(cp.random.uniform(-1,1,size = (150000,50)))for i in range(0,1000): weights = cp.random.uniform(-1,1,size = (1275,1000)) for chunk in range(0,xtrain.shape[0],5000): xchunk = xtrain[chunk:chunk+5000,:] poly=PolynomialFeatures(interaction_only = True, include_bias = False) xchunk = cp.array(poly.fit_transform(xchunk)) ranks = cp.matmul(xchunk,weights) del ranks, xchunk, poly del weightsxtrain 也只是浮点数据,介于 -1 和 1 之间。
1 回答
萧十郎
TA贡献1815条经验 获得超13个赞
这些行在每次迭代结束时插入修复它:
cp.get_default_memory_pool().free_all_blocks() cp.get_default_pinned_memory_pool().free_all_blocks()
添加回答
举报
0/150
提交
取消