Theano / PyMC3 Dot产品错误(潜在的DGEMM失败)

时间:2018-03-11 15:28:36

标签: theano pymc3

我正在尝试使用带有pymc3的theano来制作如图所示的模型

from scipy import stats

N = 100
height = stats.norm.rvs(size=N, loc=10, scale=2)
leg_prop = stats.uniform.rvs(size=N, loc=0.4, scale=0.5) 
leg_left = leg_prop * height + stats.norm.rvs(size=N, loc=0, scale=0.02)
leg_right = leg_prop * height + stats.norm.rvs(size=N, loc=0, scale=0.02)

import matplotlib.pyplot as plt
import pymc3 as pm
import numpy as np
%matplotlib inline

leg_length = np.array([leg_left, leg_right])
leg_mean = leg_length.mean()
print leg_length.mean()
with pm.Model() as model_mvlr:
    alpha_centered = pm.Normal('alpha_centered', mu=0, sd=10)
    beta = pm.Normal('beta', mu=0, sd=1, shape=2)
    epsilon = pm.HalfCauchy('epsilon', 5)

    mu = alpha_centered+pm.math.dot(beta, leg_length)
    alpha = pm.Deterministic('alpha', alpha_centered-pm.math.dot(beta, leg_mean))

    height_pred = pm.Normal('height_pred', mu=mu, sd=epsilon, observed=height)

    trace_height = pm.sample(size=5000, njobs=1)

我得到下面的错误,似乎从我可以收集的dgemm实现有问题,让我认为pm.dot调用是罪魁祸首。我需要使用这个电话,所以任何关于如何解决这个问题的建议都会非常感激。

这是(相当长的)错误:

You can find the C code in this temporary file: c:\users\notle_~1\appdata\local\temp\theano_compilation_error_i_ayvf
Exception Traceback (most recent call last)
in ()
17 height_pred = pm.Normal('height_pred', mu=mu, sd=epsilon, observed=height)
18
---> 19 trace_height = pm.sample(size=5000, njobs=1)

C:\Users\notle_000\Anaconda2\lib\site-packages\pymc3\sampling.pyc in sample(draws, step, init, n_init, start, trace, chain_idx, chains, njobs, tune, nuts_kwargs, step_kwargs, progressbar, model, random_seed, live_plot, discard_tuned_samples, live_plot_kwargs, compute_convergence_checks, **kwargs)
371 start_, step = init_nuts(init=init, chains=chains, n_init=n_init,
372 model=model, random_seed=random_seed,
--> 373 progressbar=progressbar, **args)
374 if start is None:
375 start = start_

C:\Users\notle_000\Anaconda2\lib\site-packages\pymc3\sampling.pyc in init_nuts(init, chains, n_init, model, random_seed, progressbar, **kwargs)
1352 'Unknown initializer: {}.'.format(init))
1353
-> 1354 step = pm.NUTS(potential=potential, model=model, **kwargs)
1355
1356 return start, step

