diff options
author | Anthony LaTorre <tlatorre9@gmail.com> | 2011-09-11 01:05:29 -0400 |
---|---|---|
committer | Anthony LaTorre <tlatorre9@gmail.com> | 2011-09-11 01:05:29 -0400 |
commit | 1a3dc65dd50d1cfb8ef819abbdbdf99e61b3ed0b (patch) | |
tree | 36ee8371aebe37e1b0474d869b1f2b9fd84b88e3 | |
parent | 55cec145d72baf58639aad7773e23e28c9ca8676 (diff) | |
download | chroma-1a3dc65dd50d1cfb8ef819abbdbdf99e61b3ed0b.tar.gz chroma-1a3dc65dd50d1cfb8ef819abbdbdf99e61b3ed0b.tar.bz2 chroma-1a3dc65dd50d1cfb8ef819abbdbdf99e61b3ed0b.zip |
correctly check cuda initialization in create_cuda_context().
-rw-r--r-- | gpu.py | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -778,16 +778,20 @@ class GPUPDF(object): def create_cuda_context(device_id=None): """Initialize and return a CUDA context on the specified device. If device_id is None, the default device is used.""" - try: - cuda.mem_get_info() - except cuda.LogicError: - # initialize cuda - cuda.init() - if device_id is None: - context = pycuda.tools.make_default_context() + try: + context = pycuda.tools.make_default_context() + except cuda.LogicError: + # initialize cuda + cuda.init() + context = pycuda.tools.make_default_context() else: - device = cuda.Device(device_id) + try: + device = cuda.Device(device_id) + except cuda.LogicError: + # initialize cuda + cuda.init() + device = cuda.Device(device_id) context = device.make_context() context.set_cache_config(cuda.func_cache.PREFER_L1) |