在Windows 10上使用PYMC3 - theano无法导入名称'floatX'

时间:2017-03-10 22:35:40

标签: python theano pymc3

我很难让PYMC3在Windows上正确安装。我已尝试通过conda install -c conda-forge pymc3使用Anaconda软件包,并根据文档使用仅使用pip的virtualenv。

似乎安装好,但在运行import pymc3时出现以下错误则失败。研究表明可能存在一些错过的依赖性。

    >>> import pymc3
WARNING (theano.sandbox.cuda): The cuda backend is deprecated and will be removed in the next release (v0.10).  Please switch to the gpuarray backend. You can get more information about how to switch at this URL:
 https://github.com/Theano/Theano/wiki/Converting-to-the-new-gpu-back-end%28gpuarray%29

ERROR (theano.sandbox.cuda): nvcc compiler not found on $PATH. Check your nvcc installation and try again.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\peter\Anaconda3\lib\site-packages\pymc3\__init__.py", line 8, in <module>
    from .sampling import *
  File "C:\Users\peter\Anaconda3\lib\site-packages\pymc3\sampling.py", line 11, in <module>
    from .step_methods import (NUTS, HamiltonianMC, Metropolis, BinaryMetropolis,
  File "C:\Users\peter\Anaconda3\lib\site-packages\pymc3\step_methods\__init__.py", line 3, in <module>
    from .hmc import HamiltonianMC
  File "C:\Users\peter\Anaconda3\lib\site-packages\pymc3\step_methods\hmc\__init__.py", line 1, in <module>
    from .hmc import HamiltonianMC
  File "C:\Users\peter\Anaconda3\lib\site-packages\pymc3\step_methods\hmc\hmc.py", line 7, in <module>
    from .base_hmc import BaseHMC
  File "C:\Users\peter\Anaconda3\lib\site-packages\pymc3\step_methods\hmc\base_hmc.py", line 2, in <module>
    from .trajectory import get_theano_hamiltonian_functions
  File "C:\Users\peter\Anaconda3\lib\site-packages\pymc3\step_methods\hmc\trajectory.py", line 3, in <module>
    from pymc3.theanof import join_nonshared_inputs, gradient, CallableTensor, floatX
ImportError: cannot import name 'floatX'

我找不到关于这个floatx包的内容。

似乎是一个windows的东西 - 因为它在我的旧Ubuntu盒子上安装并运行没有问题(使用anaconda)。

感激不尽的任何帮助!

编辑:更近一步。由于某种原因,我有nvcc编译器的路径错误。因此,如果您在环境路径中进行相同的检查,那么您将拥有包含“\ bin”的完整路径。如果您进行了更改,请不要忘记重新启动。

现在我收到一个错误:

    >>> import pymc3
WARNING (theano.sandbox.cuda): The cuda backend is deprecated and will be removed in the next release (v0.10).  Please switch to the gpuarray backend. You can get more information about how to switch at this URL:
 https://github.com/Theano/Theano/wiki/Converting-to-the-new-gpu-back-end%28gpuarray%29

Using gpu device 0: GeForce GTX 960M (CNMeM is disabled, cuDNN not available)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\peter\Anaconda3\lib\site-packages\pymc3\__init__.py", line 4, in <module>
    from .distributions import *
  File "C:\Users\peter\Anaconda3\lib\site-packages\pymc3\distributions\__init__.py", line 1, in <module>
    from . import timeseries
  File "C:\Users\peter\Anaconda3\lib\site-packages\pymc3\distributions\timeseries.py", line 1, in <module>
    import theano.tensor as tt
  File "C:\Users\peter\Anaconda3\lib\site-packages\theano\__init__.py", line 116, in <module>
    theano.sandbox.cuda.tests.test_driver.test_nvidia_driver1()
  File "C:\Users\peter\Anaconda3\lib\site-packages\theano\sandbox\cuda\tests\test_driver.py", line 32, in test_nvidia_driver1
    profile=False)
  File "C:\Users\peter\Anaconda3\lib\site-packages\theano\compile\function.py", line 326, in function
    output_keys=output_keys)
  File "C:\Users\peter\Anaconda3\lib\site-packages\theano\compile\pfunc.py", line 486, in pfunc
    output_keys=output_keys)
  File "C:\Users\peter\Anaconda3\lib\site-packages\theano\compile\function_module.py", line 1795, in orig_function
    defaults)
  File "C:\Users\peter\Anaconda3\lib\site-packages\theano\compile\function_module.py", line 1661, in create
    input_storage=input_storage_lists, storage_map=storage_map)
  File "C:\Users\peter\Anaconda3\lib\site-packages\theano\gof\link.py", line 699, in make_thunk
    storage_map=storage_map)[:3]
  File "C:\Users\peter\Anaconda3\lib\site-packages\theano\gof\vm.py", line 1098, in make_all
    self.updated_vars,
  File "C:\Users\peter\Anaconda3\lib\site-packages\theano\gof\vm.py", line 952, in make_vm
    vm = CVM(
NameError: name 'CVM' is not defined
>>>

我在这里修改了最后一篇文章:https://groups.google.com/forum/#!msg/theano-users/JoTu61_MTLk/4ZzsVyaOf2kJ。但现在陷入了错误:

>>> import pymc3
Traceback (most recent call last):
  File "C:\Users\peter\Anaconda3\lib\site-packages\theano\gof\cutils.py", line 306, in <module>
    from cutils_ext.cutils_ext import *  # noqa
ImportError: No module named 'cutils_ext.cutils_ext'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\peter\Anaconda3\lib\site-packages\theano\gof\cutils.py", line 317, in <module>
    from cutils_ext.cutils_ext import *  # noqa
ImportError: No module named 'cutils_ext.cutils_ext'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\peter\Anaconda3\lib\site-packages\pymc3\__init__.py", line 4, in <module>
    from .distributions import *
  File "C:\Users\peter\Anaconda3\lib\site-packages\pymc3\distributions\__init__.py", line 1, in <module>
    from . import timeseries
  File "C:\Users\peter\Anaconda3\lib\site-packages\pymc3\distributions\timeseries.py", line 1, in <module>
    import theano.tensor as tt
  File "C:\Users\peter\Anaconda3\lib\site-packages\theano\__init__.py", line 80, in <module>
    from theano.scan_module import (scan, map, reduce, foldl, foldr, clone,
  File "C:\Users\peter\Anaconda3\lib\site-packages\theano\scan_module\__init__.py", line 41, in <module>
    from theano.scan_module import scan_opt
  File "C:\Users\peter\Anaconda3\lib\site-packages\theano\scan_module\scan_opt.py", line 60, in <module>
    from theano import tensor, scalar
  File "C:\Users\peter\Anaconda3\lib\site-packages\theano\tensor\__init__.py", line 9, in <module>
    from theano.tensor.subtensor import *
  File "C:\Users\peter\Anaconda3\lib\site-packages\theano\tensor\subtensor.py", line 26, in <module>
    import theano.gof.cutils  # needed to import cutils_ext
  File "C:\Users\peter\Anaconda3\lib\site-packages\theano\gof\cutils.py", line 320, in <module>
    compile_cutils()
  File "C:\Users\peter\Anaconda3\lib\site-packages\theano\gof\cutils.py", line 285, in compile_cutils
    preargs=args)
  File "C:\Users\peter\Anaconda3\lib\site-packages\theano\gof\cmodule.py", line 2313, in compile_str
    return dlimport(lib_filename)
  File "C:\Users\peter\Anaconda3\lib\site-packages\theano\gof\cmodule.py", line 302, in dlimport
    rval = __import__(module_name, {}, {}, [module_name])
ImportError: DLL load failed: The specified procedure could not be found.
>>>

调查继续进行!也许现在是时候把窗口移到Linux全职了!

EDIT2:我切换到python 2.7环境,似乎工作正常。不得不安装http://mingw.org/但是之后一切都好。

很高兴让它在3.6中工作。有谁想?

1 个答案:

答案 0 :(得分:3)

好的,我设法凑齐安装。

我使用conda install -c conda-forge pymc3对依赖管理等没有好运,我无法确定编译器的位置/路径是否存在问题等等。所以我从一开始就重新安装了

我去了Anaconda3(而不是2),它运行良好。

1)我按照https://github.com/philferriere/dlwin的环境设置进行操作,直到我开始安装Theano。但是,我建议使用https://github.com/nouiz建议的最新conda install -c rdonnelly Theano而不是我建议的版本。这是一个很好的固体环境设置 - 我真的推荐使用msys工具 - 我之前没有使用它。

philferriere指南中的测试脚本是测试功能/性能的好方法。

2)然后我使用pip install pymc3设置pymc3,因为他们在这里建议https://github.com/pymc-devs/pymc3。但不是git上的最新版本。

希望有人觉得这很有用。

参考文献: https://github.com/Theano/Theano/issues/5348