def check_cuda(feature_name='You are using code that relies on cuda-convnet. Cuda-convnet', check_enabled=True):
 if (not cuda.cuda_available):
  raise RuntimeError(("%s only runs on GPUs, but there doesn't seem to be a GPU available. If you would like assistance making a CPU version of convolutional maxout, contact pylearn-dev@googlegroups.com." % feature_name))
 if (not hasattr(cuda.cuda_ndarray.cuda_ndarray, 'cublas_v2')):
  warnings.warn('You are using probably a too old Theano version. That will cause compilation crash. If so, update Theano.')
 elif (not cuda.cuda_ndarray.cuda_ndarray.cublas_v2()):
  raise RuntimeError('You are using probably a too old Theano version. That will cause compilation crash. Update Theano')
 if (check_enabled and (not cuda.cuda_enabled)):
  raise RuntimeError(('%s must run be with theano configured to use the GPU' % feature_name))

def check_cuda ( feature_name = 'You are using code that relies on cuda-convnet. Cuda-convnet' , check_enabled = True ) : if ( not cuda . cuda_available ) : raise RuntimeError ( ( "%s only runs on GPUs, but there doesn't seem to be a GPU available. If you would like assistance making a CPU version of convolutional maxout, contact pylearn-dev@googlegroups.com." % feature_name ) ) if ( not hasattr ( cuda . cuda_ndarray . cuda_ndarray , 'cublas_v2' ) ) : warnings . warn ( 'You are using probably a too old Theano version. That will cause compilation crash. If so, update Theano.' ) elif ( not cuda . cuda_ndarray . cuda_ndarray . cublas_v2 ( ) ) : raise RuntimeError ( 'You are using probably a too old Theano version. That will cause compilation crash. Update Theano' ) if ( check_enabled and ( not cuda . cuda_enabled ) ) : raise RuntimeError ( ( '%s must run be with theano configured to use the GPU' % feature_name ) )
call this function before sections of code that depend on the cuda_convnet module .