C:\Users\notle_000\Anaconda2\lib\site-packages\pymc3\step_methods\hmc\nuts.pyc in init(self, vars, max_treedepth, early_max_treedepth, **kwargs)
150 pm.sample to the desired number of tuning steps.
151 """
--> 152 super(NUTS, self).init(vars, **kwargs)
153
154 self.max_treedepth = max_treedepth

C:\Users\notle_000\Anaconda2\lib\site-packages\pymc3\step_methods\hmc\base_hmc.pyc in init(self, vars, scaling, step_scale, is_cov, model, blocked, potential, integrator, dtype, Emax, target_accept, gamma, k, t0, adapt_step_size, step_rand, **theano_kwargs)
61
62 super(BaseHMC, self).init(vars, blocked=blocked, model=model,
---> 63 dtype=dtype, **theano_kwargs)
64
65 self.adapt_step_size = adapt_step_size

C:\Users\notle_000\Anaconda2\lib\site-packages\pymc3\step_methods\arraystep.pyc in init(self, vars, model, blocked, dtype, **theano_kwargs)
213
214 self._logp_dlogp_func = model.logp_dlogp_function(
--> 215 vars, dtype=dtype, **theano_kwargs)
216
217 def step(self, point):

C:\Users\notle_000\Anaconda2\lib\site-packages\pymc3\model.pyc in logp_dlogp_function(self, grad_vars, **kwargs)
656 varnames = [var.name for var in grad_vars]
657 extra_vars = [var for var in self.free_RVs if var.name not in varnames]
--> 658 return ValueGradFunction(self.logpt, grad_vars, extra_vars, **kwargs)
659
660 @property

C:\Users\notle_000\Anaconda2\lib\site-packages\pymc3\model.pyc in init(self, cost, grad_vars, extra_vars, dtype, casting, **kwargs)
403
404 self._theano_function = theano.function(
--> 405 inputs, [self._cost_joined, grad], givens=givens, **kwargs)
406
407 def set_extra_values(self, extra_vars):

C:\Users\notle_000\Anaconda2\lib\site-packages\theano\compile\function.pyc in function(inputs, outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, allow_input_downcast, profile, on_unused_input)
315 on_unused_input=on_unused_input,
316 profile=profile,
--> 317 output_keys=output_keys)
318 return fn

C:\Users\notle_000\Anaconda2\lib\site-packages\theano\compile\pfunc.pyc in pfunc(params, outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, allow_input_downcast, profile, on_unused_input, output_keys)
484 accept_inplace=accept_inplace, name=name,
485 profile=profile, on_unused_input=on_unused_input,
--> 486 output_keys=output_keys)
487
488

C:\Users\notle_000\Anaconda2\lib\site-packages\theano\compile\function_module.pyc in orig_function(inputs, outputs, mode, accept_inplace, name, profile, on_unused_input, output_keys)
1839 name=name)
1840 with theano.change_flags(compute_test_value="off"):
-> 1841 fn = m.create(defaults)
1842 finally:
1843 t2 = time.time()

C:\Users\notle_000\Anaconda2\lib\site-packages\theano\compile\function_module.pyc in create(self, input_storage, trustme, storage_map)
1713 theano.config.traceback.limit = theano.config.traceback.compile_limit
1714 _fn, _i, _o = self.linker.make_thunk(
-> 1715 input_storage=input_storage_lists, storage_map=storage_map)
1716 finally:
1717 theano.config.traceback.limit = limit_orig

C:\Users\notle_000\Anaconda2\lib\site-packages\theano\gof\link.pyc in make_thunk(self, input_storage, output_storage, storage_map)
697 return self.make_all(input_storage=input_storage,
698 output_storage=output_storage,
--> 699 storage_map=storage_map)[:3]
700
701 def make_all(self, input_storage, output_storage):

C:\Users\notle_000\Anaconda2\lib\site-packages\theano\gof\vm.pyc in make_all(self, profiler, input_storage, output_storage, storage_map)
1082 compute_map,
1083 [],
-> 1084 impl=impl))
1085 linker_make_thunk_time[node] = time.time() - thunk_start
1086 if not hasattr(thunks[-1], 'lazy'):

C:\Users\notle_000\Anaconda2\lib\site-packages\theano\gof\op.pyc in make_thunk(self, node, storage_map, compute_map, no_recycling, impl)
953 try:
954 return self.make_c_thunk(node, storage_map, compute_map,
--> 955 no_recycling)
956 except (NotImplementedError, utils.MethodNotDefined):
957 # We requested the c code, so don't catch the error.

C:\Users\notle_000\Anaconda2\lib\site-packages\theano\gof\op.pyc in make_c_thunk(self, node, storage_map, compute_map, no_recycling)
856 _logger.debug('Trying CLinker.make_thunk')
857 outputs = cl.make_thunk(input_storage=node_input_storage,
--> 858 output_storage=node_output_storage)
859 thunk, node_input_filters, node_output_filters = outputs
860

C:\Users\notle_000\Anaconda2\lib\site-packages\theano\gof\cc.pyc in make_thunk(self, input_storage, output_storage, storage_map, keep_lock)
1215 cthunk, module, in_storage, out_storage, error_storage = self.compile(
1216 input_storage, output_storage, storage_map,
-> 1217 keep_lock=keep_lock)
1218
1219 res = _CThunk(cthunk, init_tasks, tasks, error_storage, module)

C:\Users\notle_000\Anaconda2\lib\site-packages\theano\gof\cc.pyc in compile(self, input_storage, output_storage, storage_map, keep_lock)
1155 output_storage,
1156 storage_map,
-> 1157 keep_lock=keep_lock)
1158 return (thunk,
1159 module,

C:\Users\notle_000\Anaconda2\lib\site-packages\theano\gof\cc.pyc in cthunk_factory(self, error_storage, in_storage, out_storage, storage_map, keep_lock)
1618 node.op.prepare_node(node, storage_map, None, 'c')
1619 module = get_module_cache().module_from_key(
-> 1620 key=key, lnk=self, keep_lock=keep_lock)
1621
1622 vars = self.inputs + self.outputs + self.orphans

C:\Users\notle_000\Anaconda2\lib\site-packages\theano\gof\cmodule.pyc in module_from_key(self, key, lnk, keep_lock)
1172 try:
1173 location = dlimport_workdir(self.dirname)
-> 1174 module = lnk.compile_cmodule(location)
1175 name = module.file
1176 assert name.startswith(location)

C:\Users\notle_000\Anaconda2\lib\site-packages\theano\gof\cc.pyc in compile_cmodule(self, location)
1521 lib_dirs=self.lib_dirs(),
1522 libs=libs,
-> 1523 preargs=preargs)
1524 except Exception as e:
1525 e.args += (str(self.fgraph),)

C:\Users\notle_000\Anaconda2\lib\site-packages\theano\gof\cmodule.pyc in compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module, hide_symbols)
2357 # difficult to read.
2358 raise Exception('Compilation failed (return status=%s): %s' %
-> 2359 (status, compile_stderr.replace('\n', '. ')))
2360 elif config.cmodule.compilation_warning and compile_stderr:
2361 # Print errors just below the command line.

例外:('编译节点时出现以下错误',CGemv {inplace}(AllocEmpty {dtype =' float64'}。0,TensorConstant {1.0},TensorConstant { [[8.40619..90000243]]},beta,TensorConstant {0.0}),' \ n',"编译失败(返回状态= 1):C:\ Users \ NOTLE_~1 \应用程序数据\本地\ TEMP \ cc6eSkXb.o:在功能运行':\ R C:/Users/notle_000/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.12-64/tmppb73ml。 /mod.cpp:1261:未定义参考todgemv _' \ R C:/Users/notle_000/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.12-64/tmppb73ml/mod.cpp :1233:未定义参照sgemv _' \ R C:/Users/notle_000/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.12-64/tmppb73ml/mod.cpp:1224: undefined reference tosdot _' \ r.C:/ Users / notle_000 / AppData / Local / Theano / compiledir_Windows-10-10 .0.16299-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.12-64 / tmppb73ml / mod.cpp:1190:对dgemv _' \ r \ n的未定义引用。 C:/Users/notle_000/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.12-64/tmppb73ml/mod.cpp:1252:未定义参考toddot _' \ r。 C:/Users/notle_000/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.12-64/tmppb73ml/mod.cpp:1180:未定义参考`sgemv _' \ r。 collect2.exe:错误:ld返回1退出状态\ r \ n。 ",' [CGemv {inplace}(,TensorConstant {1.0},TensorConstant {[[8.40619..90000243]]},beta,TensorConstant {0.0})]')

0 个答案:

没有答案