首页 > 解决方案 > tensorflow.python.framework.errors InternalError:无法创建会话

问题描述

我是张量流初学者。当我运行 test.py 时。有一个错误:

2018-05-13 10:00:03.012495: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2018-05-13 10:00:03.312772: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1344] Found device 0 with properties: 
name: TITAN Xp major: 6 minor: 1 memoryClockRate(GHz): 1.911
pciBusID: 0000:05:00.0
totalMemory: 11.90GiB freeMemory: 11.58GiB
2018-05-13 10:00:03.591350: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1344] Found device 1 with properties: 
name: TITAN Xp major: 6 minor: 1 memoryClockRate(GHz): 1.911
pciBusID: 0000:06:00.0
totalMemory: 11.90GiB freeMemory: 11.74GiB
2018-05-13 10:00:03.862648: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1344] Found device 2 with properties: 
name: TITAN Xp major: 6 minor: 1 memoryClockRate(GHz): 1.911
pciBusID: 0000:09:00.0
totalMemory: 11.90GiB freeMemory: 11.74GiB
2018-05-13 10:00:04.117984: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1344] Found device 3 with properties: 
name: TITAN Xp major: 6 minor: 1 memoryClockRate(GHz): 1.911
pciBusID: 0000:0a:00.0
totalMemory: 11.90GiB freeMemory: 11.74GiB
2018-05-13 10:00:04.123222: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1423] Adding visible gpu devices: 0, 1, 2, 3
2018-05-13 10:00:04.123350: E tensorflow/core/common_runtime/direct_session.cc:167] Internal: cudaGetDevice() failed. Status: CUDA driver version is insufficient for CUDA runtime version
Traceback (most recent call last):
  File "test.py", line 5, in <module>
    sess = tf.Session()
  File "/home/zhe/anaconda3/envs/tf_env/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1509, in __init__
super(Session, self).__init__(target, graph, config=config)
  File "/home/zhe/anaconda3/envs/tf_env/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 638, in __init__
self._session = tf_session.TF_NewDeprecatedSession(opts, status)
  File "/home/zhe/anaconda3/envs/tf_env/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 516, in __exit__
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InternalError: Failed to create session.

tensorflow-gpu 版本 1.7.0

nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Tue_Jan_10_13:22:03_CST_2017
Cuda compilation tools, release 8.0, V8.0.61

测试.py:

import tensorflow as tf
import os
#os.environ["CUDA_VISIBLE_DEVICES"]="3"
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

我的实验室同事没有这个问题。我尝试使用注释的代码行,但它不起作用,而且是同样的错误。

谢谢你的帮助!

标签: pythontensorflowcuda

解决方案


错误消息的这一行中指定了问题:

内部:cudaGetDevice() 失败。状态:CUDA 驱动程序版本对于 CUDA 运行时版本不足

您需要更新 CUDA 驱动程序。或者,只需重新安装整个 CUDA 工具包


推荐阅读