def __enter__(self): try: mkl.domain_set_num_threads(self.n_threads, domain='fft') except: raise ValueError( "Class argument {} result in invalid number of threads {}". format(self.workers, self.n_threads))
def test_domain_set_num_threads_blas(self): saved_blas_nt = mkl.domain_get_max_threads(domain='blas') saved_fft_nt = mkl.domain_get_max_threads(domain='fft') saved_vml_nt = mkl.domain_get_max_threads(domain='vml') # set blas_nt = int((3 + saved_blas_nt) / 4) fft_nt = int((3 + 2 * saved_fft_nt) / 4) vml_nt = int((3 + 3 * saved_vml_nt) / 4) status = mkl.domain_set_num_threads(blas_nt, domain='blas') assert (status == 'success') status = mkl.domain_set_num_threads(fft_nt, domain='fft') assert (status == 'success') status = mkl.domain_set_num_threads(vml_nt, domain='vml') assert (status == 'success') # check assert (mkl.domain_get_max_threads(domain='blas') == blas_nt) assert (mkl.domain_get_max_threads(domain='fft') == fft_nt) assert (mkl.domain_get_max_threads(domain='vml') == vml_nt) # restore status = mkl.domain_set_num_threads(saved_blas_nt, domain='blas') assert (status == 'success') status = mkl.domain_set_num_threads(saved_fft_nt, domain='fft') assert (status == 'success') status = mkl.domain_set_num_threads(saved_vml_nt, domain='vml') assert (status == 'success')
if _mklinc: _incs.extend(_mklinc) _pyx.install(setup_args={'include_dirs': _incs}, language_level=2) except Exception as e: _w.warn("no mkl autocorrelation") from . import ft # noqa # cuda _cuda = _nbcuda.is_available() if _cuda: try: from . import cucor, cucorrad, cusimple simple = cusimple qcor = cucor qcorrad = cucorrad except Exception as e: print(e) _cuda = False if not _cuda: _w.warn("no cuda available") simple = cpusimple qcor = cpucor qcorrad = cpucorrad if _mkl is not None: _mkl.domain_set_num_threads(_vml_threads, 'vml') # numexpr messes with vml thread number
def __exit__(self, *args): # restore default n_threads = _hardware_counts.get_max_threads_count() mkl.domain_set_num_threads(n_threads, domain='fft')
""" Face detection Creating New Python 3.6 environment conda create -n face python=3.6 """ #import tomopy import mkl mkl.domain_set_num_threads(1, domain='fft') # Intel(R) MKL FFT functions to run sequentially import cv2 import os from time import sleep import numpy as np import argparse from wide_resnet import WideResNet from keras.utils.data_utils import get_file import os, random class FaceCV(object): """ Singleton class for face recongnition task """ CASE_PATH = ".\\pretrained_models\\haarcascade_frontalface_alt.xml" WRN_WEIGHTS_PATH = ".\\pretrained_models\\weights.18-4.06.hdf5" def __new__(cls, weight_file=None, depth=16, width=8, face_size=64): if not hasattr(cls, 'instance'):
def test_domain_set_num_threads_all(self): status = mkl.domain_set_num_threads(4, domain='all') assert (status == 'success')
def test_domain_set_num_threads_pardiso(self): status = mkl.domain_set_num_threads(4, domain='pardiso') assert (status == 'success')