Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Tensorflow 2.0列出了物理设备和x27;我没有检测到我的GPU_Python_Gpu_Tensorflow2.0 - Fatal编程技术网

Python Tensorflow 2.0列出了物理设备和x27;我没有检测到我的GPU

Python Tensorflow 2.0列出了物理设备和x27;我没有检测到我的GPU,python,gpu,tensorflow2.0,Python,Gpu,Tensorflow2.0,我最近在我的计算机上安装了tensorflow 2.0,但当我尝试在我的GPU上运行它时,Jupyter或Vitual Studio代码上的函数tf.config.experimental.list\u物理设备('GPU')会返回一个空数组。你知道为什么吗 我的设置: physical_devices = tf.config.experimental.list_physical_devices('GPU') print(physical_devices) if physical_devices:

我最近在我的计算机上安装了tensorflow 2.0,但当我尝试在我的GPU上运行它时,Jupyter或Vitual Studio代码上的函数
tf.config.experimental.list\u物理设备('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)
计算机:MSI

处理器:英特尔(R)核心(TM)i7-8750H处理器@2.220GHz

GPU 0:Intel(R)UHD图形630

GPU:NVIDIA GeForce GTX 1060

Python:ananconda3和Python 3.7

Tensenflow 2.0安装时附带
pip安装tensorflow

我的测试代码:

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)

提前感谢!:)

在这里提供解决方案(答案部分),即使为了社区的利益,它出现在评论部分

您可以尝试
pip安装tensorflow
,而不是
pip安装tensorflow-gpu
,或者只需删除
tensorflow
,然后
安装“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')]

升级对我来说很有效

pip3 install --upgrade tensorflow-gpu
搜索的设备名称必须是“XLA\U GPU”,并且不会使用单独的“GPU”搜索词进行响应。但在设置“XLA”GPU不支持的内存增长时,它也引发了另一个错误。

您是否尝试过“pip3安装-升级tensorflow GPU”或只是删除tensorflow,然后安装“tensorflow GPU”?