【问题标题】:Tensorflow 2.3.0 CUDA Toolkit version 10.1 does not use GPUTensorflow 2.3.0 CUDA Toolkit 10.1版不使用GPU
【发布时间】:2020-08-06 03:19:06
【问题描述】:

我使用我的 RTX2070 gpu 进行了 tensorflow 2.0 工作。我做了一个 Windows 更新,所以我可以使用 tf-nightly。不喜欢它所以卸载它并重新安装 tensorflow 2.3.0。运行以前在 GPU 上运行良好但没有使用 GPU 的以前的 python 代码。尝试了很多东西。终于重新开始了。重新安装 Anaconda,创建新环境。卸载 Cuda 工具包 10.1 并重新安装。在目录 c:\Tools 中安装了 cuDnn SDK 7.6。检查要包含的路径环境变量

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin;
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\extras\CUPTI\lib64;
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include;
C:\tools\cuda\bin;%PATH%
       #then ran this code:
import tensorflow as tf
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
print(tf.__version__)
print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))
tf.test.is_gpu_available()
     #I get the result
[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 15177607927005893519
, name: "/device:XLA_CPU:0"
device_type: "XLA_CPU"
memory_limit: 17179869184
locality {
}
incarnation: 4640072765546557805
physical_device_desc: "device: XLA_CPU device"
, name: "/device:XLA_GPU:0"
device_type: "XLA_GPU"
memory_limit: 17179869184
locality {
}
incarnation: 16675502319763286567
physical_device_desc: "device: XLA_GPU device"
]
2.3.0
Num GPUs Available:  0

False

tensorflow still does not use GPU. What an I missing? 

also same problem using python 3.7.0 and same problem using tensorflow 2.0.0


【问题讨论】:

  • 1. verify cuda install 2.确认你没有设置任何CUDA_VISIBLE_DEVICES环境变量
  • Cuda toolkit v 10.1 创建了相关的目录,因此它被安装了。没有您提到的类型的环境变量。为什么显示 GPU 为 XLA-GPU?
  • 你使用的python版本是什么?
  • 版本是 3.8.3
  • 也试过用python 3.7.0还是有问题。然后尝试了tensorflow 2.0.0 还是有问题

标签: python tensorflow


【解决方案1】:

我发现如果在我使用 conda 的工作环境中运行 conda install cudnn==7.6.4 可以让 tensorflow 识别 GPU,它与 CUDA 10.1.0 一起使用,anaconda 提示符中的结果消息是:

Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: C:\Users\tfuser\anaconda3\envs\tf

  added / updated specs:
    - cudnn==7.6.4


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    cudnn-7.6.4                |       cuda10.1_0       179.3 MB
    ------------------------------------------------------------
                                           Total:       179.3 MB

The following NEW packages will be INSTALLED:

  cudatoolkit        pkgs/main/win-64::cudatoolkit-10.1.243-h74a9793_0
  cudnn              pkgs/main/win-64::cudnn-7.6.4-cuda10.1_0


Proceed ([y]/n)? y
The following packages will be downloaded:
 cudnn-7.6.4                |       cuda10.1_0       179.3 MB
The following NEW packages will be INSTALLED:

  cudatoolkit        pkgs/main/win-64::cudatoolkit-10.1.243-h74a9793_0
  cudnn              pkgs/main/win-64::cudnn-7.6.4-cuda10.1_0


Proceed ([y]/n)? y
Downloading and Extracting Packages
cudnn-7.6.4          | 179.3 MB  |
Preparing transaction: doneVerifying transaction: done
Executing transaction: done

【讨论】:

  • 在我的 cuda 10.2 驱动程序上成功安装 tensorflow-gpu 2.3 和 cudatoolkit 10.1,使用以下命令:conda install cudnn==7.6.4 然后 pip install tensorflow-gpu=2.3 注意:记得激活你的 conda 环境并为 anaconda 安装 pip conda install pip
  • 我遇到了完全相同的问题。 Azure N 系列 DSVM 未显示 GPU 可用性,尽管使用了 DS 映像。将cudnn=7.6.4 添加到我的 conda 环境中修复了它。然后我可以使用 tensorflow 2.3 来训练我的模型。
  • 太棒了!像神一样工作,绝对解决了手动微调所有组件版本的问题! Ubuntu 16.04 TensorFlow 2.3 CUDA 10.1
猜你喜欢
  • 1970-01-01
  • 2021-10-27
  • 1970-01-01
  • 2017-07-26
  • 1970-01-01
  • 2020-12-10
  • 1970-01-01
  • 2021-04-13
  • 2019-01-20
相关资源
最近更新 更多