How to get AWS GPU instance details using Python-tensorflow


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


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

I tried few other methods as well


import tensorflow as tf

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


from tensorflow.python.client import device_lib



from tensorflow.python.client import device_lib

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


All the codes will respond with no GPU.

what could be the possible options to access the GPU?


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:

Answered By – Yaoshiang

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published