【问题标题】:Tensorflow uses CPU instead of GPU. How to fix?TensorFlow 使用 CPU 而不是 GPU。怎么修?
【发布时间】:2021-03-23 22:34:59
【问题描述】:

我想使用 Anaconda、TensorFlow 2.3、Keras 2.4.3(CNN 示例)运行该项目。操作系统 Windows 10。

我为 CUDA 10.1 安装了 Visual Studio 2019 社区版、CUDA 10.1 和 cudnn 8.0.5。

使用 Anaconda,我使用 TensorFlow(tensorflow-gpu 没有帮助)、Keras、matplotlib、scikit-learn 创建了一个环境。我尝试在 CPU 上运行它,但它需要很长时间(当有 35 个 epoch 时,只有 1 个 epoch 需要 20 分钟)。

我需要使用 GPU 运行它,但 TensorFlow 看不到我的 GPU 设备 (GeForce GTX 1060)。有人可以帮我找到问题吗?我尝试使用本指南tensorflow 解决问题,但它对我没有帮助。

【问题讨论】:

  • 我相信你需要使用 cudnn 7.6.5 和 cudetoolkit 10.1.243 安装。你是用 pip 安装 tensorflow 的吗?
  • 请找到我的分辨率here

标签: python tensorflow


【解决方案1】:

请注意,您尝试使用的 Cudnn 版本不兼容。 Listing Versions and compatible CUDA+Cudnn

您可以转到here,然后向下滚动到底部以查看用于构建 TensorFlow 的 CUDA 和 Cudnn 版本。

【讨论】:

    【解决方案2】:

    好的,所以我尝试将所有组件安装到新的 anaconda 环境中。但我决定写“pip install tensorflow-gpu”而不是“conda install tensorflow-gpu”,现在它可以通过 GPU 工作......

    【讨论】:

      【解决方案3】:

      这 100% 有效,无需手动安装任何东西(例如 cuda)

       conda create --name tf_gpu tensorflow-gpu 
      

      【讨论】:

      • 我通过 Anaconda Powershell Prompt 使用了这个命令。它仍然使用CPU。感谢您的回复。
      猜你喜欢
      • 2021-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-11
      • 2018-05-18
      • 1970-01-01
      • 2021-10-14
      • 1970-01-01
      相关资源
      最近更新 更多