我有一个关于使用tensorflow gpu的问题。当我在训练步骤中使用tensorflow gpu时,它工作得非常好,实际上比我预期的要好。它使用我的笔记本电脑gpu(Geforce 940m笔记本电脑)几乎100%,性能令人满意。你知道吗
然而,当我试图使用tensorflow gpu在实时或一些视频对象检测,它只使用我的gpu约30%和会话部分需要这么多时间才能完成。我还得到了一个叫做ran out of memory trying to allocate 2.26GiB with freed_by_count=0.
的错误。你知道吗
我会把一些截图的链接下面,以清除一切关于我的问题。你知道吗
我想找出解决这个错误的办法,但对我不起作用。 我尝试的是:
How can I solve 'ran out of gpu memory' in TensorFlow
How to prevent tensorflow from allocating the totality of a GPU memory?
我的图形卡功能(Nvdia GeForce 940M):
内存:2048 GPU默认时钟:1072 MHz GPU增强时钟:1176 MHz
以下是我的部分代码:
with detection_graph.as_default():
with tf.Session(graph=detection_graph,
config=tf.ConfigProto(gpu_options=gpu_options)) as sess:
model = tf.keras.models.load_model("CNN-3")
while True:
ret, image_np = cap.read()
if W is None or H is None:
(H, W)= image_np.shape[:2]
image_np_expanded = np.expand_dims(image_np, axis=0)
image_tensor = detection_graph.get_tensor_by_name('image_tensor:0')
boxes = detection_graph.get_tensor_by_name('detection_boxes:0')
scores = detection_graph.get_tensor_by_name('detection_scores:0')
classes = detection_graph.get_tensor_by_name('detection_classes:0')
num_detections =
detection_graph.get_tensor_by_name('num_detections:0')
(boxes, scores, classes, num_detections) = sess.run(
[boxes, scores, classes, num_detections],
feed_dict={image_tensor: image_np_expanded})
训练步骤中的这些图像:
https://pasteboard.co/IowqeLE.jpg----- https://pasteboard.co/IowpXpV.gif
当目标实时检测时:
https://pasteboard.co/IowqJME.jpg----- https://pasteboard.co/Iowr8gS.gif
这是一条错误消息:
目前没有回答
相关问题 更多 >
编程相关推荐