Beispiel #1
0
def main(argv=()):
  del argv  # Unused.
  hvd.init()
  #logging.basicConfig(level=logging.ERROR)
  model_class = import_symbol(FLAGS.model_name)
  # Multiply the task number by a value large enough that tasks starting at a
  # similar time cannot end up with the same seed.
  seed = int(time.time() + hvd.rank() * 3600 * 24)
  random.seed(seed)
  if hvd.rank() == 0:
   # logging.basicConfig(level=logging.INFO) # not for tflogging
    logging.set_verbosity(logging.INFO)
   # os.environ['TF_CPP_MIN_LOG_LEVEL'] = '0'
    logging.info('Rank: %d / %d' % (hvd.rank(), hvd.size()))
    logging.info('Random seed: %r', seed)
    logging.info('Learning rate: %r', get_learning_rate(1,FLAGS.batch_size))
    logging.info('Batch size: %d', FLAGS.batch_size)
    try:
      logging.info('Python version: {}'.format(sys.version))
      logging.info('numpy version: {}'.format(np.__version__))
      logging.info('tensorflow version: {}'.format(tf.__version__))
      logging.info('horovod version: {}'.format(hvd.__version__))
      import mkl
      logging.info('MKL: {}'.format(mklstr))
      mklstr = mkl.get_version_string()
    except:
      pass
  train_ffn(model_class, batch_size=FLAGS.batch_size,
            **json.loads(FLAGS.model_args))
Beispiel #2
0
def run(verbosity=1):
    print("sys.prefix: %s" % sys.prefix)
    print("sys.version: %s" % sys.version)
    print("mkl-service version: %r" % mkl.__version__)
    print("MKL version string: %r" % mkl.get_version_string())
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(Test))

    runner = unittest.TextTestRunner(verbosity=verbosity)
    return runner.run(suite)
 def _get_packages(self, pkgs):
     if self.out:
         self.out += '\n'
     packages = pkgs.split(',')
     for p in packages:
         if p == 'mkl':
             try:
                 from mkl import get_version_string
                 s = get_version_string()
                 stringMatch = re.search('Version (.*) Product', s)
                 stringMKL = stringMatch.group(1)
                 self.out += '\n%s %s' %(p, stringMKL)
             except ImportError:
                 self.out += '\n%s %s' %(p, 'No mkl module')
         else:
             self.out += '\n%s %s' %(p, get_distribution(p).version)
Beispiel #4
0
It also checks and stores mandatory additional information, if possible, such
as available RAM or MKL info.

