使用 tensorflow 时 GPU 同步失败 [英] GPU Sync Failed While using tensorflow

查看:45
本文介绍了使用 tensorflow 时 GPU 同步失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to run this simple code to test 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 同步失败错误.

But weirdly getting GPU sync failed error.

追溯:

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 同步失败.重新启动我的笔记本/内核没有帮助.

When I got this error GPU sync failed. Restarting my notebook/kernel did not help.

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

I had another notebook/kernel that was not shutdown and was using my GPU, so to fix this issue all I did was to shutdown the other notebook, restart my current notebook and everything worked!

这篇关于使用 tensorflow 时 GPU 同步失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