如何使用Python-TensorFlow获取AWS GPU实例详细信息
我使用g4dn.xlarge
实例类型创建了一个AWS GPU实例。
我也安装了python
和jupyter-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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您说自己安装了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/