How to use the mkl.set_num_threads function in mkl

To help you get started, we’ve selected a few mkl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bbfrederick / rapidtide / rapidtide / workflows / happy.py View on Github external
sys.exit()
        else:
            assert False, "unhandled option: " + o
        formattedcmdline.append('\t' + o + linkchar + a + ' \\')
    formattedcmdline[len(formattedcmdline) - 1] = formattedcmdline[len(formattedcmdline) - 1][:-2]

    # write out the command used
    tide_util.savecommandline(thearguments, outputroot)
    tide_io.writevec(formattedcmdline, outputroot + '_formattedcommandline.txt')

    memfile = open(outputroot + '_memusage.csv', 'w')
    tide_util.logmem(None, file=memfile)

    # set the number of MKL threads to use
    if mklexists:
        mkl.set_num_threads(mklthreads)

    # if doglm is set, make sure we are generating app matrix
    if doglm and cardcalconly:
        print('doing glm fit requires phase projection - setting cardcalconly to False')
        cardcalconly = False

    # set up cardiac filter
    arb_lower = minhrfilt / 60.0
    arb_upper = maxhrfilt / 60.0
    thecardbandfilter = tide_filt.noncausalfilter()
    thecardbandfilter.settype('arb')
    arb_lowerstop = arb_lower * 0.9
    arb_upperstop = arb_upper * 1.1
    thecardbandfilter.setfreqs(arb_lowerstop, arb_lower, arb_upper, arb_upperstop)
    therespbandfilter = tide_filt.noncausalfilter()
    therespbandfilter.settype('resp')
github FCP-INDI / C-PAC / scripts / cpac_centrality.py View on Github external
help="Number of threads to parallel processes for Intel MKL")

# Output
parser.add_argument('-o', '--outdir', default=os.getcwd(), help="Output directory")



###
# Parse and Read User Args
###

args = parser.parse_args()

try:
    import mkl
    mkl.set_num_threads(args.nthreads)
except ImportError:
    pass

if not args.degree and not args.eigen:
    raise SystemExit("--degree and/or --eigen must be specified")
method_options = [args.degree, args.eigen]

if not args.binarize and not args.weighted:
    raise SystemExit("--binarize and/or --weighted must be specified")
weight_options = [args.binarize, args.weighted]

if args.pvalue is not None:
    option = 0
    threshold = args.pvalue
elif args.sparsity is not None:
    option = 1
github flaviovdf / pyksc / src / scripts / plot_centroids.py View on Github external
def main(tseries_fpath, k, plot_foldpath):
    import mkl
    mkl.set_num_threads(16)

    initialize_matplotlib()
    
    X = np.genfromtxt(tseries_fpath)[:,1:]
    aux = X.sum(axis=1)
    fix = np.where(aux == 0)[0]
    X[fix] += .001 #fixing zero only rows
    X = X.copy()

    cent, assign, shift, dists_cent = ksc.inc_ksc(X, k)
    
    for i in xrange(cent.shape[0]):
        t_series = cent[i]
        
        plt.plot(t_series, '-k')
        plt.gca().get_xaxis().set_visible(False)
github LCAV / FRIDA / figure_doa_synthetic.py View on Github external
# We need to do a bunch of imports
    import pyroomacoustics as pra
    import os
    import numpy as np
    from scipy.io import wavfile
    import mkl as mkl_service

    import doa
    from tools import rfft, polar_error, polar_distance, gen_sig_at_mic_stft, gen_diracs_param

    # initialize local RNG seed
    np.random.seed(seed)

    # for such parallel processing, it is better 
    # to deactivate multithreading in mkl
    mkl_service.set_num_threads(1)

    # number of sources
    K = number_sources

    # Generate "groundtruth" Diracs at random
    alpha_gt, phi_gt, time_stamp = gen_diracs_param(
            K, positive_amp=True, log_normal_amp=False,
            semicircle=False, save_param=False
            )

    # generate complex base-band signal received at microphones
    y_mic_stft, y_mic_stft_noiseless = \
            gen_sig_at_mic_stft(phi_gt, alpha_gt, pmt['mic_array'][:2,:], SNR,
                            pmt['fs'], fft_size=pmt['nfft'], Ns=pmt['num_snapshots'])

    # dict for output
github MattKleinsmith / pbt / main.py View on Github external
from trainer import Trainer
from utils import (update_task, get_max_of_db_column,
                   get_a_task, ExploitationNeeded,
                   LossIsNaN, get_task_ids_and_scores, PopulationFinished,
                   get_col_from_populations, RemainingTasksTaken,
                   print_with_time, ExploitationOcurring,
                   create_new_population)
from config import (get_optimizer, DATA_DIR, MODEL_CLASS, LOSS_FN,
                    HYPERPARAM_NAMES, EPOCHS, BATCH_SIZE, POPULATION_SIZE,
                    EXPLOIT_INTERVAL, USE_SQLITE)


if __name__ == "__main__":
    # TODO: Does this help?
    nproc = mkl.get_max_threads()  # e.g. 12
    mkl.set_num_threads(nproc)

    parser = argparse.ArgumentParser(description="Population Based Training")
    parser.add_argument("-g", "--gpu", type=int, default=0, help="Selects GPU with the given ID. IDs are those shown in nvidia-smi.")  # noqa
    parser.add_argument("-p", "--population_id", type=int, default=None, help="Resumes work on the population with the given ID. Use -1 to select the most recently created population. Without this flag, a new population will be created.")  # noqa
    parser.add_argument("-e", "--exploiter", action="store_true", help="Set this process as the exploiter. It will be responsible for running the exploit step over the entire population at the end of each interval.")  # noqa
    args = parser.parse_args()

    gpu = args.gpu
    population_id = args.population_id
    exploiter = args.exploiter
    inputs = bcolz.open(osp.join(DATA_DIR, "trn_inputs.bcolz"), 'r')
    targets = bcolz.open(osp.join(DATA_DIR, "trn_targets.bcolz"), 'r')
    pathlib.Path('checkpoints').mkdir(exist_ok=True)
    checkpoint_str = "checkpoints/pop-%03d_task-%03d.pth"
    interval_limit = int(np.ceil(EPOCHS / EXPLOIT_INTERVAL))
    table_name = "populations"
github cosmo-epfl / glosim2 / libmatch / chemical_kernel.py View on Github external
def __init__(self, fingerprintsA, fingerprintsB=None, chemicalKernelmat=None, nthreads=4):

        self.dtype = 'float64'
        self.nthreads = nthreads
        try:
            import mkl
            mkl.set_num_threads(self.nthreads)
        except:
            raise Warning('NUMPY DOES NOT SEEM TO BE LINKED TO MKL LIBRARY SO NTHREADS IS IGNORED')

        self.fingerprintsA = fingerprintsA
        self.fingerprints_infoA = self.get_info(fingerprintsA)
        pairsA = self.fingerprints_infoA['pairs']
        Nframe = len(fingerprintsA)
        if fingerprintsB is not None:
            self.fingerprintsB = fingerprintsB
            self.fingerprints_infoB = self.get_info(fingerprintsB)
            pairsB = self.fingerprints_infoB['pairs']
            Mframe = len(fingerprintsB)
        else:
            pairsB = pairsA
            Mframe = Nframe
github Roger-luo / quantum-benchmarks / qiskit / benchmarks.py View on Github external
import pytest
import mkl
import uuid
from numba import cuda
from qiskit import Aer, QuantumCircuit
from qiskit.compiler import transpile, assemble
mkl.set_num_threads(1)

backend = Aer.get_backend("qasm_simulator")
default_options = {
    "method": "statevector",   # Force dense statevector method for benchmarks
    "truncate_enable": False,  # Disable unused qubit truncation for benchmarks
    "max_parallel_threads": 1  # Disable OpenMP parallelization for benchmarks
}

# def _execute(circuit, backend_options=None):
#     experiment = transpile(circuit, backend)
#     qobj = assemble(experiment, shots=1)
#     qobj_aer = backend._format_qobj(qobj, backend_options, None)
#     return backend._controller(qobj_aer)

def _execute(controller, qobj_aer):
    controller(qobj_aer)
github crowsonkb / style_transfer / style_transfer.py View on Github external
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))
github fgnt / pb_chime5 / pb_chime5 / __init__.py View on Github external
from pathlib import Path

import os
os.nice(1)  # be nice

try:
    import mkl  # assume numpy from anaconda
    mkl.set_num_threads(1)
except ModuleNotFoundError:
    pass
os.environ['OMP_NUM_THREADS'] = str(1)  # recommended for HPC systems
os.environ['GOMP_NUM_THREADS'] = str(1)  # recommended for HPC (maybe gnu omp)
os.environ['MKL_NUM_THREADS'] = str(1)
os.environ['NUMEXPR_NUM_THREADS'] = str(1)

git_root = Path(__file__).parent.parent.resolve().expanduser()

from . import (
    activity,

mkl

Intel® oneAPI Math Kernel Library

MPL-2.0
Latest version published 14 days ago

Package Health Score

67 / 100
Full package analysis