We will now translate our little Mandelbrot generation program so that we can use our wrapper library. Let's start with the appropriate import statements; notice how we load all of our wrappers into the current namespace:
from __future__ import divisionfrom time import timeimport matplotlibfrom matplotlib import pyplot as pltimport numpy as npfrom cuda_driver import *
Let's put all of our GPU code into the mandelbrot function, as we did previously. We will start by initializing the CUDA Driver API with cuInit and then checking if there is at least one GPU installed on the system, raising an exception otherwise:
def mandelbrot(breadth, low, high, max_iters, upper_bound): cuInit(0) cnt = c_int(0) cuDeviceGetCount(byref(cnt)) ...