在没有 NVIDIA GPU 的情况下导入 Tensorflow(导入错误:找不到"nvcuda.dll")



我已经使用Anaconda Navigator安装了tensorflow包。当我尝试在jupyter笔记本电脑中运行import tensorflow时,我得到以下错误:

OSError                                   Traceback (most recent call last)
D:ProgrammFilesAnacondalibsite-packagestensorflowpythonplatformself_check.py in preload_check()
61         try:
---> 62           ctypes.WinDLL(build_info.nvcuda_dll_name)
63         except OSError:
D:ProgrammFilesAnacondalibctypes__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
363         if handle is None:
--> 364             self._handle = _dlopen(self._name, mode)
365         else:
OSError: [WinError 126] Det går inte att hitta den angivna modulen
During handling of the above exception, another exception occurred:
ImportError                               Traceback (most recent call last)
<ipython-input-8-d6579f534729> in <module>
----> 1 import tensorflow
D:ProgrammFilesAnacondalibsite-packagestensorflow__init__.py in <module>
26 
27 # pylint: disable=g-bad-import-order
---> 28 from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
29 from tensorflow.python.tools import module_util as _module_util
30 
D:ProgrammFilesAnacondalibsite-packagestensorflowpython__init__.py in <module>
47 import numpy as np
48 
---> 49 from tensorflow.python import pywrap_tensorflow
50 
51 # Protocol buffers
D:ProgrammFilesAnacondalibsite-packagestensorflowpythonpywrap_tensorflow.py in <module>
28 # Perform pre-load sanity checks in order to produce a more actionable error
29 # than we get from an error during SWIG import.
---> 30 self_check.preload_check()
31 
32 # pylint: disable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
D:ProgrammFilesAnacondalibsite-packagestensorflowpythonplatformself_check.py in preload_check()
68               "'C:\Windows\System32'. If it is not present, ensure that you "
69               "have a CUDA-capable GPU with the correct driver installed."
---> 70               % build_info.nvcuda_dll_name)
71 
72       if hasattr(build_info, "cudart_dll_name") and hasattr(
ImportError: Could not find 'nvcuda.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Typically it is installed in 'C:WindowsSystem32'. If it is not present, ensure that you have a CUDA-capable GPU with the correct driver installed.

我知道我不能使用tensorflow-gpu,因为我没有NVIDIA GPU。因此,我甚至还没有安装tensorflow-gpu软件包。

在没有安装CUDA的情况下,我应该如何导入TensorFlow?

正如评论中所讨论的,问题只出现在您的安装中。使用anaconda导航器并不是安装tensorflow的最佳方式。我的假设是tensorflow-basetensorflow-estimate具有GPU依赖性,这就是它不断显示发布的错误消息的原因。

使用conda安装tensorflow的最佳方式是通过conda-forge通道,这是官方的方式。你可以通过运行来做到这一点

conda install -c conda-forge tensorflow

相关内容

最新更新