[英]Tensorflow won't import using Anaconda
I am trying to get Gpt-2 to work on Win10 intel i7 950 and have set up an env in Anaconda (Python 3.5, Tensorflow 1.12) but I am not even getting past the import of tensor flow.我试图让 Gpt-2 在 Win10 intel i7 950 上工作,并在 Anaconda(Python 3.5,Tensorflow 1.12)中设置了一个环境,但我什至没有通过张量流的导入。 I have read several questions regarding similar problems but none of the fixes/workarounds have worked for me.我已经阅读了几个关于类似问题的问题,但没有一个修复/解决方法对我有用。
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.
Here is my Anaconda env:这是我的 Anaconda 环境:
# 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
I have tried up/down-grading packages but from my understanding, Gpt-2 will not work with higher versions of Python and TensorFlow.我已经尝试过升级/降级软件包,但据我了解,Gpt-2 不适用于更高版本的 Python 和 TensorFlow。
*edit I tried the "conda create --name tf_gpu tensorflow-gpu" which installs a full tensorflow environment, I also tried downgrading to tensorflow 1.5, both work but none of them works with gpt-2 *编辑我尝试了“conda create --name tf_gpu tensorflow-gpu”,它安装了一个完整的 tensorflow 环境,我还尝试降级到 tensorflow 1.5,两者都可以,但它们都不能与 gpt-2 一起使用
*edit 2 I looked at the code that generates the error message and it is not a dll that is being loaded despite what the message says. *edit 2 我查看了生成错误消息的代码,尽管消息显示,但它不是正在加载的 dll。 It is a.pyd file: "\lib\site-packages\tensorflow\python\_pywrap_tensorflow_internal.pyd"它是一个 .pyd 文件:“\lib\site-packages\tensorflow\python\_pywrap_tensorflow_internal.pyd”
Even if you do a pip install, sometimes this DLL error may appear while trying to import tensorflow.即使您执行 pip 安装,有时在尝试导入 tensorflow 时可能会出现此 DLL 错误。 Go to https://www.tensorflow.org/install/pip then click on Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019 as given in screenshot. Go to https://www.tensorflow.org/install/pip then click on Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019 as given in screenshot.
Now download and install the required executable 64 bit or 32 bit.现在下载并安装所需的 64 位或 32 位可执行文件。 This resolved my issue.这解决了我的问题。 Please try this.请试试这个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.