代码之家  ›  专栏  ›  技术社区  ›  Tae-Sung Shin

如何设置虚拟环境以运行tensorflow基准测试

  •  0
  • Tae-Sung Shin  · 技术社区  · 6 年前

    tensorflow benchmark 但在运行下面的代码后,我在最后一个语句中得到一个错误。请问我应该如何解决这个问题?仅供参考:我使用的是Python 3.6.7,仅安装了pip和virtualenv软件包以及CUDA 9.2/cuDNN7(系统路径中的所有DLL)。

    virtualenv venv
    venv\scripts\activate
    #now you should be in virtual environment
    #install using pip
    pip install tf-nightly-gpu
    
    python
    import tensorflow
    

    错误消息:

    >>> import tensorflow
    Traceback (most recent call last):
      File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
        from tensorflow.python.pywrap_tensorflow_internal import *
      File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
        _pywrap_tensorflow_internal = swig_import_helper()
      File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
        _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
      File "C:\MyWork\testarea\testvirtualenv\venv\lib\imp.py", line 243, in load_module
        return load_dynamic(name, filename, file)
      File "C:\MyWork\testarea\testvirtualenv\venv\lib\imp.py", line 343, in load_dynamic
        return _load(spec)
    ImportError: DLL load failed: The specified module could not be found.
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
        from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
      File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
        from tensorflow.python import pywrap_tensorflow
      File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
        raise ImportError(msg)
    ImportError: Traceback (most recent call last):
      File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
        from tensorflow.python.pywrap_tensorflow_internal import *
      File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
        _pywrap_tensorflow_internal = swig_import_helper()
      File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
        _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
      File "C:\MyWork\testarea\testvirtualenv\venv\lib\imp.py", line 243, in load_module
        return load_dynamic(name, filename, file)
      File "C:\MyWork\testarea\testvirtualenv\venv\lib\imp.py", line 343, in load_dynamic
        return _load(spec)
    ImportError: DLL load failed: The specified module could not be found.
    
    
    Failed to load the native TensorFlow runtime.
    
    See https://www.tensorflow.org/install/errors
    
    for some common reasons and solutions.  Include the entire stack trace
    above this error message when asking for help.
    >
    
    1 回复  |  直到 6 年前
        1
  •  1
  •   Tae-Sung Shin    6 年前

    在写下问题后找到了答案。

    在将cudnn64_7.dll(cuDNN 7.3.1适用于CUDA 9.0)复制到CUDA bin目录之前,将CUDA 9.2降级到9.0使其正常工作。

    virtualenv venv
    venv\scripts\activate
    pip install tf-nightly-gpu    
    python tf_cnn_benchmarks.py --num_gpus=1 --batch_size=32 --model=resnet50 --variable_update=parameter_server
    

    每秒总图像数:78.16

    每秒总图像数:147.77