logo
Loading...

Tensorflow_keras 安裝失敗 - Cupoy

老師好,我目前的GPU 是NV 1660,驅動程式版本NVCUDA:為了確保相容,使用版本如下pyt...

day 066,tensorflow,keras,安裝

Tensorflow_keras 安裝失敗

2020/06/07 下午 07:31
機器學習共學討論版
Jason
觀看數:18
回答數:4
收藏數:0
day 066
tensorflow
keras
安裝

老師好,

我目前的GPU 是NV 1660,驅動程式版本

NVCUDA:

為了確保相容,使用版本如下

python 3.6.10/tensorflow1.13.1 /CUDA10.0.1/cuDNN7.6.4

使用conda建立環境並列出Conda list如下

# packages in environment at C:\Users\Jason\.conda\envs\ML100-tf:
#
# Name                    Version                   Build  Channel
absl-py                   0.9.0                    pypi_0    pypi
astor                     0.8.1                    pypi_0    pypi
attrs                     19.3.0                     py_0  
backcall                  0.1.0                    py36_0  
bleach                    3.1.4                      py_0  
ca-certificates           2020.1.1                      0  
certifi                   2020.4.5.1               py36_0  
colorama                  0.4.3                      py_0  
cudatoolkit               10.0.130                      0  
cudnn                     7.6.4                cuda10.0_0  
cycler                    0.10.0                     py_2    conda-forge
decorator                 4.4.2                      py_0  
defusedxml                0.6.0                      py_0  
entrypoints               0.3                      py36_0  
freetype                  2.10.2               hd328e21_0    conda-forge
gast                      0.3.3                    pypi_0    pypi
grpcio                    1.29.0                   pypi_0    pypi
h5py                      2.10.0                   pypi_0    pypi
icu                       64.2                 he025d50_1    conda-forge
importlib-metadata        1.6.0                    py36_0  
importlib_metadata        1.6.0                         0  
intel-openmp              2020.0                      166  
ipykernel                 5.1.4            py36h39e3cac_0  
ipython                   7.13.0           py36h5ca1d4c_0  
ipython_genutils          0.2.0                    py36_0  
ipywidgets                7.5.1                      py_0  
jedi                      0.17.0                   py36_0  
jinja2                    2.11.2                     py_0  
jpeg                      9d                   he774522_0    conda-forge
jsonschema                3.2.0                    py36_0  
jupyter                   1.0.0                    py36_7  
jupyter_client            6.1.3                      py_0  
jupyter_console           6.1.0                      py_0  
jupyter_core              4.6.3                    py36_0  
keras-applications        1.0.8                    pypi_0    pypi
keras-preprocessing       1.1.2                    pypi_0    pypi
kiwisolver                1.2.0            py36h246c5b5_0    conda-forge
libblas                   3.8.0                    15_mkl    conda-forge
libcblas                  3.8.0                    15_mkl    conda-forge
libclang                  9.0.1           default_hf44288c_0    conda-forge
liblapack                 3.8.0                    15_mkl    conda-forge
liblapacke                3.8.0                    15_mkl    conda-forge
libopencv                 4.2.0                    py36_6    conda-forge
libpng                    1.6.37               hfe6a214_1    conda-forge
libsodium                 1.0.16               h9d3ae62_0  
libtiff                   4.1.0                h885aae3_6    conda-forge
libwebp                   1.0.2                hfa6e2cd_5    conda-forge
lz4-c                     1.9.2                h62dcd97_1    conda-forge
m2w64-gcc-libgfortran     5.3.0                         6  
m2w64-gcc-libs            5.3.0                         7  
m2w64-gcc-libs-core       5.3.0                         7  
m2w64-gmp                 6.1.0                         2  
m2w64-libwinpthread-git   5.0.0.4634.697f757               2  
markdown                  3.2.2                    pypi_0    pypi
markupsafe                1.1.1            py36he774522_0  
matplotlib                3.2.1                         0    conda-forge
matplotlib-base           3.2.1            py36hf0cddfc_0    conda-forge
mistune                   0.8.4            py36he774522_0  
mkl                       2020.0                      166  
mock                      4.0.2                    pypi_0    pypi
msys2-conda-epoch         20160418                      1  
nbconvert                 5.6.1                    py36_0  
nbformat                  5.0.6                      py_0  
notebook                  6.0.3                    py36_0  
numpy                     1.18.5           py36h4d86e3b_0    conda-forge
opencv                    4.2.0                    py36_6    conda-forge
openssl                   1.1.1g               he774522_0  
pandoc                    2.2.3.2                       0  
pandocfilters             1.4.2                    py36_1  
parso                     0.7.0                      py_0  
pickleshare               0.7.5                    py36_0  
pip                       20.0.2                   py36_3  
prometheus_client         0.7.1                      py_0  
prompt-toolkit            3.0.5                      py_0  
prompt_toolkit            3.0.5                         0  
protobuf                  3.12.2                   pypi_0    pypi
py-opencv                 4.2.0            py36h95af2a2_6    conda-forge
pygments                  2.6.1                      py_0  
pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
pyqt                      5.12.3           py36h003fed8_3    conda-forge
pyqt5-sip                 4.19.18                  pypi_0    pypi
pyqtchart                 5.12                     pypi_0    pypi
pyqtwebengine             5.12.1                   pypi_0    pypi
pyrsistent                0.16.0           py36he774522_0  
python                    3.6.10               h9f7ef89_2  
python-dateutil           2.8.1                      py_0    conda-forge
python_abi                3.6                     1_cp36m    conda-forge
pywin32                   227              py36he774522_1  
pywinpty                  0.5.7                    py36_0  
pyzmq                     18.1.1           py36ha925a31_0  
qt                        5.12.5               h7ef1ec2_0    conda-forge
qtconsole                 4.7.4                      py_0  
qtpy                      1.9.0                      py_0  
send2trash                1.5.0                    py36_0  
setuptools                47.1.1                   py36_0  
six                       1.15.0             pyh9f0ad1d_0    conda-forge
sqlite                    3.31.1               h2a8f88b_1  
tensorboard               1.13.1                   pypi_0    pypi
tensorflow-estimator      1.13.0                   pypi_0    pypi
tensorflow-gpu            1.13.1                   pypi_0    pypi
termcolor                 1.1.0                    pypi_0    pypi
terminado                 0.8.3                    py36_0  
testpath                  0.4.4                      py_0  
tornado                   6.0.4            py36hfa6e2cd_0    conda-forge
traitlets                 4.3.3                    py36_0  
vc                        14.1                 h0510ff6_4  
vs2015_runtime            14.16.27012          hf0eaf9b_2  
wcwidth                   0.1.9                      py_0  
webencodings              0.5.1                    py36_1  
werkzeug                  1.0.1                    pypi_0    pypi
wheel                     0.34.2                   py36_0  
widgetsnbextension        3.5.1                    py36_0  
wincertstore              0.2              py36h7fe50ca_0  
winpty                    0.4.3                         4  
xz                        5.2.5                h2fa13f4_0    conda-forge
zeromq                    4.3.1                h33f27b4_3  
zipp                      3.1.0                      py_0  
zlib                      1.2.11               h62dcd97_4  
zstd                      1.4.4                h9f78265_3    conda-forge
------------------------------------------------------------------------------------------

