首页 > 解决方案 > 为什么 GPU 没有在 python 中显示

问题描述

我的笔记本电脑是戴尔 xps 15,它有 Intel 和 Nvidia GPU。当我通过 dxdiag 检查时,它只显示 Intel GPU。

直接的

当我转到设备管理器时,它会显示两个 GPU。

图形处理器

现在,当我键入以下代码时,Spider 控制台中什么也没有。

代码 1:

Import tensorflow as tf
tf.test.is_gpu_available()

代码 2:

Import tensorflow as tf
tf.test.gpu_device_name()

代码 3:

from tensorflow.python.client import device_lib

def get_available_gpus():
    local_device_protos = device_lib.list_local_devices()
    return [x.name for x in local_device_protos if x.device_type == 'GPU']

问题是什么?如何解决这个错误?我需要启用或激活某些东西吗?

标签: pythontensorflow

解决方案


推荐阅读