python - 使用 tensorflow 时 GPU 同步失败
问题描述
我正在尝试运行这个简单的代码来测试 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 sync failed
。重新启动我的笔记本/内核没有帮助。
我有另一个笔记本/内核没有关闭并且正在使用我的 GPU,所以为了解决这个问题,我所做的就是关闭另一个笔记本,重新启动我当前的笔记本,一切正常!
推荐阅读
- json - 无效的 JSON。缺失的符号
- nginx - Nginx split_clients 不划分流量
- php - laravel ajax 成功后如何刷新数据表?
- python - Python/Pandas:根据另一个数据框过滤和组织数据框的行和列
- python - 将链表中的元素与列表的其余部分进行比较python
- php - PDO 插入空而不是空?
- python - 如何为谓词调用 leaveOut 条目
- c - 在 C 中递归文件时如何打印整个路径名和单个路径名?
- javascript - TypeScript & Yup 错误:“参考”类型的参数
' 不能分配给 'number | 类型的参数 参考 ' - flutter - 哪种架构更适合具有大量 API 调用的 Flutter 应用程序?