logo
Loading...

tensorflow 運行失敗,該如何解決 - Cupoy

我在運行 part1 程式時,會import tensorflow 時出現以下問題,該如何解決---...

tensorflow,part1

tensorflow 運行失敗,該如何解決

2020/09/22 下午 09:56
《用 Python 打造你的 AI 股票交易引擎》業界專家實戰教學
許明記
觀看數:43
回答數:1
收藏數:0
tensorflow
part1

我在運行 part1 程式時,會import tensorflow 時出現以下問題,該如何解決



--------------------------------------------------------------------------- ImportError                               Traceback (most recent call last) E:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>      63 try: ---> 64 from tensorflow.python._pywrap_tensorflow_internal import *      65 # This try catch logic is because there is no bazel equivalent for py_extension. ImportError: DLL load failed with error code 3221225501 while importing _pywrap_tensorflow_internal  During handling of the above exception, another exception occurred:  ImportError                               Traceback (most recent call last) <ipython-input-1-2554c9a1553e> in <module> ----> 1 import cstock as cs       2 import talib  ~\stock_market\CH4_CStock_v1_0_5\cstock.py in <module>      30 from keras.metrics import mae      31 ''' ---> 32 from tensorflow import keras      33 from tensorflow.keras.preprocessing.sequence import pad_sequences      34 from tensorflow.keras.models import Model, load_model  E:\Anaconda3\lib\site-packages\tensorflow\__init__.py in <module>      39 import sys as _sys      40 ---> 41 from tensorflow.python.tools import module_util as _module_util      42 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader      43 E:\Anaconda3\lib\site-packages\tensorflow\python\__init__.py in <module>      38 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top      39 ---> 40 from tensorflow.python.eager import context      41      42 # pylint: enable=wildcard-import E:\Anaconda3\lib\site-packages\tensorflow\python\eager\context.py in <module>      33 from tensorflow.core.protobuf import config_pb2      34 from tensorflow.core.protobuf import rewriter_config_pb2 ---> 35 from tensorflow.python import pywrap_tfe      36 from tensorflow.python import tf2      37 from tensorflow.python.client import pywrap_tf_session  E:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tfe.py in <module>      26      27 # pylint: disable=invalid-import-order,g-bad-import-order, wildcard-import, unused-import ---> 28 from tensorflow.python import pywrap_tensorflow      29 from tensorflow.python._pywrap_tfe import * E:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>      81 for some common reasons and solutions.  Include the entire stack trace      82 above this error message when asking for help.""" % traceback.format_exc() ---> 83 raise ImportError(msg)      84      85 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long ImportError: Traceback (most recent call last):   File "E:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>     from tensorflow.python._pywrap_tensorflow_internal import * ImportError: DLL load failed with error code 3221225501 while importing _pywrap_tensorflow_internal   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.  

回答列表

  • 2020/09/23 下午 07:13
    陳明佑 (Ming You Chen)
    贊同數:0
    不贊同數:0
    留言數:1

    同學您好

    這個問題主要是因為您的CPU不支援avx指令集, 導致執行tensorflow失敗

    (因為tensorflow主要是針對GPU的環境設計, 所以有部分CPU會出現這種問題)

    建議的做法, 是改用Colab版本執行(請參考課程第0章第5節的Colab版本教學)


    回答來源參考資料

    https://github.com/tensorflow/tensorflow/issues/35598