Ich versuche Tensorflow in meinem PC zu installieren. Ich habe Python 3.5.2 64-Bit, cuda_8.0.61 für Windows 10 und Cudnn-8.0-Windows10-x64-v6.0 installiert
Ich habe "native" pip verwendet, um die GPU-Version von Tensorflow zu installieren, dann öffne ich IDLE und teste mit "import tensorflow as tf", und ich habe den folgenden Fehler erhalten
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\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: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\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 "<pyshell#0>", line 1, in <module>
import tensorflow as tf
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\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: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\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.
Nach diesen Schritten konnte ich Tensorflow unter Windows ausführen. Ich hoffe es hilft! Je nachdem, in welchem Ordner Sie Python installiert haben, kann sich dies ändern.
Kopieren Sie die CuDNN-Dateien in den Nvidia CUDA-Toolkit-Ordner, wenn 2. abgeschlossen ist (normalerweise unter C:\Programme\NVIDIA GPU Computing Toolkit\CUDA\v8.0).
Installieren Sie Tensorflow über den Pip-Befehl Prompt 'Pip install --upgrade tensorflow-gpu'
5.1 TensorFlow-Abhängigkeiten
Versuchen:
pip install https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-0.12.0rc0-cp35-cp35m-win_AMD64.whl
tensorflow anstelle von:
pip install --upgrade tensorflow-gpu
Mein Computer ist Windows mit CPU und ich hatte die gleichen Probleme. Ich deinstalliere tensorflow 1.9 und installiere stattdessen 1.5. Es funktioniert jetzt.
Warum nicht Anaconda probieren?
conda create -n gpu_env tensorflow-gpu
conda activate gpu_env
So einfach ist das. Alle benötigten Pakete und Runtime (einschließlich Visual Studio) werden zusammengebracht, während Sie in Ehrfurcht schauen :). Probieren Sie es aus!
Einschränkung: Sie müssen Keras von Tensorflow aus ausführen damit Keras Ihre GPU erkennt und verwendet. Andernfalls, wenn Sie nur Keras und Tensorflow als Backend verwenden, Keras verwendet normalen Tensorflow und nicht Tensorflow-gp. Beide werden nebeneinander installiert.
Das heißt, Sie sollten es so codieren:
import tensorflow as tf
from tensorflow.keras.models import Sequential, load_model
from tensorflow.keras.layers import Dense,Dropout
from tensorflow.keras.callbacks import ModelCheckpoint, EarlyStopping,CSVLogger
from tensorflow.keras.utils import plot_model
.............
.............
Ich hoffe das hilft.
Ich habe das gleiche Problem mit dir. Das Problem ist, dass Anaconda die Version python= bei der Installation von ipython und spyder automatisch aktualisiert. Diese wird zu Version 3.6. Sie können die Version python= auf Version 3.5 ändern, indem Sie eingeben die Tensorflow-Umgebung über Anaconda. Bildbeschreibung hier eingeben
Wenn das Problem weiterhin besteht, überprüfen Sie die Versionsnummerierung und stellen Sie sicher, dass cuda und TF kompatibel sind.
Überprüfe die Versionsnummerierung hier
oder für einen simpler Weg, verwenden Sie Anaconda
conda create --name new_env_name tensorflow-gpu
activate new_env_name
Ich habe TensorFlow GPU Version 1.12 (spätestens bis zum Datum des Schreibens) mit Cuda 9.0, GeForce 1050 Ti, Windows 10 und Python 3.6.7 erfolgreich installiert.
Hinweis: Sie haben das CUDA Toolkit (Version 9) für TensorFlow installiert, um Ihre GPU zu erkennen
Alles kann von der Konsole aus installiert werden: conda create --name tf-gpu conda install -c aaronzs tensorflow-gpu conda install -c anaconda cudatoolkit conda install -c anaconda cudnn conda install keras-gpu
Das Problem für mich war mit einem Paket namens protobuf. Es wurde mit pip install https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-0.12.0rc0-cp35-cp35m-win_AMD64.whl
Behoben, das protobuf auf 3.6.1 aufrüstete und den Fehler behebte.