python : cannot import tensorflow-gpu

python : cannot import tensorflow-gpu … here is a solution to the problem.

python : cannot import tensorflow-gpu

I successfully created my tensorflow environment on my machine using Anaconda3 by following the steps described in this link. But when I try to do :

>>> import tensorflow as tf

I get the following error messages: OSError and ImportError.

Traceback (most recent call last):
  File "C:\Users\Froilan\Anaconda3\envs\tensorflow\lib\site-
packages\tensorflow\python\platform\self_check.py", line 75, in preload_check
ctypes. WinDLL(build_info.cudart_dll_name)
  File "C:\Users\Froilan\Anaconda3\envs\tensorflow\lib\ctypes\__init__.py", line 351, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] This 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\Froilan\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
  File "C:\Users\Froilan\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
  File "C:\Users\Froilan\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 30, in <module>
self_check.preload_check()
  File "C:\Users\Froilan\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\platform\self_check.py", line 82, in preload_check
% (build_info.cudart_dll_name, build_info.cuda_version_number))
ImportError: Could not find 'cudart64_80.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 8.0 from this URL: https://developer.nvidia.com/cuda-toolkit

Could it be an issue with my CPU? I use a Ryzen 1700.
+ GPU: GTX 1050 Ti – a little worse than 1080 ti: But I’ve heard that GPUs are still much better than CPUs.

Solution

You need to install the CUDA library first, I recommend you follow this link:

https://gist.github.com/mjdietzx/0ff77af5ae60622ce6ed8c4d9b419f45

Update:
For Windows operating systems, follow these methods:

http://blog.nitishmutha.com/tensorflow/2017/01/22/TensorFlow-with-gpu-for-windows.html

Related Problems and Solutions