美文网首页我爱编程
TensorFlow安装小记

TensorFlow安装小记

作者: wangke | 来源:发表于2018-05-11 17:30 被阅读312次

    记一次安装TensorFlow的问题


    刚刚解决了一个pycharm的问题, 突然又想起了服务器上的TensorFlow了

    之前使用过keras, 后台是用的TensorFlow, 能正常跑keras程序. 忘记了什么原因把TensorFlow卸载了一次, 然后就装不上了...

    先说一下电脑的配置, 特别之处就是系统为windows server 2008

    尝试了多个版本, 多种安装方式, 能够安装, 但是运行时报错

    # running
    import tensorflow as tf
    print(tf.__version__)
    

    提示的错误

    "D:\Program Files\Anaconda3\python.exe" C:/Users/wk/PycharmProjects/tf_test/__test/tf_version.py
    Traceback (most recent call last):
      File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 14, in swig_import_helper
        return importlib.import_module(mname)
      File "D:\Program Files\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 986, in _gcd_import
      File "<frozen importlib._bootstrap>", line 969, in _find_and_load
      File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
      File "<frozen importlib._bootstrap>", line 577, in module_from_spec
      File "<frozen importlib._bootstrap_external>", line 906, in create_module
      File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
    ImportError: DLL load failed with error code -1073741795
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
        from tensorflow.python.pywrap_tensorflow_internal import *
      File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in <module>
        _pywrap_tensorflow_internal = swig_import_helper()
      File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 16, in swig_import_helper
        return importlib.import_module('_pywrap_tensorflow_internal')
      File "D:\Program Files\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
    ImportError: No module named '_pywrap_tensorflow_internal'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "C:/Users/wk/PycharmProjects/tf_test/__test/tf_version.py", line 1, in <module>
        import tensorflow as tf
      File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
        from tensorflow.python import *  # pylint: disable=redefined-builtin
      File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
        from tensorflow.python import pywrap_tensorflow
      File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
        raise ImportError(msg)
    ImportError: Traceback (most recent call last):
      File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 14, in swig_import_helper
        return importlib.import_module(mname)
      File "D:\Program Files\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 986, in _gcd_import
      File "<frozen importlib._bootstrap>", line 969, in _find_and_load
      File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
      File "<frozen importlib._bootstrap>", line 577, in module_from_spec
      File "<frozen importlib._bootstrap_external>", line 906, in create_module
      File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
    ImportError: DLL load failed with error code -1073741795
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
        from tensorflow.python.pywrap_tensorflow_internal import *
      File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in <module>
        _pywrap_tensorflow_internal = swig_import_helper()
      File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 16, in swig_import_helper
        return importlib.import_module('_pywrap_tensorflow_internal')
      File "D:\Program Files\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
    ImportError: No module named '_pywrap_tensorflow_internal'
    
    
    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.
    
    Process finished with exit code 1
    

    提示ImportError: DLL load failed, 很有可能就是编译出了问题

    在网上查找了一些资料

    其中有一个是ImportError: No module named '_pywrap_tensorflow_internal'

    但是windows server 2008 死活安装不上 msvc 2015

    但是TensorFlow必须要msvc 2015进行编译呀1

    不对, 我之前也没有安装上MSVC 2015呀, 在安装LightGBM的时候都没有装上. 那我之前又是怎么装上TensorFlow的? 时间推移, 找历史版本...

    把时间线推到之前安装的时间, 试了多个历史版本, 包括已经编译好了的版本, 还是没有装上...

    今天又试着去找了历史版本, 突然今天看到有编译好的tensorflow_gpu-1.4.0-cp35-cp35m-win_amd64.whl, 然后找到了cpu的版本

    https://pypi.org/project/tensorflow/1.4.1/#files

    没有windows的版本, 神奇的是1.2中有windows的版本

    安装, 就这么能用了...

    感谢多次失败都没放弃的自己:)

    最新版本中, 也找到了windows上编译好的包

    不过安装TensorFlow1.8还是出现了之前的问题, 最后安装的TensorFlow1.5.

    总结, 如果你电脑编译不上的话, 就到这个网站下载已经编译好的TensorFlow吧

    https://pypi.org/project/tensorflow/#files

    相关文章

      网友评论

        本文标题:TensorFlow安装小记

        本文链接:https://www.haomeiwen.com/subject/xwxqdftx.html