【问题标题】:Tensorflow not detecting GPU - Adding visible gpu devices: 0Tensorflow 未检测到 GPU - 添加可见 gpu 设备:0
【发布时间】:2019-06-03 07:43:52
【问题描述】:

我有一个配备 NVIDIA GeForce GTX 980 Ti 的系统。我安装了 tensorflow,并使用 tf.test.gpu_device_name() 查找 gpu 设备。看起来它找到了 gpu,但随后显示“添加可见 gpu 设备:0”

>>> import tensorflow as tf
>>> tf.test.gpu_device_name()
2019-01-08 10:01:12.589000: I tensorflow/core/platform/cpu_feature_guard.cc:141]
 Your CPU supports instructions that this TensorFlow binary was not compiled to
use: AVX2
2019-01-08 10:01:12.855000: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1
432] Found device 0 with properties:
name: GeForce GTX 980 Ti major: 5 minor: 2 memoryClockRate(GHz): 1.228
pciBusID: 0000:01:00.0
totalMemory: 6.00GiB freeMemory: 5.67GiB
2019-01-08 10:01:12.862000: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1
511] Adding visible gpu devices: 0

【问题讨论】:

  • 设备为0... 检测到。
  • 但它没有被使用。在另一个系统(相同的 GPU)上,它以“创建的 Tensorflow 设备(/device:GPU:0 with 75MB memory)-> 物理 GPU(设备:0,名称 GeForce GTX 980 Ti,pci 总线 ID:0000:01:00.0,计算能力:5.2"
  • tensorflow.org/guide/using_gpu 这就是你在 tensorflow 中使用 gpu 所需要知道的一切

标签: tensorflow


【解决方案1】:

有趣的是,你关心的 0 并不是你用来计数的 0。准确地说,它不是“检测到 0 台设备”,而是“检测到 0 台设备”。 “添加可见设备 0”,这里的 0 是您 GPU 的标识。或者你可以说,tensorflow 的方式来区分系统中的多个 GPU。 这是我的系统的输出,我很确定,我正在用 gpu 进行计算。 所以不用担心。你已准备好出发! ?

Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.test.gpu_device_name()
2019-01-08 20:51:02.212125: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2019-01-08 20:51:03.199893: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1411] Found device 0 with properties:
name: GeForce GTX 1060 with Max-Q Design major: 6 minor: 1 memoryClockRate(GHz): 1.3415
pciBusID: 0000:01:00.0
totalMemory: 6.00GiB freeMemory: 4.97GiB
2019-01-08 20:51:03.207308: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1490] Adding visible gpu devices: 0
2019-01-08 20:51:04.857881: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-01-08 20:51:04.861791: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977]      0
2019-01-08 20:51:04.863796: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990] 0:   N
2019-01-08 20:51:04.867507: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1103] Created TensorFlow device (/device:GPU:0 with 4722 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1060 with Max-Q Design, pci bus id: 0000:01:00.0, compute capability: 6.1)
'/device:GPU:0'

【讨论】:

  • 另外,为了确保 GPU 无法正常工作,我建议您转到 link 并导入 tensorflow 并运行一个简单的图表,同时密切关注 gpu 活动面板。如果一切正常,您将能够在那里看到 python.exe。
  • 在 TensorFlow 中,支持的设备类型是 CPU 和 GPU。它们表示为字符串。例如:“/cpu:0”:你机器的 CPU。 “/device:GPU:0”:你机器的 GPU,如果你有的话。 “/device:GPU:1”:你机器的第二个GPU等
【解决方案2】:

以管理员身份运行提示解决了我的问题

【讨论】:

  • 这对我有用。谢谢!! TensorflowJS 3.6.1/Cuda 11.0/RTX 2060 MAXQ。不过,由于“cusolver64_10.dll”失败,我不得不将 Cuda 驱动程序从 11.3 降级到 11.0。
【解决方案3】:

您可以尝试以下命令之一:

  1. device_lib.list_local_devices()
  2. print("可用的 GPU 数量:", len(tf.config.experimental.list_physical_devices('GPU')))

这将显示 gpu 设备及其编号。

我的设置如下来解决这个问题:

张量流 2.4.1

cuda 11.0.2

cudNN 8.1.0

