How it works...

The execution is pretty simple. In the first line of code, pycuda.driver is imported and then initialized:

import pycuda.driver as drv  
drv.init() 

The pycuda.driver module exposes the driver level to the programming interface of CUDA, which is more flexible than the CUDA C runtime-level programming interface, and it has a few features that are not present in the runtime.

Then, it cycles into the drv.Device.count() function and, for each GPU card, the name of the card and its main characteristics (computing capability and total memory) are printed:

print ("Device #%d: %s" % (ordinal, dev.name()))  
print ("Compute Capability: %d.%d" % dev.compute_capability()) 
print ("Total Memory: %s KB" % (dev.total_memory()//(1024))) 

Execute the following code:

C:>python dealingWithPycuda.py

When you've done so, the installed GPU will be shown on the screen, as in the following example:

1 device(s) found.
Device #0: GeForce GT 240
Compute Capability: 1.2
Total Memory: 1048576 KB
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.67.251