我在羣集上運行tensorflow。我安裝了CUDA版本。它工作沒有任何問題。要使用GPU,我必須請求資源。現在,我只想在CPU上運行而不請求GPU資源。Tensorflow僅在CPU上運行CUDA版本
On import tensorflow as tf, I get the error:
ImportError: /home/.pyenv/versions/2.7.13/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: cuDevicePrimaryCtxRetain
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
我意識到我必須只在CPU上運行,並設置環境變量CUDA_VISIBLE_DEVICES=""
。我通過bash上的export
以及python腳本完成了它。我仍然得到同樣的錯誤。
如何才能在CPU上使用tensorflow的GPU版本?可能嗎?其他一些頁面例如Run Tensorflow on CPU建議更改會話配置參數。但是,由於我在import
本身出現錯誤,我認爲這不適用或有幫助。
堆棧跟蹤:
File "<FileNameReplaced>", line 10, in <module>
import tensorflow as tf
File "/home/***/.pyenv/versions/2.7.13/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/***/.pyenv/versions/2.7.13/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/***/.pyenv/versions/2.7.13/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/***/.pyenv/versions/2.7.13/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/***/.pyenv/versions/2.7.13/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/***/.pyenv/versions/2.7.13/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
附加信息:
版本:1.1.0
這不起作用。張量流的版本是否重要?它是1.1.0。我會看看github鏈接。 – Dinesh
@edit對於環境變量,版本應該沒有關係,因爲它是CUDA的事情。對於'tf.ConfigProto',它可能,老實說我沒有用過我自己。 – jdehesa
是的,我試過環境變量。問題是我得到分段錯誤:如果我確實: 進口操作系統 os.environ [「CUDA_VISIBLE_DEVICES」] =「-1」 導入tensorflow爲tf 它引發Segmentation故障並退出python命令行。 – Dinesh