【发布时间】:2021-01-27 20:19:39
【问题描述】:
我的代码中出现此错误: MemoryError:无法为形状为 (61, 17, 41, 59, 51, 11) 且数据类型为 float64 的数组分配 10.5 GiB 当我尝试在
运行我的代码时#Control test to look at 4-Seamer at different approaches
import numpy as np
import math
#Creating the Arrays for the baseball pitch (Testing 4-Seam FB)
phi=np.linspace(175,180,61)*math.pi/180.0
theta=np.linspace(-4,4,17)*math.pi/180.0
speed=np.linspace(90,100,41)
tilt=np.linspace(190,235,59)*math.pi/180.0
RPM=np.linspace(2050,2350,51)
gyro=np.linspace(0,10,11)*math.pi/180.0
#Weather Conditions (Control shown here for TB's Tropicana Dome)
tf=72.0
tc=(tf-32)*5/9
tk=tc+273.15
press=1013.15
ppa=press*100.0
RH=0.55
rho=ppa/(287*tk)
tau=500
dt=0.0001
#Release Points
x0=-2.5
y0=55.0
z0=6.0
backtopspin=np.empty(((61),(17),(41),(59),(51),(11)))
sidespin=np.empty(np.shape(backtopspin))
我正在尝试开发此代码,以便查看任何角度、速度和旋转的最轻微变化将如何影响运动。 T
谢谢。
【问题讨论】:
-
你的机器有多少内存?
-
8 GB,7.88 GB 可用。
-
这就是该对象占用的内存量。你的电脑上没有那么多可用的东西。你不能分配对象。您可以手动将问题分解为更小的部分,也可以使用 Dask 等专为核外计算而设计的工具。
-
您可以使用 AWS/GCP 提供的云计算资源,按小时租用它,并且拥有比您的 PC 更多的 RAM
-
有没有更好的方法让我拥有这些数组,因为我想将我的研究扩展到未来,而不必在每次运行时手动输入每个细节。