所以首先你安装 tensorflow。然后继续使用 cuda (https://developer.nvidia.com/cuda-11.0-download-archive) 并从此处下载 cudNN zip 文件 -> https://developer.nvidia.com/rdp/cudnn-download,解压缩并将 cudnn64_8.dll 文件粘贴到 C:\Program Files \NVIDIA GPU 计算工具包\CUDA\v11.0\bin。 然后一切都像魅力一样发挥作用。

【讨论】:

    【解决方案4】:

    我也面临同样的问题,使用 environment.yml 文件创建 conda 环境为我解决了这个问题。 .yml 文件的内容如下: 请确保在代码的最后一行提供您的系统路径。例如。 “/home/nikhilanand_1921cs24”应替换为您的系统路径。

    name: keras-gpu
    channels:
      - conda-forge
      - defaults
    dependencies:
      - _libgcc_mutex=0.1=main
      - _openmp_mutex=4.5=1_gnu
      - _tflow_select=2.1.0=gpu
      - absl-py=0.13.0=py39h06a4308_0
      - aiohttp=3.8.1=py39h7f8727e_0
      - aiosignal=1.2.0=pyhd3eb1b0_0
      - astor=0.8.1=py39h06a4308_0
      - astunparse=1.6.3=py_0
      - async-timeout=4.0.1=pyhd3eb1b0_0
      - attrs=21.2.0=pyhd3eb1b0_0
      - blas=1.0=mkl
      - blinker=1.4=py39h06a4308_0
      - brotli=1.0.9=h7f98852_5
      - brotli-bin=1.0.9=h7f98852_5
      - brotlipy=0.7.0=py39h27cfd23_1003
      - c-ares=1.17.1=h27cfd23_0
      - ca-certificates=2021.10.8=ha878542_0
      - cachetools=4.2.2=pyhd3eb1b0_0
      - certifi=2021.10.8=py39hf3d152e_1
      - cffi=1.14.6=py39h400218f_0
      - charset-normalizer=2.0.4=pyhd3eb1b0_0
      - click=8.0.3=pyhd3eb1b0_0
      - cryptography=3.4.8=py39hd23ed53_0
      - cudatoolkit=10.1.243=h6bb024c_0
      - cudnn=7.6.5=cuda10.1_0
      - cupti=10.1.168=0
      - cycler=0.11.0=pyhd8ed1ab_0
      - dataclasses=0.8=pyh6d0b6a4_7
      - dbus=1.13.6=he372182_0
      - expat=2.2.10=h9c3ff4c_0
      - fontconfig=2.13.1=h6c09931_0
      - fonttools=4.25.0=pyhd3eb1b0_0
      - freetype=2.10.4=h0708190_1
      - frozenlist=1.2.0=py39h7f8727e_0
      - gast=0.4.0=pyhd3eb1b0_0
      - glib=2.69.1=h4ff587b_1
      - google-auth=1.33.0=pyhd3eb1b0_0
      - google-auth-oauthlib=0.4.4=pyhd3eb1b0_0
      - google-pasta=0.2.0=pyhd3eb1b0_0
      - grpcio=1.42.0=py39hce63b2e_0
      - gst-plugins-base=1.14.0=hbbd80ab_1
      - gstreamer=1.14.0=h28cd5cc_2
      - h5py=2.10.0=py39hec9cf62_0
      - hdf5=1.10.6=hb1b8bf9_0
      - icu=58.2=hf484d3e_1000
      - idna=3.3=pyhd3eb1b0_0
      - importlib-metadata=4.8.2=py39h06a4308_0
      - intel-openmp=2021.4.0=h06a4308_3561
      - jpeg=9d=h7f8727e_0
      - keras-preprocessing=1.1.2=pyhd3eb1b0_0
      - kiwisolver=1.3.1=py39h2531618_0
      - lcms2=2.12=hddcbb42_0
      - ld_impl_linux-64=2.35.1=h7274673_9
      - libbrotlicommon=1.0.9=h7f98852_5
      - libbrotlidec=1.0.9=h7f98852_5
      - libbrotlienc=1.0.9=h7f98852_5
      - libffi=3.3=he6710b0_2
      - libgcc-ng=9.3.0=h5101ec6_17
      - libgfortran-ng=7.5.0=ha8ba4b0_17
      - libgfortran4=7.5.0=ha8ba4b0_17
      - libgomp=9.3.0=h5101ec6_17
      - libpng=1.6.37=h21135ba_2
      - libprotobuf=3.17.2=h4ff587b_1
      - libstdcxx-ng=9.3.0=hd4cf53a_17
      - libtiff=4.2.0=h85742a9_0
      - libuuid=1.0.3=h7f8727e_2
      - libwebp-base=1.2.0=h27cfd23_0
      - libxcb=1.13=h7f98852_1003
      - libxml2=2.9.12=h03d6c58_0
      - lz4-c=1.9.3=h9c3ff4c_1
      - markdown=3.3.4=py39h06a4308_0
      - matplotlib=3.4.3=py39hf3d152e_2
      - matplotlib-base=3.4.3=py39hbbc1b5f_0
      - mkl=2021.4.0=h06a4308_640
      - mkl-service=2.4.0=py39h7f8727e_0
      - mkl_fft=1.3.1=py39hd3c417c_0
      - mkl_random=1.2.2=py39h51133e4_0
      - multidict=5.1.0=py39h27cfd23_2
      - munkres=1.1.4=pyh9f0ad1d_0
      - ncurses=6.3=h7f8727e_2
      - numpy=1.21.2=py39h20f2e39_0
      - numpy-base=1.21.2=py39h79a1101_0
      - oauthlib=3.1.1=pyhd3eb1b0_0
      - olefile=0.46=pyh9f0ad1d_1
      - openssl=1.1.1m=h7f8727e_0
      - opt_einsum=3.3.0=pyhd3eb1b0_1
      - pcre=8.45=h9c3ff4c_0
      - pip=21.2.4=py39h06a4308_0
      - protobuf=3.17.2=py39h295c915_0
      - pthread-stubs=0.4=h36c2ea0_1001
      - pyasn1=0.4.8=pyhd3eb1b0_0
      - pyasn1-modules=0.2.8=py_0
      - pycparser=2.21=pyhd3eb1b0_0
      - pyjwt=2.1.0=py39h06a4308_0
      - pyopenssl=21.0.0=pyhd3eb1b0_1
      - pyparsing=3.0.7=pyhd8ed1ab_0
      - pyqt=5.9.2=py39h2531618_6
      - pysocks=1.7.1=py39h06a4308_0
      - python=3.9.7=h12debd9_1
      - python-dateutil=2.8.2=pyhd8ed1ab_0
      - python-flatbuffers=2.0=pyhd3eb1b0_0
      - python_abi=3.9=2_cp39
      - qt=5.9.7=h5867ecd_1
      - readline=8.1=h27cfd23_0
      - requests=2.26.0=pyhd3eb1b0_0
      - requests-oauthlib=1.3.0=py_0
      - rsa=4.7.2=pyhd3eb1b0_1
      - scipy=1.7.1=py39h292c36d_2
      - setuptools=58.0.4=py39h06a4308_0
      - sip=4.19.13=py39h295c915_0
      - six=1.16.0=pyhd3eb1b0_0
      - sqlite=3.36.0=hc218d9a_0
      - tensorboard-plugin-wit=1.6.0=py_0
      - tensorflow-estimator=2.6.0=pyh7b7c402_0
      - termcolor=1.1.0=py39h06a4308_1
      - tk=8.6.11=h1ccaba5_0
      - tornado=6.1=py39h3811e60_1
      - typing-extensions=3.10.0.2=hd3eb1b0_0
      - typing_extensions=3.10.0.2=pyh06a4308_0
      - tzdata=2021e=hda174b7_0
      - urllib3=1.26.7=pyhd3eb1b0_0
      - werkzeug=2.0.2=pyhd3eb1b0_0
      - wheel=0.37.0=pyhd3eb1b0_1
      - wrapt=1.13.3=py39h7f8727e_2
      - xorg-libxau=1.0.9=h7f98852_0
      - xorg-libxdmcp=1.1.3=h7f98852_0
      - xz=5.2.5=h7b6447c_0
      - yarl=1.6.3=py39h27cfd23_0
      - zipp=3.6.0=pyhd3eb1b0_0
      - zlib=1.2.11=h7f8727e_4
      - zstd=1.4.9=ha95c52a_0
      - pip:
        - joblib==1.1.0
        - keras==2.8.0
        - keras-applications==1.0.8
        - libclang==13.0.0
        - opencv-python==4.5.5.62
        - pandas==1.4.0
        - pillow==9.0.1
        - pytz==2021.3
        - pyyaml==6.0
        - scikit-learn==1.0.2
        - tensorboard==2.8.0
        - tensorboard-data-server==0.6.1
        - tensorflow==2.8.0
        - tensorflow-gpu==2.8.0
        - tensorflow-io-gcs-filesystem==0.23.1
        - tf-estimator-nightly==2.8.0.dev2021122109
        - threadpoolctl==3.0.0
    prefix: /home/nikhilanand_1921cs24/anaconda3/envs/keras-gpu
    

    通过运行conda env create -f environment.yml 创建环境

    【讨论】:

      猜你喜欢
      • 2017-09-15
      • 1970-01-01
      • 2018-05-31
      • 2020-12-10
      • 2020-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-04
      相关资源
      最近更新 更多