我没有 Nvidia GPU,但想在 CPU 上 运行 Tensorflow 模型。为什么它一直要求一些 CUDA DLL?

I don't have an Nvidia GPU and want to run a Tensorflow model on the CPU. Why does it keep asking for some CUDA DLL?

我关注了these instructions

具体来说,我想 运行 从 Github 下载 Tensorflow 模型。我的电脑上只有一个 Intel GPU,所以我想在我的 CPU 上执行 Tensorflow 模型。如 here on GitHub 所述,将 use-gpu 参数设置为 false 应该是可能的。所以我 运行 这个命令:

python test_model.py model=iphone_orig dped_dir=dped/ test_subset=full iteration=all resolution=orig use_gpu=false

但是,我收到以下错误,最后两行表明 tensorflow 尝试在 GPU 上 运行,这是控制台 window:

C:\Users\username\Downloads\DPED-master\DPED-master>python test_model.py model=iphone_orig dped_dir=dped/ test_subset=full iteration=all resolution=orig use_gpu=false
Traceback (most recent call last):
  File "C:\Users\username\Downloads\WPy64-3720\python-3.7.2.amd64\lib\site-packages\tensorflow\python\platform\self_check.py", line 62, in preload_check
    ctypes.WinDLL(build_info.nvcuda_dll_name)
  File "C:\Users\username\Downloads\WPy64-3720\python-3.7.2.amd64\lib\ctypes\__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] Das angegebene Modul wurde nicht gefunden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test_model.py", line 5, in <module>
    import tensorflow as tf
  File "C:\Users\username\Downloads\WPy64-3720\python-3.7.2.amd64\lib\site-packages\tensorflow\__init__.py", line 28, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "C:\Users\username\Downloads\WPy64-3720\python-3.7.2.amd64\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\username\Downloads\WPy64-3720\python-3.7.2.amd64\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 30, in <module>
    self_check.preload_check()
  File "C:\Users\username\Downloads\WPy64-3720\python-3.7.2.amd64\lib\site-packages\tensorflow\python\platform\self_check.py", line 70, in preload_check
    % build_info.nvcuda_dll_name)
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.

您找到了相关的 test_model.py 文件 here

我尝试了几次执行,有和没有 GPU 设置。我能做些什么来修复它?

tensorlfow有两个模块:'tensorflow','tensorflow-gpu' 在 cpu 上,您需要使用 pip install tensorflow 或在 conda conda install tensorflow

上安装 tensorlfow

编辑第二个问题:

如果将 TensorFlow 操作放在 GPU 上,则执行引擎必须具有该操作的 GPU 实现,称为内核。
如果内核不存在,则放置会导致运行时错误。此外,如果请求的 GPU 设备不存在,则会引发运行时错误。
如果请求 GPU 设备导致错误,最好的处理方法是允许将操作放在 CPU 上。

一个答案是删除所有 GPU 配置,第二个答案是软放置,如果没有找到 GPU,请使用 config.allow_soft_placement = True