Tensorflow不会使用Anaconda导入

2024-09-27 21:34:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图让Gpt-2在Win10 intel i7 950上工作,并在Anaconda(Python 3.5,Tensorflow 1.12)中设置了一个env,但我甚至没有通过tensor flow的导入。我读过一些关于类似问题的问题,但没有一个修复/解决方法对我有效

import tensorflow as tf

Traceback (most recent call last):
  File "D:\anaconda3\envs\gpt-2\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "D:\anaconda3\envs\gpt-2\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "D:\anaconda3\envs\gpt-2\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 "D:\anaconda3\envs\gpt-2\lib\imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "D:\anaconda3\envs\gpt-2\lib\imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\anaconda3\envs\gpt-2\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "D:\anaconda3\envs\gpt-2\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "D:\anaconda3\envs\gpt-2\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "D:\anaconda3\envs\gpt-2\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "D:\anaconda3\envs\gpt-2\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "D:\anaconda3\envs\gpt-2\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 "D:\anaconda3\envs\gpt-2\lib\imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "D:\anaconda3\envs\gpt-2\lib\imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.

这是我的Python环境:

# packages in environment at D:\anaconda3\envs\gpt-2:
#
# Name                    Version                   Build  Channel
absl-py                   0.9.0                    pypi_0    pypi
astor                     0.8.1                    pypi_0    pypi
certifi                   2018.8.24                py35_1
chardet                   3.0.4                    pypi_0    pypi
fire                      0.3.1                    pypi_0    pypi
gast                      0.3.3                    pypi_0    pypi
grpcio                    1.30.0                   pypi_0    pypi
h5py                      2.10.0                   pypi_0    pypi
idna                      2.8                      pypi_0    pypi
importlib-metadata        1.7.0                    pypi_0    pypi
keras-applications        1.0.8                    pypi_0    pypi
keras-preprocessing       1.1.2                    pypi_0    pypi
markdown                  3.2.2                    pypi_0    pypi
numpy                     1.18.5                   pypi_0    pypi
pip                       20.1.1                   pypi_0    pypi
protobuf                  3.12.2                   pypi_0    pypi
python                    3.5.6                he025d50_0
regex                     2017.04.05               pypi_0    pypi
requests                  2.21.0                   pypi_0    pypi
setuptools                40.2.0                   py35_0
six                       1.10.0           py35h06cf344_1
tensorboard               1.12.2                   pypi_0    pypi
tensorflow                1.12.0                   pypi_0    pypi
termcolor                 1.1.0                    pypi_0    pypi
tqdm                      4.31.1                   pypi_0    pypi
urllib3                   1.24.3                   pypi_0    pypi
vc                        14.1                 h0510ff6_4
vs2015_runtime            14.16.27012          hf0eaf9b_3
werkzeug                  1.0.1                      py_0
wheel                     0.31.1                   py35_0
wincertstore              0.2              py35hfebbdb8_0
zipp                      1.2.0                    pypi_0    pypi

我尝试过升级/降级软件包,但据我所知,Gpt-2无法与更高版本的Python和TensorFlow一起使用

*编辑 我尝试了“conda create--name tfgpu tensorflow gpu”,它安装了一个完整的tensorflow环境,我还尝试了降级到tensorflow 1.5,两者都可以工作,但没有一个可以与gpt-2一起工作

*编辑2 我查看了生成错误消息的代码,不管消息怎么说,都没有加载dll。它是一个.pyd文件:“\lib\site packages\tensorflow\python\\u pywrap\u tensorflow\u internal.pyd”


Tags: inpypypilibpackagestensorflowlineload
1条回答
网友
1楼 · 发布于 2024-09-27 21:34:20

即使您进行了pip安装,有时在尝试导入tensorflow时也会出现此DLL错误。转到https://www.tensorflow.org/install/pip,然后点击微软Visual C++ +可重新分配的Visual Studio 2015, 2017和2019,如截图中所给出的。 enter image description here

现在下载并安装所需的64位或32位可执行文件。这解决了我的问题。请试试这个

相关问题 更多 >

    热门问题