如何使用Python-TensorFlow获取AWS GPU实例详细信息

发布于 2025-02-08 12:43:13 字数 1003 浏览 1 评论 0原文

我使用g4dn.xlarge实例类型创建了一个AWS GPU实例。

我也安装了pythonjupyter-notebook

当我尝试将jupyter笔记本中的GPU详细信息加载到以下代码中时:

import tensorflow as tf
tf.config.list_physical_devices()

输出:

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

我尝试了其他几种方法

1

import tensorflow as tf

gpus = tf.config.list_physical_devices('GPU')
for gpu in gpus:
    print("Name:", gpu.name, "  Type:", gpu.device_type)

2

from tensorflow.python.client import device_lib

device_lib.list_local_devices()

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']

get_available_gpus()

所有代码都将以no GPU响应。

访问GPU的可能选择是什么?

I created an AWS GPU instance with g4dn.xlarge instance type.

I installed Python and Jupyter-notebook as well.

When I am trying to load the GPU details in the Jupyter notebook with the below code:

import tensorflow as tf
tf.config.list_physical_devices()

Output:

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

I tried few other methods as well

1

import tensorflow as tf

gpus = tf.config.list_physical_devices('GPU')
for gpu in gpus:
    print("Name:", gpu.name, "  Type:", gpu.device_type)

2

from tensorflow.python.client import device_lib

device_lib.list_local_devices()

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']

get_available_gpus()

All the codes will respond with no GPU.

what could be the possible options to access the GPU?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温柔嚣张 2025-02-15 12:43:13

由于您说自己安装了Python,因此您可能没有从安装所有驱动程序的深度学习开始,因此您必须安装NVIDIA驱动程序,Cuda和Cudnn。但是,尝试在AWS EC2实例上安装NVIDIA驱动程序可能很难...

解决方案:从深度学习开始:

https://aws.amazon.com/machine-learning/amis/

Since you said you installed Python yourself, it's likely you didn't start with a deep learning AMI with all the drivers installed, so you'd have to install Nvidia drivers, CUDA, and cudnn. But trying to install Nvidia drivers on an AWS EC2 instance can be tough...

Solution: start with the deep learning AMIs:

https://aws.amazon.com/machine-learning/amis/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文