Tensorflow 2.0 list_physical_devices 未检测到我的 GPU [英] Tensorflow 2.0 list_physical_devices doesn't detect my 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
我的测试代码:
physical_devices = tf.config.experimental.list_physical_devices('GPU')打印(物理设备)如果物理设备:tf.config.experimental.set_memory_growth(物理设备[0],真)
提前致谢!:)
在此处提供解决方案(答案部分),即使它存在于评论部分以造福社区.p>
代替 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屋!