简体   繁体   中英

Windows 10 Tensorflow (Anaconda) GPU not working

I am having a lot of trouble installing tensorflow-gpu on my machine. Tensorflow 1.3 works perfectly but when I try using tensorflow-gpu I end up with this error:

ImportError: Traceback (most recent call last):
  File "C:\Users\Freddie\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Users\Freddie\Anaconda3\envs\tensorflow\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 985, in _gcd_import
  File "<frozen importlib._bootstrap>", line 968, in _find_and_load
  File "<frozen importlib._bootstrap>", line 957, 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 938, 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\Freddie\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\Freddie\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\Freddie\Anaconda3\envs\tensorflow\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\Freddie\Anaconda3\envs\tensorflow\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.

I have checked that CUDA 8.0 installed, with the "self check" script (I also installed cudNN6.0 for CUDA 8). Output of this script:

ERROR: Failed to import the TensorFlow module.

- Python version is 3.5.

- TensorFlow is installed at: C:\Users\Freddie\Anaconda3\envs\tensorflow\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
An exception has occurred, use %tb to see the full traceback.

Nothing seems to be working here.

I found the correct answer to this. The problem was that I was running the code but the PATH variable under anaconda did not include the CUDA 8 bin directory.

To fix this I created an environment variable called CUDA_8_HOME, set to the path of the bin dir and then added this to the top of my script:

import os
os.environ["PATH"] = os.environ["PATH"] + os.environ["CUDA_8_HOME"]

from keras import backend as K
import tensorflow as tf
<... Script Continues ...>

Turns out it also works to add the CUDA home ( bin directory) to PATH using the windows dialogue (search for environment variables in the start menu)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM