当前位置: 首页>>代码示例>>Python>>正文


Python mkl.set_num_threads方法代码示例

本文整理汇总了Python中mkl.set_num_threads方法的典型用法代码示例。如果您正苦于以下问题:Python mkl.set_num_threads方法的具体用法?Python mkl.set_num_threads怎么用?Python mkl.set_num_threads使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mkl的用法示例。


在下文中一共展示了mkl.set_num_threads方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _initialize_mp_worker

# 需要导入模块: import mkl [as 别名]
# 或者: from mkl import set_num_threads [as 别名]
def _initialize_mp_worker(mkey, func, threads, log_queue, seed):
    seed = derive_seed(mp.current_process().name, base=seed, none_on_old_numpy=True)
    _initialize_worker(log_queue, seed)
    global __work_model, __work_func

    nnt_env = os.environ.get('NUMBA_NUM_THREADS', None)
    if nnt_env is None or int(nnt_env) > threads:
        _log.debug('configuring Numba thread count')
        import numba
        numba.config.NUMBA_NUM_THREADS = threads
    try:
        import mkl
        _log.debug('configuring MKL thread count')
        mkl.set_num_threads(threads)
    except ImportError:
        pass

    __work_model = mkey
    # deferred function unpickling to minimize imports before initialization
    __work_func = pickle.loads(func)

    _log.debug('worker %d ready (process %s)', os.getpid(), mp.current_process()) 
开发者ID:lenskit,项目名称:lkpy,代码行数:24,代码来源:parallel.py

示例2: configure

# 需要导入模块: import mkl [as 别名]
# 或者: from mkl import set_num_threads [as 别名]
def configure(num_jobs=8, TEST=False, subtract=0, num_proc=None, num_thread_per_proc=None):
    '''
    num_jobs is typically the # of genes we are parallelizing over
    '''
    if num_proc is None:
        num_proc = multiprocessing.cpu_count() - subtract

    if num_jobs > num_proc:
        num_jobs = num_proc

    if num_thread_per_proc is None:
        num_thread_per_proc = int(np.floor(num_proc/num_jobs))

    if TEST:
        num_jobs = 1
        num_thread_per_proc = 1

    try:
        import mkl
        mkl.set_num_threads(num_thread_per_proc)    
    except ImportError:
        print "MKL not available, so I'm not adjusting the number of threads"

    print "Launching %d jobs with %d MKL threads each" % (num_jobs, num_thread_per_proc)

    return num_jobs 
开发者ID:MicrosoftResearch,项目名称:Azimuth,代码行数:28,代码来源:local_multiprocessing.py

示例3: set_num_threads

# 需要导入模块: import mkl [as 别名]
# 或者: from mkl import set_num_threads [as 别名]
def set_num_threads(self, num_threads):
        """Set the number of threads the solver should use (only a hint, not guaranteed that 
        the solver uses this amount)"""
        mkl.set_num_threads(num_threads) 
开发者ID:haasad,项目名称:PyPardisoProject,代码行数:6,代码来源:pardiso_wrapper.py

示例4: set_thread_count

# 需要导入模块: import mkl [as 别名]
# 或者: from mkl import set_num_threads [as 别名]
def set_thread_count(threads):
    """Sets the maximum number of MKL threads for this process."""
    if MKL_THREADS is not None:
        mkl.set_num_threads(max(1, threads)) 
开发者ID:crowsonkb,项目名称:style_transfer,代码行数:6,代码来源:style_transfer.py

示例5: __init__

# 需要导入模块: import mkl [as 别名]
# 或者: from mkl import set_num_threads [as 别名]
def __init__(self, *args, **kwargs):
        super(Worker, self).__init__()

        self.nthreads = pyrat._nthreads  # number of threads for processing
        if pyrat._debug is True:
            self.nthreads = 1

        try:
            import mkl
            if self.nthreads > 1:  # switch of mkl multithreading
                mkl.set_num_threads(1)  # because we do it ourself
            else:
                mkl.set_num_threads(999)
        except ImportError:
            pass

        # self.blockprocess = True                                               # blockprocessing on/off
        # self.blocksize = 128                                                   # size of single block

        for para in self.para:  # copy defaults to self
            setattr(self, para['var'], para['value'])
        for (k, v) in kwargs.items():  # copy keywords to self
            setattr(self, k, v)  # eventually overwriting defaults
        if not hasattr(self, 'layer'):  # if no keyword was used
            self.layer = pyrat.data.active  # use active layer
        # --------------------------------------------------

        self.name = self.__class__.__name__  # name of worker class (string)
        self.input = ''  # input layer(s)
        self.output = ''  # output layer(s)
        self.blockoverlap = 0  # block overlap
        self.vblock = False  # vertical blocks on/off
        self.blocks = []  # list of block boundaries
        self.valid = []  # valid part of each block
        # self.block = False                                                     # actual block range / validity
        self.allowed_ndim = False
        self.require_para = False
        self.allowed_dtype = False 
开发者ID:birgander2,项目名称:PyRAT,代码行数:40,代码来源:Worker.py


注:本文中的mkl.set_num_threads方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。