【8.1】tensorflow报错
报错1:
Your CPU supports instructions that this TensorFlow binary was not compiled to use
解决办法为:
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
报错2:
2017-06-16 13:53:53.632070: W tensorflow/stream_executor/cuda/cuda_driver.cc:523] A non-primary context 0x3f287f0 exists before initializing the StreamExecutor. We haven't verified StreamExecutor works with that.
2017-06-16 13:53:53.632367: E tensorflow/core/common_runtime/direct_session.cc:138] Internal: failed initializing StreamExecutor for CUDA device ordinal 1: Internal: failed call to cuDevicePrimaryCtxRetain: CUDA_ERROR_INVALID_DEVICE
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/zw/jy/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1292, in __init__
super(Session, self).__init__(target, graph, config=config)
File "/home/zw/jy/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 562, in __init__
self._session = tf_session.TF_NewDeprecatedSession(opts, status)
File "/usr/lib/python3.5/contextlib.py", line 66, in __exit__
next(self.gen)
File "/home/zw/jy/lib/python3.5/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InternalError: Failed to create session.
---------------------
原因: 因为有其他的程序使用GPU,tensorflow一下子不知道用哪个GPU了
解决方法:
方法1 在python程序中
os.environ["CUDA_DEVICE_ORDER"] = 'PCI_BUS_ID'
os.environ["CUDA_VISIBLE_DEVICES"] = '0,1,2,3,4' # 显示让哪几个GPU被发现,可以通过nvis
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
方法2 运行时
CUDA_VISIBLE_DEVICES=1 python **.py
方法3 直接在环境变量中 export
参考资料
这里是一个广告位,,感兴趣的都可以发邮件聊聊:tiehan@sina.cn
个人公众号,比较懒,很少更新,可以在上面提问题,如果回复不及时,可发邮件给我: tiehan@sina.cn
个人公众号,比较懒,很少更新,可以在上面提问题,如果回复不及时,可发邮件给我: tiehan@sina.cn