コード例 #1
0
 def try_flags(flag_list,
               preambule="",
               body="",
               try_run=False,
               output=False):
     return Compiler._try_flags(flag_list, preambule, body, try_run, output,
                                nvcc_path)
コード例 #2
0
 def try_compile_tmp(src_code,
                     tmp_prefix='',
                     flags=(),
                     try_run=False,
                     output=False):
     return Compiler._try_compile_tmp(src_code, tmp_prefix, flags, try_run,
                                      output, nvcc_path)
コード例 #3
0
ファイル: nvcc_compiler.py プロジェクト: naisanza/Theano
 def try_flags(flag_list, preambule="", body="", try_run=False, output=False):
     return Compiler._try_flags(flag_list, preambule, body, try_run, output, nvcc_path)
コード例 #4
0
ファイル: nvcc_compiler.py プロジェクト: naisanza/Theano
 def try_compile_tmp(src_code, tmp_prefix="", flags=(), try_run=False, output=False):
     return Compiler._try_compile_tmp(src_code, tmp_prefix, flags, try_run, output, nvcc_path)
コード例 #5
0
ファイル: __init__.py プロジェクト: intel/theano
def mkl_available():
    if config.device != "cpu":
        mkl_available.avail = False
        mkl_available.msg = "MKL is disabled since device is not CPU. " \
                            "Set the device to 'CPU' if you want to use MKL."
        return mkl_available.avail

    if config.mkl.lib != "mkl":
        raise NotImplementedError("MKL lib only supports 'mkl', got %s." % config.mkl.lib)

    if config.mkl.nn.enabled == "False":
        mkl_available.avail = False
        mkl_available.msg = "MKL is disabled by the 'mkl.nn.enabled' setting."
        return mkl_available.avail
    elif mkl_available.avail is not True:
        preambule = """
            #include <stdio.h>
         """
        preambule += textwrap.dedent(header_text())

        body = textwrap.dedent(
            """
            dnnError_t err;
            dnnLayout_t usr_layout = NULL;
            size_t size[1] = {256};
            size_t stride[1] = {1};

            if ((err = dnnLayoutCreate_F32(&usr_layout, 1, size, stride)) != E_SUCCESS) {
                fprintf(stderr, "Failed to create user layout with mkl: %s", err);
                return (-1);
            }
            """)
        if 'mklml_intel' in config.blas.ldflags:
            params = ['-l', 'mklml_intel']
        else:
            params = ['-l', 'mkl_rt']

        comp, out, err = Compiler._try_flags(
            flag_list=params, preambule=preambule, body=body,
            try_run=False, output=True, compiler=theano.config.cxx, comp_args=False)

        mkl_available.avail = comp
        if mkl_available.avail is False:
            mkl_available.msg = (
                "Can not compile with MKL. We got this error: " +
                str(err))
        else:
            # If we can compile, check that we can import and run.
            v = theano.function([], MKLVersion()(),
                                theano.Mode(optimizer=None),
                                profile=False)()
            if not isinstance(v, integer_types):
                mkl_available.avail = False
                mkl_available.msg = ("Got incorrect mkl version format")
                raise RuntimeError(mkl_available.msg)
            if v == -1 or v < 20160802:
                mkl_available.avail = False
                mkl_available.msg = "Version(%d) is too old, please use the version of %d or newer one." % (v, int(20160802))
                raise RuntimeError(mkl_available.msg)
            else:
                mkl_available.avail = comp

    if config.mkl.nn.enabled == "True":
        if not mkl_available.avail:
            raise RuntimeError(
                "You enabled MKL, but we aren't able to use it, %s" % mkl_available.msg)
    return mkl_available.avail
コード例 #6
0
ファイル: __init__.py プロジェクト: YanzhaoWu/Theano-1
def mkl_available():
    if config.device != "cpu":
        mkl_available.avail = False
        mkl_available.msg = "MKL is disabled since device is not CPU. " \
                            "Set the device to 'CPU' if you want to use MKL."
        return mkl_available.avail

    if config.mkl.lib != "mkl":
        raise NotImplementedError("MKL lib only supports 'mkl', got %s." %
                                  config.mkl.lib)

    if config.mkl.nn.enabled == "False":
        mkl_available.avail = False
        mkl_available.msg = "MKL is disabled by the 'mkl.nn.enabled' setting."
        return mkl_available.avail
    elif mkl_available.avail is not True:
        preambule = """
            #include <stdio.h>
         """
        preambule += textwrap.dedent(header_text())

        body = textwrap.dedent("""
            dnnError_t err;
            dnnLayout_t usr_layout = NULL;
            size_t size[1] = {256};
            size_t stride[1] = {1};

            if ((err = dnnLayoutCreate_F32(&usr_layout, 1, size, stride)) != E_SUCCESS) {
                fprintf(stderr, "Failed to create user layout with mkl: %s", err);
                return (-1);
            }
            """)
        if 'mklml_intel' in config.blas.ldflags:
            params = ['-l', 'mklml_intel']
        else:
            params = ['-l', 'mkl_rt']

        comp, out, err = Compiler._try_flags(flag_list=params,
                                             preambule=preambule,
                                             body=body,
                                             try_run=False,
                                             output=True,
                                             compiler=theano.config.cxx,
                                             comp_args=False)

        mkl_available.avail = comp
        if mkl_available.avail is False:
            mkl_available.msg = (
                "Can not compile with MKL. We got this error: " + str(err))
        else:
            # If we can compile, check that we can import and run.
            v = theano.function([],
                                MKLVersion()(),
                                theano.Mode(optimizer=None),
                                profile=False)()
            if not isinstance(v, integer_types):
                mkl_available.avail = False
                mkl_available.msg = ("Got incorrect mkl version format")
                raise RuntimeError(mkl_available.msg)
            if v == -1 or v < 20160802:
                mkl_available.avail = False
                mkl_available.msg = "Version(%d) is too old, please use the version of %d or newer one." % (
                    v, int(20160802))
                raise RuntimeError(mkl_available.msg)
            else:
                mkl_available.avail = comp

    if config.mkl.nn.enabled == "True":
        if not mkl_available.avail:
            raise RuntimeError(
                "You enabled MKL, but we aren't able to use it, %s" %
                mkl_available.msg)
    return mkl_available.avail