- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用 Friends Dialogues 作为数据集,使用 GPT-2 进行对话式 AI 训练,但是,它显示我内存不足。我知道这个问题已经在 StackOverflow 上得到解决,但我无法弄清楚 NLP 任务的优化。
我尝试将批量大小设置为 50(我的数据集大约有 60k 行)。我一直在关注这个tutorial在自定义数据集上重新训练 GPT-2。
我的系统规范是:
操作系统:Windows 10
内存:16GB
CPU:i7第8代
GPU:4GB 英伟达 GTX 1050Ti
这是整个错误信息
Resource exhausted: OOM when allocating tensor with shape[51200,2304] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc
Traceback (most recent call last):
File "C:\Users\bhave\AppData\Local\conda\conda\envs\tf_gpu\lib\site-packages\tensorflow\python\client\session.py", line 1334, in _do_call
return fn(*args)
File "C:\Users\bhave\AppData\Local\conda\conda\envs\tf_gpu\lib\site-packages\tensorflow\python\client\session.py", line 1319, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File "C:\Users\bhave\AppData\Local\conda\conda\envs\tf_gpu\lib\site-packages\tensorflow\python\client\session.py", line 1407, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.ResourceExhaustedError: OOM when allocating tensor with shape[51200,2304] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc
[[{{node model/h0/attn/c_attn/MatMul}}]]
Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.
[[{{node Mean}}]]
Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "train.py", line 293, in <module>
main()
File "train.py", line 271, in main
feed_dict={context: sample_batch()})
File "C:\Users\bhave\AppData\Local\conda\conda\envs\tf_gpu\lib\site-packages\tensorflow\python\client\session.py", line 929, in run
run_metadata_ptr)
File "C:\Users\bhave\AppData\Local\conda\conda\envs\tf_gpu\lib\site-packages\tensorflow\python\client\session.py", line 1152, in _run
feed_dict_tensor, options, run_metadata)
File "C:\Users\bhave\AppData\Local\conda\conda\envs\tf_gpu\lib\site-packages\tensorflow\python\client\session.py", line 1328, in _do_run
run_metadata)
File "C:\Users\bhave\AppData\Local\conda\conda\envs\tf_gpu\lib\site-packages\tensorflow\python\client\session.py", line 1348, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.ResourceExhaustedError: OOM when allocating tensor with shape[51200,2304] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc
[[node model/h0/attn/c_attn/MatMul (defined at D:\Python and AI\Generative Chatbot\gpt-2\src\model.py:55) ]]
Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.
[[node Mean (defined at train.py:96) ]]
Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.
Caused by op 'model/h0/attn/c_attn/MatMul', defined at:
File "train.py", line 293, in <module>
main()
File "train.py", line 93, in main
output = model.model(hparams=hparams, X=context_in)
File "D:\Python and AI\Generative Chatbot\gpt-2\src\model.py", line 164, in model
h, present = block(h, 'h%d' % layer, past=past, hparams=hparams)
File "D:\Python and AI\Generative Chatbot\gpt-2\src\model.py", line 126, in block
a, present = attn(norm(x, 'ln_1'), 'attn', nx, past=past, hparams=hparams)
File "D:\Python and AI\Generative Chatbot\gpt-2\src\model.py", line 102, in attn
c = conv1d(x, 'c_attn', n_state*3)
File "D:\Python and AI\Generative Chatbot\gpt-2\src\model.py", line 55, in conv1d
c = tf.reshape(tf.matmul(tf.reshape(x, [-1, nx]), tf.reshape(w, [-1, nf]))+b, start+[nf])
File "C:\Users\bhave\AppData\Local\conda\conda\envs\tf_gpu\lib\site-packages\tensorflow\python\ops\math_ops.py", line 2455, in matmul
a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)
File "C:\Users\bhave\AppData\Local\conda\conda\envs\tf_gpu\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 5333, in mat_mul
name=name)
File "C:\Users\bhave\AppData\Local\conda\conda\envs\tf_gpu\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 788, in _apply_op_helper
op_def=op_def)
File "C:\Users\bhave\AppData\Local\conda\conda\envs\tf_gpu\lib\site-packages\tensorflow\python\util\deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "C:\Users\bhave\AppData\Local\conda\conda\envs\tf_gpu\lib\site-packages\tensorflow\python\framework\ops.py", line 3300, in create_op
op_def=op_def)
File "C:\Users\bhave\AppData\Local\conda\conda\envs\tf_gpu\lib\site-packages\tensorflow\python\framework\ops.py", line 1801, in __init__
self._traceback = tf_stack.extract_stack()
ResourceExhaustedError (see above for traceback): OOM when allocating tensor with shape[51200,2304] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator
GPU_0_bfc
[[node model/h0/attn/c_attn/MatMul (defined at D:\Python and AI\Generative Chatbot\gpt-2\src\model.py:55) ]]
Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.
[[node Mean (defined at train.py:96) ]]
Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.
最佳答案
我猜它总是意味着同样的事情。尝试批量大小为 1,看看是否有效。然后增加批量大小以找到您的 gpu 可以处理多少。如果它无法处理 1 的批量大小,则模型对于您的 GPU 来说可能太大了。如果您没有立即收到此错误,请检查代码是否正常,可能其中存在一些错误。哦,也许您应该检查一下还有什么正在使用您的 gpu,以确保没有任何不必要的东西占用资源。
关于python - "Resource exhausted: OOM when allocating tensor"在重新训练 GPT 2 模型 : 期间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56307656/
N3485 20.6.9.1 [allocator.members]/1 说: Calls to these functions that allocate or deallocate a parti
我想编写一个调用 createHook() 的自定义分配器在对象构造和对称之后 destroyHook()就在对象销毁之前。我以这种方式使用我的分配器: class Object {}; class
我正在用 C++ 重新创建一个链表,并且在重载 += 运算符时得到了一个错误的指针。我想我只是以错误的方式使用了分配器,但我可能是错的。 这里是上下文: void MyLinkedList::oper
Allocator concept和 std::allocator_traits没有说明 allocate 是否会抛出。 所以当我使用分配器编写容器时,如何知道是检查返回类型还是使用 catch? 最
C++20 删除了 construct()和 destruct()成员(member)来自 std::allocator .我应该如何构造通过 std::allocator::allocate() 分
这个问题听起来可能相当初级,但这是我与另一位合作开发人员的辩论。 我注意在可能的地方分配堆栈,而不是堆分配它们。他在和我说话并看着我的肩膀并评论说没有必要,因为他们在表现方面是一样的。 我一直认为堆栈
这个问题听起来可能相当初级,但这是我与另一位合作开发者的争论。 我一直在尽可能地堆栈分配东西,而不是堆分配它们。他一边跟我说话,一边看着我,并评论说没有必要,因为它们在性能方面是相同的。 我一直认为堆
在 Java 程序中,当需要分配数千个相似大小的对象时,最好(在我看来)有一个“池”(这是一个单一的分配),其中包含可以从中提取的保留项目需要的时候。这个单一的大分配不会像数千个较小的分配那样使堆碎片
我正在尝试使用 TBB 来提升使用 OpenCV 的计算机视觉项目的性能。这是代码中给出访问冲突的部分。 #include #include "opencv2/objdetect/objdetect
我对一个问题有疑问,特别是关于 this 的问题回答。 有一部分留给读者作为练习(这本身不是问题),特别是 Jonathan Wakely(答案的作者)说: This code asserts tha
Allocator concept和 std::allocator_traits不要说当分配失败时 allocate 会做什么——它会返回 nullptr 还是抛出异常? 当我使用标准分配器 API
我有充分的理由不应该做这样的事情吗?示例: 我有一个类(class)MyClass。在那里我有这个实现: - (id)copyWithZone:(NSZone*)zone { MyClass
相关但不重复:请参阅此答案的底部,在单击此问题下方的“关闭”按钮之前,我解决了您可能想要声明的重复项。 自动生成 ROS (Robot Operating System) message C++ 头文
据我所知std::allocator::construct在旧版本的 C++ 上仅需要两个参数;第一个是指向原始的、未构造的内存的指针,我们要在其中构造 T 类型的对象。第二个是用于初始化该对象的元素
40个不同的分配函数给40个不同的调用点 void f00(size_t sz) { void* ptr = malloc(sz); free(ptr); } void f01(size_t sz)
我在使用 RenderScript 时一直遇到内存管理问题,所以我认为由于 Allocation.createFromBitmap()/createTyped() 消耗内存,Allocation.de
我正在尝试使用 valgrind 跟踪段错误。我从 valgrind 收到以下消息: ==3683== Conditional jump or move depends on uninitialise
实际上,我正在尝试创建一个包含 n 个多媒体文件(包括图像和视频)的应用程序。我的应用程序大小约为 34MB,我的 Assets 大小约为 60mb。当我在普通设备上加载应用程序时,我们没有遇到任何问
STL 容器有一个模板参数可以选择自定义分配器。花了一段时间,但我想我明白它是如何工作的。不知何故,它并不是很好,因为给定的分配器类型没有直接使用,而是反弹到另一种类型的分配器。我终于可以使用它了。
new int[0]在 C++ 中是允许的,但 std::allocator().allocate(0)定义好? 更一般地说,所有分配器都必须接受 0作为参数分配? 编辑: 阅读答案后,我测试了 Vi
我是一名优秀的程序员,十分优秀!