How to get GPU info in mojo

Hello,

I wonder if someone can show an example on how to get info on GPU features from mojo ?

I looked in GPUInfo struct but I cannot make it to work and see nothing in GPU basics.

Lucian

The struct is acting as an enum there. Right now you get info from DeviceContext and DeviceAttribute which we should work on Nvidia and AMD. Apple is being worked on:

from gpu.host import DeviceContext, DeviceAttribute

def main():
    try:
        ctx = DeviceContext()
        print(ctx.name())
        print(ctx.api())
        (free, total) = ctx.get_memory_info()
        print("Free memory:", free / (1024*1024), "MB")
        print("Total memory:", total / (1024*1024), "MB")
        print(ctx.get_attribute(DeviceAttribute.CLOCK_RATE))
        print(ctx.get_attribute(DeviceAttribute.MAX_BLOCKS_PER_MULTIPROCESSOR))

    except:
        print("Error occured!")

Thanks! that’s what I wanted.