Tensorflow 2.0 list_physical_devices 未检测到我的 GPU [英] Tensorflow 2.0 list_physical_devices doesn't detect my GPU

查看:152
本文介绍了Tensorflow 2.0 list_physical_devices 未检测到我的 GPU的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我的设置:

电脑:微星

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

GPU 0 : Intel(R) UHD Graphics 630

GPU:NVIDIA GeForce GTX 1060

Python : Ananconda 3 with Python 3.7

使用 pip install tensorflow

安装 Tensenflow 2.0

我的测试代码:

physical_devices = tf.config.experimental.list_physical_devices('GPU')打印(物理设备)如果物理设备:tf.config.experimental.set_memory_growth(物理设备[0],真)

提前致谢!:)

解决方案

在此处提供解决方案(答案部分),即使它存在于评论部分以造福社区.

代替 pip install tensorflow,您可以尝试 pip3 install --upgrade tensorflow-gpu 或删除 tensorflow 然后 安装tensorflow-gpu 将解决您的问题.

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

physical_devices = tf.config.experimental.list_physical_devices('GPU')打印(物理设备)如果物理设备:tf.config.experimental.set_memory_growth(物理设备[0],真)

输出:

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

I recently install tensorflow 2.0 on my computer but when I try to run it on my GPU, the function tf.config.experimental.list_physical_devices('GPU') on Jupyter or Vitual Studio Code it returns me a void array. Do you know why ?

My set-up :

Computer : MSI

Processor : Intel(R) Core(TM) i7-8750H CPU @ 2.220GHz

GPU 0 : Intel(R) UHD Graphics 630

GPU : NVIDIA GeForce GTX 1060

Python : Ananconda 3 with Python 3.7

Tensenflow 2.0 installed with pip install tensorflow

My test code :

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)

Thanks in advance ! :)

解决方案

Providing the solution here (Answer Section), even though it is present in the Comment Section for the benefit of the community.

Instead of pip install tensorflow, you can try pip3 install --upgrade tensorflow-gpu or just remove tensorflow and then installing "tensorflow-gpu will resolves your issue.

After installation of Tensorflow GPU, you can check GPU as below

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)

Output:

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

这篇关于Tensorflow 2.0 list_physical_devices 未检测到我的 GPU的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