tensorflow遇到的一些问题和解决方案的整理【tensorflow1.14.0gpu+h5py2.8.0+numpy1.16.6】+软件和包的重装

特别注意:tensorflow1.14.0gpu+h5py2.8.0+numpy1.16.6

很多时候,我们遇到的问题都是由于某些包的版本和tensorflow不兼容导致的,所以需要把版本降下来,很少见需要升版本的。

其中h5py和numpy的版本最容易出问题。

除此以外,在重新安装包的时候,尽量在自己创建的环境里安装,否则一切都会出各种奇怪的问题。

1.0 问题描述

Traceback (most recent call last):
  File "D:\Program\Anaconda3\envs\cat\lib\site-packages\tensorflow\python\platform\self_check.py", line 75, in 
preload_check
    ctypes.WinDLL(build_info.cudart_dll_name)
  File "D:\Program\Anaconda3\envs\cat\lib\ctypes\__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] 找不到指定的模块。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "e:\matlab\CNN-classification\LSTM\test_one_review.py", line 50, in
    import tensorflow as tf 
  File "D:\Program\Anaconda3\envs\cat\lib\site-packages\tensorflow\__init__.py", line 28, in
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "D:\Program\Anaconda3\envs\cat\lib\site-packages\tensorflow\python\__init__.py", line 49, in   
    from tensorflow.python import pywrap_tensorflow
  File "D:\Program\Anaconda3\envs\cat\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 30, in
    self_check.preload_check()
  File "D:\Program\Anaconda3\envs\cat\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_100.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 10.0 from this URL: https://developer.nvidia.com/cuda-90-download-archive

tensorflow遇到的一些问题和解决方案的整理【tensorflow1.14.0gpu+h5py2.8.0+numpy1.16.6】+软件和包的重装_第1张图片

tensorflow遇到的一些问题和解决方案的整理【tensorflow1.14.0gpu+h5py2.8.0+numpy1.16.6】+软件和包的重装_第2张图片

1.1 解决方案

重装合适版本的CUDA+cuDNN

https://blog.csdn.net/a1456123a/article/details/115468769

*********************************************************************************************************

2.0 问题描述

D:\Program\Anaconda3\envs\tensorflow\lib\site-packages\numpy\__init__.py:138: UserWarning: mkl-service package 
failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
  from . import _distributor_init
Traceback (most recent call last):
  File "D:\Program\Anaconda3\envs\tensorflow\lib\site-packages\numpy\core\__init__.py", line 22, in
    from . import multiarray
  File "D:\Program\Anaconda3\envs\tensorflow\lib\site-packages\numpy\core\multiarray.py", line 12, in
    from . import overrides
  File "D:\Program\Anaconda3\envs\tensorflow\lib\site-packages\numpy\core\overrides.py", line 7, in
    from numpy.core._multiarray_umath import (
ImportError: DLL load failed: 找不到指定的模块。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "e:\matlab\CNN-classification\LSTM\test_one_review.py", line 2, in
    import numpy as np
  File "D:\Program\Anaconda3\envs\tensorflow\lib\site-packages\numpy\__init__.py", line 140, in       
    from . import core
  File "D:\Program\Anaconda3\envs\tensorflow\lib\site-packages\numpy\core\__init__.py", line 48, in   
    raise ImportError(msg)
ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.7 from "D:\Program\Anaconda3\envs\tensorflow\python.exe"
  * The NumPy version is: "1.19.2"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

2.1 解决方案

重装版本合适的numpy

可参考https://blog.csdn.net/a1456123a/article/details/115375952

*********************************************************************************************************

3.0 问题描述

Original error was: DLL load failed: 找不到指定的模块。

PS E:\matlab\CNN-classification> D:/Program/Anaconda3/Scripts/activate
PS E:\matlab\CNN-classification> conda activate tensorflow

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If your shell is Bash or a Bourne variant, enable conda for the current user with

    $ echo ". D:\Program\Anaconda3/etc/profile.d/conda.sh" >> ~/.bashrc

or, for all users, enable conda with

    $ sudo ln -s D:\Program\Anaconda3/etc/profile.d/conda.sh /etc/profile.d/conda.sh

The options above will permanently enable the 'conda' command, but they do NOT
put conda's base (root) environment on PATH.  To do so, run

    $ conda activate

in your terminal, or to put the base environment on PATH permanently, run

    $ echo "conda activate" >> ~/.bashrc

Previous to conda 4.4, the recommended way to activate conda was to modify PATH in
your ~/.bashrc file.  You should manually remove the line that looks like

    export PATH="D:\Program\Anaconda3/bin:$PATH"

^^^ The above line should NO LONGER be in your ~/.bashrc file! ^^^

3.1 解决方案

重装conda

conda update conda

可参考https://blog.csdn.net/a1456123a/article/details/115328537

*********************************************************************************************************

4.0 问题描述

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tensorflow 1.14.0 requires google-pasta>=0.1.6, which is not installed.

4.1 解决方案

重装pip install google-pasta>=0.1.7之后,本错误消失,但是整体问题仍旧没有解决。

tensorflow遇到的一些问题和解决方案的整理【tensorflow1.14.0gpu+h5py2.8.0+numpy1.16.6】+软件和包的重装_第3张图片

*********************************************************************************************************

5.0 问题描述

重命名自己的创建的tensorflow环境

给自己创建的环境改名字:将原来为cat的tensorflow环境改名为tensorflow。

5.1 解决方案

conda create -n tensorflow --clone cat

tensorflow遇到的一些问题和解决方案的整理【tensorflow1.14.0gpu+h5py2.8.0+numpy1.16.6】+软件和包的重装_第4张图片

本质是克隆一份源文件,然后新建一个名字为tensorflow的名字。其实感觉还不如直接为文件改名比较方便。

*********************************************************************************************************

6.0 问题描述

tensorflow遇到的一些问题和解决方案的整理【tensorflow1.14.0gpu+h5py2.8.0+numpy1.16.6】+软件和包的重装_第5张图片

6.1 解决方案

重装h5py

pip uninstall h5py

pip install h5py

*********************************************************************************************************

如果以上的方法不能解决的话,可以进入到具体某一篇文章找寻解决方案。

在实验那个语义分析的文件中,我跑通了整个程序,在tensorflow里面遇到的所有问题几乎都遇到了一遍。我把这些遇到的问题和解决方案整理出来以方面后面学习tensorflow的人。

语义分析源程序:https://codechina.csdn.net/mirrors/hqwei/sentiment-analysis

以后遇到问题了再进行分析和总结。

你可能感兴趣的:(python,解决方案,python,anaconda,深度学习,tensorflow,numpy)