完成安裝後執行

from tensorflow.python.client import device_lib

print(device_lib.list_local_devices())

出現錯誤如下

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
~\.conda\envs\ML100-tf\lib\site-packages\numpy\core\__init__.py in <module>
    23 try:
---> 24     from . import multiarray
    25 except ImportError as exc:

~\.conda\envs\ML100-tf\lib\site-packages\numpy\core\multiarray.py in <module>
    13
---> 14 from . import overrides
    15 from . import _multiarray_umath

~\.conda\envs\ML100-tf\lib\site-packages\numpy\core\overrides.py in <module>
     6
----> 7 from numpy.core._multiarray_umath import (
     8     add_docstring, implement_array_function, _get_implementing_args)

ImportError: DLL load failed: 找不到指定的模組。

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-3-0ca82b29604d> in <module>
----> 1 from tensorflow.python.client import device_lib
     2 print(device_lib.list_local_devices())

~\.conda\envs\ML100-tf\lib\site-packages\tensorflow\__init__.py in <module>
    22
    23 # pylint: disable=g-bad-import-order
---> 24 from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
    25
    26 from tensorflow._api.v1 import app

~\.conda\envs\ML100-tf\lib\site-packages\tensorflow\python\__init__.py in <module>
    45 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top
    46
---> 47 import numpy as np
    48
    49 from tensorflow.python import pywrap_tensorflow

