2014-04-07 11:55:46 +01:00
|
|
|
"""
|
|
|
|
|
The package for scikits.cuda initialization
|
|
|
|
|
|
|
|
|
|
Global variables: initSuccess
|
|
|
|
|
providing CUBLAS handle: cublas_handle
|
|
|
|
|
"""
|
|
|
|
|
|
2014-06-26 13:46:47 +01:00
|
|
|
gpu_initialized = False
|
|
|
|
|
gpu_device = None
|
|
|
|
|
gpu_context = None
|
|
|
|
|
MPI_enabled = False
|
|
|
|
|
|
2016-02-09 17:22:38 +00:00
|
|
|
try:
|
|
|
|
|
import pycuda.autoinit
|
|
|
|
|
gpu_initialized = True
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
# def initGPU():
|
|
|
|
|
# try:
|
|
|
|
|
# from mpi4py import MPI
|
|
|
|
|
# MPI_enabled = True
|
|
|
|
|
# except:
|
|
|
|
|
# pass
|
|
|
|
|
# try:
|
|
|
|
|
# if MPI_enabled and MPI.COMM_WORLD.size>1:
|
|
|
|
|
# from .parallel import get_id_within_node
|
|
|
|
|
# gpuid = get_id_within_node()
|
|
|
|
|
# import pycuda.driver
|
|
|
|
|
# pycuda.driver.init()
|
|
|
|
|
# if gpuid>=pycuda.driver.Device.count():
|
|
|
|
|
# print('['+MPI.Get_processor_name()+'] more processes than the GPU numbers!')
|
|
|
|
|
# raise
|
|
|
|
|
# gpu_device = pycuda.driver.Device(gpuid)
|
|
|
|
|
# gpu_context = gpu_device.make_context()
|
|
|
|
|
# gpu_initialized = True
|
|
|
|
|
# else:
|
|
|
|
|
# import pycuda.autoinit
|
|
|
|
|
# gpu_initialized = True
|
|
|
|
|
# except:
|
|
|
|
|
# pass
|
2015-09-07 16:27:31 +01:00
|
|
|
|
2014-06-26 12:17:45 +01:00
|
|
|
def closeGPU():
|
|
|
|
|
if gpu_context is not None:
|
|
|
|
|
gpu_context.detach()
|