python - 在没有 NVIDIA GPU 的情况下导入 Tensorflow(ImportError: 找不到 'nvcuda.dll')
问题描述
我已经tensorflow
使用 Anaconda Navigator 安装了该软件包。当我尝试import tensorflow
在 jupyter notebook 中运行时,出现以下错误:
OSError Traceback (most recent call last)
D:\ProgrammFiles\Anaconda\lib\site-packages\tensorflow\python\platform\self_check.py in preload_check()
61 try:
---> 62 ctypes.WinDLL(build_info.nvcuda_dll_name)
63 except OSError:
D:\ProgrammFiles\Anaconda\lib\ctypes\__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:\ProgrammFiles\Anaconda\lib\site-packages\tensorflow\__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:\ProgrammFiles\Anaconda\lib\site-packages\tensorflow\python\__init__.py in <module>
47 import numpy as np
48
---> 49 from tensorflow.python import pywrap_tensorflow
50
51 # Protocol buffers
D:\ProgrammFiles\Anaconda\lib\site-packages\tensorflow\python\pywrap_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:\ProgrammFiles\Anaconda\lib\site-packages\tensorflow\python\platform\self_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:\Windows\System32'. 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-navigator 不是安装tensorflow
. 我的假设是tensorflow-base
或者tensorflow-estimate
具有 GPU 依赖关系,这就是它不断显示发布的错误消息的原因。
最好的安装方式是通过tensorflow
官方渠道安装。你可以通过运行来做到这一点:conda
conda-forge
conda install -c conda-forge tensorflow
推荐阅读
- classloader - 我的 ByteBuddy 生成的类互相看不到
- r - 将变量除以数据框中的其他变量
- javafx - JavaFX:从内部照亮对象
- javascript - 使用 vuetify.js 创建表和子表——不知道从哪里开始
- c# - 将分隔字符串转换为 Expando 对象
- php - 多文件输入和表单验证?
- python - 将条目与分桶表阈值进行比较,因为它们被填充到 SQL 数据库中
- python - 在 Beautiful Soup 中定位没有标签的文本元素
- javascript - 如何使用ajax在laravel中几秒钟后自动存储数据?
- python - pandas 数据框以 csv 格式导出到 zip 文件中