【发布时间】:2019-02-28 20:56:36
【问题描述】:
我对此很陌生,如果我的术语不完美,请道歉,但我已经做了很多尝试和搜索,但我无法通过这个问题。
我一直在尝试创建 Deep Dream 风格的传输图像,以便将它们批量处理为视频。
我尝试了一大堆不同的东西、指南和版本,我无法在 python 3.6.6 或更高版本上安装 tensorflow。 但遵循本指南:
(https://www.reddit.com/r/deepdream/comments/6z5tyz/guide_on_how_to_setup_neural_style_transfer_on/)
我终于让它工作了,但只是作为张量流 CPU。这很棒,但速度很慢。我有一个 GTX 1080,我想充分利用它。
当我安装 Tensorflow-gpu 时,它说它工作正常
C:\Users\kurti>pip3 install --upgrade tensorflow-gpu
Collecting tensorflow-gpu
Using cached https://files.pythonhosted.org/packages/01/ac/ed64953d36b6516dc4a4ae983d7759bdcdaedd65541ee92a116909a524a8/tensorflow_gpu-1.13.1-cp35-cp35m-win_amd64.whl
Requirement already up-to-date: gast>=0.2.0 in c:\users\kurti\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-gpu)
Requirement already up-to-date: keras-applications>=1.0.6 in c:\users\kurti\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-gpu)
Requirement already up-to-date: keras-preprocessing>=1.0.5 in c:\users\kurti\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-gpu)
Requirement already up-to-date: absl-py>=0.1.6 in c:\users\kurti\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-gpu)
Requirement already up-to-date: protobuf>=3.6.1 in c:\users\kurti\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-gpu)
Requirement already up-to-date: termcolor>=1.1.0 in c:\users\kurti\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-gpu)
Requirement already up-to-date: wheel>=0.26 in c:\users\kurti\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-gpu)
Requirement already up-to-date: astor>=0.6.0 in c:\users\kurti\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-gpu)
Requirement already up-to-date: tensorflow-estimator<1.14.0rc0,>=1.13.0 in c:\users\kurti\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-gpu)
Requirement already up-to-date: numpy>=1.13.3 in c:\users\kurti\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-gpu)
Requirement already up-to-date: six>=1.10.0 in c:\users\kurti\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-gpu)
Requirement already up-to-date: grpcio>=1.8.6 in c:\users\kurti\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-gpu)
Requirement already up-to-date: tensorboard<1.14.0,>=1.13.0 in c:\users\kurti\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-gpu)
Requirement already up-to-date: h5py in c:\users\kurti\appdata\local\programs\python\python35\lib\site-packages (from keras-applications>=1.0.6->tensorflow-gpu)
Requirement already up-to-date: setuptools in c:\users\kurti\appdata\local\programs\python\python35\lib\site-packages (from protobuf>=3.6.1->tensorflow-gpu)
Requirement already up-to-date: mock>=2.0.0 in c:\users\kurti\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-estimator<1.14.0rc0,>=1.13.0->tensorflow-gpu)
Requirement already up-to-date: werkzeug>=0.11.15 in c:\users\kurti\appdata\local\programs\python\python35\lib\site-packages (from tensorboard<1.14.0,>=1.13.0->tensorflow-gpu)
Requirement already up-to-date: markdown>=2.6.8 in c:\users\kurti\appdata\local\programs\python\python35\lib\site-packages (from tensorboard<1.14.0,>=1.13.0->tensorflow-gpu)
Requirement already up-to-date: pbr>=0.11 in c:\users\kurti\appdata\local\programs\python\python35\lib\site-packages (from mock>=2.0.0->tensorflow-estimator<1.14.0rc0,>=1.13.0->tensorflow-gpu)
Installing collected packages: tensorflow-gpu
Successfully installed tensorflow-gpu-1.13.1
但是当我通过导入 GPU 版本进行测试时,我得到了这个:
C:\Users\kurti>python
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "C:\Users\kurti\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\kurti\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\kurti\AppData\Local\Programs\Python\Python35\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:\Users\kurti\AppData\Local\Programs\Python\Python35\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\kurti\AppData\Local\Programs\Python\Python35\lib\imp.py", line 342, 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:\Users\kurti\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\kurti\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\kurti\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\kurti\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\kurti\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\kurti\AppData\Local\Programs\Python\Python35\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:\Users\kurti\AppData\Local\Programs\Python\Python35\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\kurti\AppData\Local\Programs\Python\Python35\lib\imp.py", line 342, 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.
CPU 工作的事实表明它与 CUDA、cuDNN 或 Tensor flow GPU 的版本有关,但我已经尝试过
Cuda 8(update2) + CuDNN 6
Cuda 8(update2) + CuDNN 5.1
Cuda 7.5 + cuDNN 5.1
之前还有一大堆较新的。 我相信我已经安装了所有正确的依赖项。
我已经检查了 PATH,就像这里有类似问题的其他人所建议的那样,看起来一切都很好,所以我不知道从这里去哪里?
我有这个用于 CPU 的工作,但我需要能够为视频做数百个这样的工作,所以非常感谢任何帮助。
更新:我发现这个不错的自检小脚本适用于 1.4 之前的版本 link
这表示它找不到我安装的 cuDNN v6,然后测试,仍然是同样的错误。再次运行自检,得到了这个结果
C:\Users\kurti\Documents\Projects SSD\TESTS\Deep Dream>tensorflow_self_check.py
ERROR: Failed to import the TensorFlow module.
WARNING! This script is no longer maintained!
=============================================
Since TensorFlow 1.4, the self-check has been integrated with TensorFlow itself,
and any missing DLLs will be reported when you execute the `import tensorflow`
statement. The error messages printed below refer to TensorFlow 1.3 and earlier,
and are inaccurate for later versions of TensorFlow.
- Python version is 3.5.
- TensorFlow is installed at: C:\Users\kurti\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow
- All required DLLs appear to be present. Please open an issue on the
TensorFlow GitHub page: https://github.com/tensorflow/tensorflow/issues
更新 2:
经过更多研究,建议使用 Anaconda,因为这在 Windows 中显然不太容易出现上述问题。 这些是我正在采取的步骤
- conda create -n [名称] python=3.5
- 激活[名称]
- conda 安装 tensorflow-gpu
- pip3 安装 (numpy-1.16.2+mkl-cp35-cp35m-win_amd64.whl)
- pip3 安装 (opencv_python-3.4.5-cp35-cp35m-win_amd64.whl)
- pip3 安装 (scipy-1.2.1-cp35-cp35m-win_amd64.whl)
当我键入时,这不会给我任何错误
python
>>>import tensorflow
>>>import numpy
但是当我尝试运行脚本(适用于 cpu 版本)时,它再也找不到 numpy
(tf2) C:\Users\kurti\GitProjects\DeepStyle\Deep Style\neural-style-tf-master>neural_style.py --content_img littleme.jpg --style_imgs starry-night.jpg --max_iterations 100 --verbose
Traceback (most recent call last):
File "C:\Users\kurti\GitProjects\DeepStyle\Deep Style\neural-style-tf-master\neural_style.py", line 1, in <module>
import tensorflow as tf
File "C:\Users\kurti\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\kurti\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 47, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
运行 pip3 列表显示 numpy, 运行 pip list 显示 numpy, 运行 conda list 显示错误的 numpy,
我相信为所需的 .whl 运行 pip3 安装不会将它们安装到我的 conda 环境中,这是否正确,我该如何解决?
【问题讨论】:
标签: python python-3.x tensorflow deep-learning