"""
import distutils.sysconfig as sysconfig
import os
import sys

try:
    import psutil
except ImportError:
    psutil = False

try:
    import mkl
    mkl.get_version_string()
except (ImportError, AttributeError):
    mkl = False

try:
    import numexpr
except ImportError:
    numexpr = False

# Get available RAM, if available
if psutil:
    tmem = psutil.virtual_memory().total
    TOTAL_RAM = '{:.1f} GiB'.format(tmem / (1024.0**3))
else:
    TOTAL_RAM = False
Beispiel #5
0
import mkl
import mkl.test

for s in ('mkl.get_max_threads()', 'mkl.get_cpu_clocks()', 'mkl.mem_stat()',
          'mkl.get_cpu_frequency()', 'mkl.get_version_string()'):
    print('%s=%r' % (s, eval(s)))

assert mkl.test.run().wasSuccessful()
assert 'Math Kernel Library Version 20' in mkl.get_version_string()
print(mkl.__version__)
assert mkl.__version__ == '2.3.0'
Beispiel #6
0
# Since it's not on PyPi I don't want to make this an actual package dependency
# So without it just create mock functions and don't do version checking
try:
    from mkl import get_version, get_version_string
except ImportError:

    def get_version():
        return None

    def get_version_string():
        return None


if get_version() is not None and get_version()["MajorVersion"] < 2020:
    msg = "Loaded version of MKL is out of date: {v}".format(
        v=get_version_string())
    warnings.warn(msg)

import numpy as np
import scipy.sparse as _spsparse
from numpy.ctypeslib import ndpointer, as_array

NUMPY_FLOAT_DTYPES = [np.float32, np.float64]


class MKL:
    """ This class holds shared object references to C functions with arg and returntypes that can be adjusted"""

    MKL_INT = None
    MKL_INT_NUMPY = None
Beispiel #7
0
def get_mkl_version():
    try:
        import mkl
        return mkl.get_version_string()
    except ImportError:
        return getattr(numpy, "__mkl_version__", "none")
Beispiel #8
0
import numpy
import numpy.fft as fft
numpy.use_fastnumpy = True
import time
#from scipy.fftpack import fft
import mkl

print 'Intel MKL version:', mkl.get_version_string()
print 'Intel cpu_clocks:', mkl.get_cpu_clocks()
print 'Intel cpu_frequency:', mkl.get_cpu_frequency()
#print 'Intel MKL, freeing buffer memory:', mkl.thread_free_buffers()

print 'max Intel threads:', mkl.get_max_threads()

mkl.set_num_threads(2)

N = 2**16

print 'using numpy', numpy.__version__
a = numpy.random.rand(2, N)
print a.shape, 'items'
t0 = time.clock()
for i in range(100):
    continue
base = time.clock()-t0
fftn = fft.fftn
t0 = time.clock()
for i in range(100):
    r = fftn(a, (N,), (1,))
print 'simple loop', time.clock()-t0-base
Beispiel #9
0
try:
    import ipywidgets
except ImportError:
    ipywidgets = False
try:
    import numexpr
except ImportError:
    numexpr = False
try:
    import mkl
except ImportError:
    mkl = False

# Get mkl info from numexpr or mkl, if available
if mkl:
    mklinfo = mkl.get_version_string()
elif numexpr:
    mklinfo = numexpr.get_vml_version()
else:
    mklinfo = False


class Versions:
    """Print date, time, and version information.

    Print date, time, and package version information in any environment
    (Jupyter notebook, IPython console, Python console, QT console), either as
    html-table (notebook) or as plain text (anywhere).

    Always shown are the OS, number of CPU(s), ``numpy``, ``scipy``,
    ``SimPEG``, ``cython``, ``properties``, ``vectormath``, ``discretize``,
Beispiel #10
0
def get_mkl_version():
    try:
        import mkl
        return mkl.get_version_string()
    except ImportError:
        return getattr(numpy, "__mkl_version__", "none")
# Use mkl-service to check version if it's installed
# Since it's not on PyPi I don't want to make this an actual package dependency
# So without it just create mock functions and don't do version checking
try:
    from mkl import get_version, get_version_string
except ImportError:
    def get_version():
        return None


    def get_version_string():
        return None

if get_version() is not None and get_version()["MajorVersion"] < 2020:
    _verr_msg = "Loaded version of MKL is out of date: {v}".format(v=get_version_string())
    warnings.warn(_verr_msg)

import numpy as np
import scipy.sparse as _spsparse
from numpy.ctypeslib import ndpointer, as_array

NUMPY_FLOAT_DTYPES = [np.float32, np.float64]


class MKL:
    """ This class holds shared object references to C functions with arg and returntypes that can be adjusted"""

    MKL_INT = None
    MKL_INT_NUMPY = None
Beispiel #12
0
 def test_get_version_string(self):
     v = mkl.get_version_string()
     assert (isinstance(v, six.string_types))
     assert ('Math Kernel Library' in v)
Beispiel #13
0
        if mkl.enable_instructions(instructions_set) == 'success':
            result = instructions_set
            break
    else:
        result = 'error'

    return result


def is_max_supported_instructions_set(instructions_set):
    result = False
    if re.search(instructions_set.replace('4_2', '4.2'),
                 mkl.get_version()['Processor'].decode(), re.IGNORECASE):
        result = True

    return result


if __name__ == '__main__':
    time_begin = mkl.dsecnd()
    print(mkl.get_version_string())

    instructions_set = enable_best_instructions_set()
    print('Enable snstructions set: ' + str(instructions_set))

    is_max = is_max_supported_instructions_set(instructions_set)
    print('Is the best supported instructions set: ' + str(is_max))

    time_end = mkl.dsecnd()
    print('Execution time: ' + str(time_end - time_begin))
import mkl
import mkl.test

for s in ('mkl.get_max_threads()', 'mkl.get_cpu_clocks()', 'mkl.mem_stat()',
          'mkl.get_cpu_frequency()', 'mkl.get_version_string()'):
    print('%s=%r' % (s, eval(s)))

assert mkl.test.run().wasSuccessful()
assert 'Math Kernel Library Version 11.3.3 ' in mkl.get_version_string()
assert mkl.__version__ == '1.1.2'