PyCUDA provides a simple API to find information such as, which CUDA-enabled GPU devices (if any) are present and which capabilities each device supports. It is important to find out the properties of a GPU device that is being used before writing PyCUDA programs so that the optimal resources of the device can be used.
The program for displaying all properties of CUDA-enabled devices on a system by using PyCUDA is shown as follows:
import pycuda.driver as drv
import pycuda.autoinit
drv.init()
print("%d device(s) found." % drv.Device.count())
for i in range(drv.Device.count()):
dev = drv.Device(i)
print("Device #%d: %s" % (i, dev.name()))
print(" Compute Capability: %d.%d" % dev.compute_capability())
print(" Total Memory: %s GB" % (dev.total_memory()//(1024*1024*1024)))
attributes...