无法以数组形状分配内存来创建强化学习模型

发布于 2025-01-15 22:32:04 字数 315 浏览 5 评论 0原文

我正在尝试为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

草莓味的萝莉 2025-01-22 22:32:04

看起来您根本没有足够的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文