简体   繁体   中英

Tensorflow 1.9 for CPU, without GPU still requires cudNN - Windows

I am working on a Win10 machine, with python 3.6.3 and using tensorflow 1.9, pip 18.0. I did not provide an option to install tensorflow with gpu, (ie), according to this link1 , I used

    pip install tensorflow

and did not provide option for using GPU. However, when trying to import tensorflow, I am faced with the following error

    ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'

After following various links, link2 , link3 , I installed the Visual studio update 3 and also used the script provided tensorflow self check , and came across this following error:

    Could not load 'cudart64_80.dll'. .....
    Could not load 'nvcuda.dll' .......
    Could not load 'cudnn64_5.dll' ........

Why is my Tensorflow looking for these packages, when I installed it without GPU? MY system doesn't house a GPU at the moment. I tried uninstall and reinstalling with the upgraded pip 18.0 , but the issue persists. How can this be rectified.?

The self-check script from that link is labeled as "DEPRECATED" so it may not work for the latest version (at least not for TensorFlow 1.9 with GPU since that would require cudart64_90.dll instead of cudart64_80.dll). Also, the script simply checks all possible missing files which could be needed by either the CPU or the GPU version. The detailed message tells you which files are only needed by the GPU version.

You may first double-check the GPU version is not installed, if you are not sure about it, by executing pip show tensorflow-gpu . There should be nothing showing up if you have only installed the CPU version.

I encountered a problem yesterday while upgrading the GPU version from 1.8 to 1.9. The problem might not be exactly the same as yours but could be related since my problem was also caused by a failed _pywrap_tensorflow_internal import due to a DLL loading failure. If your problem is also caused by a DLL loading failure , which is explicitly mentioned in the stack trace message, you could consider using this approach to pinpoint the problem:

  1. Use the DLL dependency analyzer Dependencies to analyze <Your Python Dir>\\Lib\\site-packages\\tensorflow\\python\\_pywrap_tensorflow_internal.pyd and determine the exact missing DLL (indicated by a ? beside the DLL).

  2. Look for information of the missing DLL and install the appropriate package to resolve the problem.

In my case the missing library is VCOMP140.dll , which is Microsoft's OpenMP library and was not needed by the 1.8 version. I installed VC++ Redistributable for VS 2017 and the problem is resolved.

Status 2020-07-12: tensorflow-gpu is integrated into the regular installation - which causes problems as also in your case. This is true since version 2.0.0 - see here on github .

A huge list of different wheels/compatibilities can be found here on github . By using this, you can downgrade to almost every availale version in combination with the respective for python. For example:

pip install tensorflow==2.0.0

(What you have to pay attention about is that you cannot install arbitrary versions of tensorflow, they have to correspond to your python installation. So previous to installing Python 3.7.8 alongside 3.8.3 (or analogously for your case), you would get

ERROR: Could not find a version that satisfies the requirement tensorflow==2.0.0 (from versions: 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0, 2.3.0rc0, 2.3.0rc1)
ERROR: No matching distribution found for tensorflow==2.0.0

)

Besides your usecase without a GPU, this should also be useful for legacy CPU without AVX support and GPUs with a compute capability that's too low.


If you only need the most recent releases (which it doesn't sound like in your question) a list of urls for the current wheel packages is available on this tensorflow page . That's from this SO-answer .

Note: This link to a list of different versions didn't work for me.

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