gpt4 book ai didi

python - 使用 tensorflow 时 GPU 同步失败

转载 作者:太空宇宙 更新时间:2023-11-04 06:49:47 24 4
gpt4 key购买 nike

我正在尝试运行这个简单的代码来测试 tensorflow

  from __future__ import print_function

import tensorflow as tf

a = tf.constant(2)
b = tf.constant(3)


with tf.Session() as sess:
print("a=2, b=3")
print("Addition with constants: %i" % sess.run(a+b))

但奇怪的是获取 GPU 同步失败错误。

回溯:

runfile('D:/tf_examples-master/untitled3.py', wdir='D:/tf_examples-master')
a=2, b=3
Traceback (most recent call last):

File "<ipython-input-5-d4753a508b93>", line 1, in <module>
runfile('D:/tf_examples-master/untitled3.py', wdir='D:/tf_examples-master')

File "C:\ProgramData\Anaconda3\envs\env3-gpu\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
execfile(filename, namespace)

File "C:\ProgramData\Anaconda3\envs\env3-gpu\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "D:/tf_examples-master/untitled3.py", line 15, in <module>
print("Multiplication with constants: %i" % sess.run(a*b))

File "C:\ProgramData\Anaconda3\envs\env3-gpu\lib\site-packages\tensorflow\python\client\session.py", line 900, in run
run_metadata_ptr)

File "C:\ProgramData\Anaconda3\envs\env3-gpu\lib\site-packages\tensorflow\python\client\session.py", line 1135, in _run
feed_dict_tensor, options, run_metadata)

File "C:\ProgramData\Anaconda3\envs\env3-gpu\lib\site-packages\tensorflow\python\client\session.py", line 1316, in _do_run
run_metadata)

File "C:\ProgramData\Anaconda3\envs\env3-gpu\lib\site-packages\tensorflow\python\client\session.py", line 1335, in _do_call
raise type(e)(node_def, op, message)

InternalError: GPU sync failed

我们将不胜感激。

最佳答案

当我遇到此错误时 GPU 同步失败。重新启动我的笔记本/内核没有帮助。

我有另一个笔记本电脑/内核没有关闭并且正在使用我的 GPU,所以要解决这个问题,我所做的就是关闭另一个笔记本电脑,重新启动我当前的笔记本电脑,一切正常!

关于python - 使用 tensorflow 时 GPU 同步失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51112126/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com