- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用tensorflow.keras 训练我的模型,但由于 OOM,它在经过一些时期后失败。 Tensorflow 2.0 已将许多内容标记为已弃用,我不知道应该如何诊断问题。
该网络由一系列 Conv1D 层和一些从一个序列转换为另一个序列的自注意力层组成。序列的长度是可变的,但序列长度和失败时间之间没有相关性。 IE:它可以很好地处理 6 分钟的序列,但无法处理 4 分钟的序列。
with tensorflow.device('/device:gpu:0'):
m2t = BuildGenerator() #builds and returns model
m2t.compile(optimizer='adam', loss='mse')
for epoch in range(1):
for inout in InputGenerator(params):
m2t.train_on_batch(inout[0], inout[1])
我尝试过的事情:
没有其他对tensorflow或keras的调用。
编辑:根据要求,示例错误日志。每次的错误都略有不同。
其中一些,其间有一些成功的运行。
W tensorflow/core/common_runtime/bfc_allocator.cc:239] Allocator (GPU_0_bfc) ran out of memory trying to allocate 1.06GiB with freed_by_count=0. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
然后就从这个开始,还有一个巨大的列表,其中包含“# chunks of size ...”和“InUse...”
W tensorflow/core/common_runtime/bfc_allocator.cc:419] Allocator (GPU_0_bfc) ran out of memory trying to allocate 43.26MiB (rounded to 45360128). Current allocation summary follows.
I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (256): Total Chunks: 79, Chunks in use: 79. 19.8KiB allocated for chunks. 19.8KiB in use in bin. 2.2KiB client-requested in use in bin.
...
I tensorflow/core/common_runtime/bfc_allocator.cc:921] Sum Total of in-use chunks: 8.40GiB
I tensorflow/core/common_runtime/bfc_allocator.cc:923] total_region_allocated_bytes_: 9109728768 memory_limit_: 9109728789 available bytes: 21 curr_region_allocation_bytes_: 17179869184
I tensorflow/core/common_runtime/bfc_allocator.cc:929] Stats:
Limit: 9109728789
InUse: 9024084224
MaxInUse: 9024084224
NumAllocs: 38387
MaxAllocSize: 1452673536
W tensorflow/core/common_runtime/bfc_allocator.cc:424]
W tensorflow/core/framework/op_kernel.cc:1622] OP_REQUIRES failed at cwise_ops_common.cc:82 : Resource exhausted: OOM when allocating tensor with shape[1,45000,12,21] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc
Traceback (most recent call last):
File ".\TrainGNet.py", line 380, in <module>
m2t.train_on_batch(inout[0], inout[1])
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\tensorflow_core\python\keras\engine\training.py", line 973, in train_on_batch
class_weight=class_weight, reset_metrics=reset_metrics)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\tensorflow_core\python\keras\engine\training_v2_utils.py", line 264, in train_on_batch
output_loss_metrics=model._output_loss_metrics)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\tensorflow_core\python\keras\engine\training_eager.py", line 311, in train_on_batch
output_loss_metrics=output_loss_metrics))
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\tensorflow_core\python\keras\engine\training_eager.py", line 268, in _process_single_batch
grads = tape.gradient(scaled_total_loss, trainable_weights)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\tensorflow_core\python\eager\backprop.py", line 1014, in gradient
unconnected_gradients=unconnected_gradients)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\tensorflow_core\python\eager\imperative_grad.py", line 76, in imperative_grad
compat.as_str(unconnected_gradients.value))
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\tensorflow_core\python\eager\backprop.py", line 138, in _gradient_function
return grad_fn(mock_op, *out_grads)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\tensorflow_core\python\ops\math_grad.py", line 251, in _MeanGrad
return math_ops.truediv(sum_grad, math_ops.cast(factor, sum_grad.dtype)), None
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\tensorflow_core\python\util\dispatch.py", line 180, in wrapper
return target(*args, **kwargs)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\tensorflow_core\python\ops\math_ops.py", line 1066, in truediv
return _truediv_python3(x, y, name)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\tensorflow_core\python\ops\math_ops.py", line 1005, in _truediv_python3
return gen_math_ops.real_div(x, y, name=name)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\tensorflow_core\python\ops\gen_math_ops.py", line 7950, in real_div
_six.raise_from(_core._status_to_exception(e.code, message), None)
File "<string>", line 3, in raise_from
tensorflow.python.framework.errors_impl.ResourceExhaustedError: OOM when allocating tensor with shape[1,45000,12,21] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc [Op:RealDiv] name: truediv/
编辑2和3:这是一个最小的例子。为我打印“11”后失败。 Edit3 显着减小了尺寸。
from tensorflow.keras.models import Model
from tensorflow.keras.layers import *
import tensorflow.keras.backend as K
import numpy as np
import tensorflow
def BuildGenerator():
i = Input(shape=(None,2,))
n_input = 12*21
to_n = Input(shape=(n_input))
s_n = Dense(12*21, activation='softmax')(to_n)
s_n = Reshape((12,21))(s_n)
n_base = Model(inputs=[to_n], outputs=[s_n])
b = Conv1D(n_input, 11, dilation_rate=1, padding='same', activation='relu', data_format='channels_last')(i)
n = TimeDistributed(n_base)(b)
return Model(inputs=[i], outputs=[n])
def InputGenerator():
for iter in range(1000):
print(iter)
i = np.zeros((1,10*60*1000,2))
n = np.zeros((1,10*60*1000,12,21))
yield ([i], [n])
with tensorflow.device('/device:gpu:0'):
m2t = BuildGenerator()
m2t.compile(optimizer='adam', loss='mse')
for epoch in range(1):
for inout in InputGenerator():
m2t.train_on_batch(inout[0], inout[1])
最佳答案
我的简单建议:
在大多数情况下,这会有所帮助。
关于python - Tensorflow 2.0 意外 OOM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58369283/
这里就涉及到一个问题,到底Kill掉谁呢?一般稍微了解一些Linux内核的同学第一反应是谁用的最多,就Kill掉谁。这当然是Linux内核首先考虑的一种重要因素,但是也不完全是这样的,我们查一些Li
这个问题在这里已经有了答案: Set a JVM to dump heap when OutOfMemoryError is thrown (2 个答案) 关闭 5 年前。 我是JAVA新手。我在用
我们正在使用 Fitnesse 对复杂的基于 Web 的应用程序进行验收测试。全套流程需要几个小时才能通过,因此我们使用多个流程。设置如下: maven fork Fitnesse 服务器进程 mav
我正在Tensorflow的LSTM-RNN上训练一些音乐数据,并且遇到了我不明白的一些GPU内存分配问题:当实际上似乎还有足够的VRAM可用时,我遇到了OOM。 一些背景: 我正在使用6GB的GTX
我正在使用 tf 运行 seq2seq 模型,当使用 tf.train.Saver 从检查点文件加载参数时,推理程序运行良好。但是在使用 freeze_graph.py(使用 tf.framework
我有一个问题需要用 JS 中的某种继承来解决。 我设置了一个小的 jsfiddle 来解释,看: V1 http://jsfiddle.net/FFTj4/5/ function Vehicule(n
这里是 JS 的新手,所以如果我遗漏了一些明显的东西,我深表歉意。尝试构建一个随机数生成器(它以嵌套方式工作,所以有点像随机数元组列表),但我收到此代码的 OOM 错误。 (比如,如果我尝试做类似 g
我有一个需要显示全屏图像的应用程序,我从可绘制文件夹中获取图像,它们大约为 150-250 kb,但它仍然崩溃并出现 OutOfMemory 错误。当然不是第一张图片,但每次用户启动应用程序时我都会加
我正在使用 spark 从 postgres 表中读取并将其作为 json 转储到 Google 云存储。该表很大,有数百个 GB。该代码相对简单(请参见下文)但因 OOM 而失败。似乎 spark
即使系统中有足够的内存并且正确提供了所有必需的内存设置,Tomcat 仍无法启动并出现 OOM。这种情况并没有持续发生,证明 tomact 配置没有问题。 15-Jan-2019 20:17:31.0
我在高负载多线程Java项目中遇到OOM异常问题。 我很感激你能给我任何帮助。 德莱尔斯: 项目是建立在Java+Mysql作为存储。 没有证据表明在应用程序崩溃时会使用额外的RAM(任何监控工具都不
我使用 Android P-OS。内核版本为msm-4.14 自启动以来,oom 被调用并终止进程。不过内存还是很丰富的。我的内存大小是8GByte,Swap是1GByte。我什至没有使用交换。 [
所有的一切, 我正在使用 openjdk 1.8.0_212-b04、Tomcat 8.0.21 和 Red Hat 6.4。 并且我已经调整了测试web应用程序,确保重新部署后不会有没有这样的消息:
所以我在 Crashlytics 中看到我们有很多崩溃是由位图的 OOM 引起的。似乎其中 60% 来自 6.0.1 上的 Galaxy S7 Edge 设备。我们拥有的是一个包含 2 个图像的着陆屏
最近我们在 Docker 容器中遇到了 Ruby 的问题。尽管负载非常低,但应用程序往往会消耗大量内存,并且在提到的一段时间后会出现 OOM。 经过一番调查,我们将问题缩小到单线 docker run
Snakemake 工作流可以在任何类型的失败后重新尝试每次重启,包括如果错误是内存不足(OOM),例如 def get_mem_mb(wildcards, attempt): return
我有一个有趣的问题。我想我发现了一个无限请求循环,它导致我的 istio-proxy 在特定情况下因 OOM 错误而崩溃。 当我直接从应用程序容器内部将请求本地提交到应用程序时,它似乎工作正常,并且在
我使用的是 ActiveMQ 5.2,我的应用程序需要大量主题,大约 500,000 个。当我运行我的应用程序时,仅创建大约 1000 个主题后,ActiveMQ 会抛出 OutOfMemoryExc
我在 k8s 运算符上部署了一个结构化流作业,它只是从 kafka 读取数据,反序列化,添加 2 列并将结果存储在数据湖中(尝试了 delta 和 parquet),几天后执行程序增加了内存,最终我得
我的Mac上的Minikube中有一个本地Kubernetes集群。我将Minio独立服务器部署为具有指定资源限制的单个容器。当我上载大于容器内存限制的文件时,容器因OOMKilled原因终止。在Ub
我是一名优秀的程序员,十分优秀!