我在Ubuntu上使用Python 2.7设置了Conda环境。安装Tensorflow 1.4似乎没有问题后,现在由于某种原因我无法创建会话。运行以下代码行:
import tensorflow as tf
sess = tf.Session()
产生以下错误:
2018-07-19 14:56:46.660399: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Found device 0 with properties:
name: GeForce GTX 1080 major: 6 minor: 1 memoryClockRate(GHz): 1.8095
pciBusID: 0000:05:00.0
totalMemory: 7.92GiB freeMemory: 6.83GiB
2018-07-19 14:56:46.780827: E tensorflow/core/common_runtime/direct_session.cc:170] Internal: failed initializing StreamExecutor for CUDA device ordinal 1: Internal: failed call to cuDevicePrimaryCtxRetain: CUDA_ERROR_OUT_OF_MEMORY; total memory reported: 8508145664
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/me/.conda/envs/py2/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1482, in __init__
super(Session, self).__init__(target, graph, config=config)
File "/home/me/.conda/envs/py2/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 622, in __init__
self._session = tf_session.TF_NewDeprecatedSession(opts, status)
File "/home/me/.conda/envs/py2/lib/python2.7/site-packages/tensorflow/python/framework/errors_impl.py", line 473, in __exit__
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InternalError: Failed to create session.
我可以通过选择如下所示使用的GPU来修复它,但这不是我想要做的:
import os
os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID" # see issue #152
os.environ["CUDA_VISIBLE_DEVICES"]="0"
我认为应该调用CUDA_ERROR_OUT_OF_MEMORY
是没有意义的,尤其是要看一开始如何有足够的可用内存。另外,我可以在同一台机器上运行Tensorflow 1.4,而该版本没有Python 3.6之前发布的版本。
这里可能是什么问题?
谢谢。