【问题标题】:Tensorflow 2.0 list_physical_devices doesn't detect my GPUTensorflow 2.0 list_physical_devices 没有检测到我的 GPU
【发布时间】:2019-11-20 14:25:49
【问题描述】:

我最近在我的计算机上安装了 tensorflow 2.0,但是当我尝试在我的 GPU 上运行它时,Jupyter 或 Vitual Studio Code 上的函数 tf.config.experimental.list_physical_devices('GPU') 它返回给我一个空数组。你知道为什么吗?

我的设置:

计算机:微星

处理器:Intel(R) Core(TM) i7-8750H CPU @ 2.220GHz

GPU 0:英特尔(R) 超高清显卡 630

GPU:NVIDIA GeForce GTX 1060

Python : Ananconda 3 和 Python 3.7

使用pip install tensorflow安装的Tensenflow 2.0

我的测试代码:

physical_devices = tf.config.experimental.list_physical_devices('GPU')
print(physical_devices)
if physical_devices:
  tf.config.experimental.set_memory_growth(physical_devices[0], True)

提前致谢! :)

【问题讨论】:

  • 您是尝试“pip3 install --upgrade tensorflow-gpu”还是删除 tensorflow 然后安装“tensorflow-gpu”?

标签: python gpu tensorflow2.0


【解决方案1】:

在此处(回答部分)提供解决方案,即使它出现在评论部分是为了社区的利益。

除了pip install tensorflow,您可以尝试pip3 install --upgrade tensorflow-gpu 或删除tensorflow,然后installing "tensorflow-gpu 将解决您的问题。

Tensorflow GPU 安装完成后,您可以查看 GPU 如下

physical_devices = tf.config.experimental.list_physical_devices('GPU')
print(physical_devices)
if physical_devices:
  tf.config.experimental.set_memory_growth(physical_devices[0], True)

输出:

[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

【讨论】:

    【解决方案2】:

    升级对我来说很简单。:

    pip3 install --upgrade tensorflow-gpu
    

    并且搜索的设备名称必须是“XLA_GPU”,并且不会以单独的“GPU”搜索词响应。但是在设置'XLA' gpus 不支持的内存增长时也引发了另一个错误。

    【讨论】:

      猜你喜欢
      • 2020-12-04
      • 2021-05-12
      • 2023-03-19
      • 2020-11-17
      • 2017-09-15
      • 2021-07-29
      • 2020-04-20
      • 2021-03-13
      • 2021-09-14
      相关资源
      最近更新 更多