Is there a way to check if mxnet uses my gpu?


Can I see what are the available GPUs with mxnet?

Is there something similar for TensorFlow‘s


in mxnet?


The definitive way to check if your GPU is being utilized is by using nvidia-smi command. My favorite arguments are:

nvidia-smi --query-gpu=timestamp,name,pci.bus_id,driver_version,pstate,,,temperature.gpu,utilization.gpu,utilization.memory,,,memory.used --format=csv -l 1

If you just want to test if gpu support is available (which is what tf.test.gpu_device_name()) does, the following function can help:

import mxnet as mx 
def gpu_device(gpu_number=0):
        _ = mx.nd.array([1, 2, 3], ctx=mx.gpu(gpu_number))
    except mx.MXNetError:
        return None
    return mx.gpu(gpu_number)

This function returns None if the requested gpu device isn’t available, or returns the relevant context if gpu device is available. You can also use this function to check if there is any support for GPU on this system:

if not gpu_device():
    print('No GPU device found!')

Answered By – Sina Afrooze

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