无法以数组形状分配内存来创建强化学习模型
我正在尝试为 mario 环境创建 DQN 模型。但是当我尝试创建模型时,它给了我这个错误:
内存错误:无法为形状为 (1000000, 1, 4, 240, 256) 和数据类型为 uint8 的数组分配 229.GiB
这是创建模型的代码:
model = DQN('CnnPolicy', env, verbose=1, tensorboard_log=LOG_DIR, learning_rate=0.000001)
我在这个项目中使用 Jupyter 笔记本。
I am trying to create a DQN model for mario environment. But when I try to create the model it gives me this error:
MemoryError: Unable to allocate 229. GiB for an array with shape (1000000, 1, 4, 240, 256) and data type uint8
This is the code for creating the model:
model = DQN('CnnPolicy', env, verbose=1, tensorboard_log=LOG_DIR, learning_rate=0.000001)
I am using Jupyter notebook for this project.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您根本没有足够的 RAM 来为该大小的数组分配 229 GiB(这是非常大的),很少有计算机可以。
您是否尝试过将您的想法分成 64、128、256 等批次?这是减少内存负载的一种非常常见的方法,您可以尝试不同的值,看看您可以处理什么计算。 Tensorflow 有大量内置方法可以为您提供帮助。一个值得一看的地方是此处的批处理方法。
It looks like you simply don't have enough RAM to allocate 229 GiB for an array of that size---which is incredibly large---very few computers could.
Have you tried batching your idea into batches of either 64, 128, 256, etc.? That is a very common way to decrease the memory load, and you can experiment with different values to see what computation you can handle. Tensorflow has a great deal of built-in methods that can help you here. One place to look would be the batch method here.