~\.conda\envs\ML100-tf\lib\site-packages\numpy\__init__.py in <module>
   140     from . import _distributor_init
   141
--> 142     from . import core
   143     from .core import *
   144     from . import compat

~\.conda\envs\ML100-tf\lib\site-packages\numpy\core\__init__.py in <module>
    48 """ % (sys.version_info[0], sys.version_info[1], sys.executable,
    49         __version__, exc)
---> 50     raise ImportError(msg)
    51 finally:
    52     for envkey in env_added:

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.6 from "C:\Users\Jason\.conda\envs\ML100-tf\python.exe"
 * The NumPy version is: "1.18.5"

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

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

-------------------------------------------------------------------------------

跪求建議!

回答列表

  • 2020/06/07 下午 11:55
    Yang Wang
    贊同數:0
    不贊同數:0
    留言數:0

    先 uninstall 之後再重新安裝一次試試看吧

  • 2020/06/08 下午 01:49
    張維元 (WeiYuan)
    贊同數:0
    不贊同數:0
    留言數:1

    這個是版本對不上的問題, 重新安裝一次試試看:


    ```

    $ pip uninstall tensorflow-gpu

    $ pip install tensorflow-gpu

    ```


    如果這個回答對你有幫助請主動點選「有幫助」的按鈕,也可以追蹤我的GITHUB帳號。若還有問題的話,也歡迎繼續再追問或者把你理解的部分整理上來,我都會提供你 Review 和 Feedback 😃😃😃

  • 2020/06/08 下午 10:47
    Jeffrey
    贊同數:0
    不贊同數:0
    留言數:0

    1. tensorflow-gpu 1.13.1 對映的是 cuDNN7.4, 目前cuDNN7.6.4

    2. 確認keras 是否為 GPU 的版本

    3. 確認 tensorflow, GPU CARD是否安裝成功


    import os

    os.environ["CUDA_VISIBLE_DEVICES"] = "0"

    # os.getcwd()   

    import tensorflow as tf

    W = tf.constant([1.0, 2.0, 3.0, 4.0], shape=[2, 2], name='W')

    x = tf.constant([1.3, 2.4], shape=[2, 1], name='x')

    y = tf.matmul(W, x)

    # 只使用 30% 的 GPU 記憶體

    gpu_options = tf.compat.v1.GPUOptions(per_process_gpu_memory_fraction = 0.3)

    # Creates a session with log_device_placement set to True. 

    sess = tf.compat.v1.Session(config=tf.compat.v1.ConfigProto(log_device_placement=True)) 

  • 2020/06/09 下午 11:42
    張維元 (WeiYuan)
    贊同數:0
    不贊同數:0
    留言數:0

    嗨,看起來版本都正常,從錯誤中看起來是跟 numpy 有關,可以更新看看:


    ```

    $ pip install -U numpy

    ```


    如果這個回答對你有幫助請主動點選「有幫助」的按鈕,也可以追蹤我的GITHUB帳號。若還有問題的話,也歡迎繼續再追問或者把你理解的部分整理上來,我都會提供你 Review 和 Feedback 😃😃😃