首页 文章

如何在Anaconda ver中安装theano . 2.1适用于Python 3.4的Windows 64位?

提问于
浏览
5

我安装了Anaconda . 现在我想在Anaconda中安装Theano库 . 我试过了:

Theano error message

我甚至安装了Python ver . 3.4,使用pip install安装Theano,当我尝试导入Theano时,它给出了类似于屏幕截图中的错误的错误 . 我尝试了这个Google Groups讨论中提到的变化,但是没有运气 .

3 回答

  • 1

    在Python 3.4上运行Theano很复杂 . 到目前为止,我建议你在Python 2.7中运行Theano . 为Theano编写的库是基于Python 2.6的 . 因此,为了让Theano在Python 3.4中运行,您将需要2to3自动python 2到3代码转换工具 . 我没有使用2to3测试Theano,所以我不能评论它是否会起作用 . 但是,我正在使用Python 2.7并且Theano工作顺利 . 此外,您可能希望将AnacondaCE与Python 2.7安装程序一起使用,它几乎为您提供了开始开发所需的一切 .

    您还需要重新安装Theano

    pip install Theano
    
  • 1

    我们可以看到,你试图在Windows下使用Theano . 请确保您有一个MinGW编译器 . 此外,确保您有MinGW和libpython包 .

    一般来说,我建议使用答案How do I install Keras and Theano in Anaconda Python 2.7 on Windows?,但没有最后一步 .

  • 2

    主持人请注意:这不是重复的帖子 . 我的所有其他帖子都被删除了,所以我将这个帖子留在这里,并将其他问题标记为重复 .

    我无法使用带有Python 3.4的Anaconda进行Theano的工作安装,而且我也无法使用MinGW进行手动安装,但我能够使用WinPython 3.4完美地运行它 .

    Theano Installation and Configuration on Windows 10 with GPU Acceleration and Python 3.4

    如果您使用的是Windows,那么安装和配置Theano可能会非常棘手 . 通过以下教程的组合,我能够使它工作:

    Easier configuration of Theano with Python 3.4 using WinPython instead of Anaconda Python

    使用WinPython而不是Anaconda Python时,让Theano在Python 3.4上运行要容易得多,但WinPython将环境设置存储在其设置目录中(例如 C:\SciSoft\WinPython-64bit-3.4.4.2\settings\.keras\ ),而不是在你想要它时查看你的 %USERPROFILE% 中的keras.json文件选择您的环境设置(如设置指南中所述) . 此外,如果您仍然遇到问题,可能只需要将 THEANO_FLAGS 系统环境变量设置为如下所示: floatX=float32,device=gpu,nvcc.fastmath=True,lib.cnmem=0.8,blas.ldflags=-LC:\src\OpenBLAS -lopenblas . (请注意,此环境变量会覆盖任何.theanorc安装文件中的设置,如详细here in the Theano configuration documentation,除非使用WinPython,.theanorc文件将进入 C:\SciSoft\WinPython-64bit-3.4.4.2\settings\.theanorc 而不是 %USERPROFILE\.theanorc . )

    使用WinPython安装Theano时,如果使用建议的Theano安装位置( C:\SciSoft\ ),安装会更容易 . 在这种情况下,您的安装目录应如下所示:

    Picture of SciSoft installation directory

    Fixing bugs in Theano environment batch file when using WinPython

    我遇到的另一个与Theano安装指南有关的问题是批处理脚本中有一些错误导致依赖路径不正确 . 这是我的 env.bat 文件的最终版本:

    REM configuration of paths
    set VSFORPYTHON="C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC"
    set SCISOFT=%~dp0
    
    REM add tdm gcc stuff
    set PATH=%SCISOFT%TDM-GCC-64\bin;%SCISOFT%TDM-GCC-64\x86_64-w64-mingw32\bin;%PATH%
    
    REM add winpython stuff
    CALL %SCISOFT%WinPython-64bit-3.4.4.2\scripts\env.bat
    
    REM configure path for msvc compilers
    REM for a 32 bit installation change this line to
    REM CALL %VSFORPYTHON%\vcvarsall.bat
    CALL %VSFORPYTHON%\vcvarsall.bat amd64
    
    REM return a shell
    cmd.exe /k
    

    如果使用Theano,您的.keras文件需要设置如下:

    {
        "floatx": "float32",
        "epsilon": 1e-07,
        "image_dim_ordering": "th",
        "backend": "theano" 
    }
    

    Issue with installing CuDNN

    另一个关键是需要将CuDNN DLL复制到CUDA安装目录中的相应文件夹中,以便检测它们 . 说明详述如下:Instructions for installing CuDNN into CUDA on Windows

    If still having issues with Theano installation on Windows with Python 3.4:

    那么请查看以下信息:Full installation guide for Theano on Windows with Python 3.4, including all required environment variables and PATH directories

    Another key issue with installing the C++ dependencies for Theano

    我被绊倒的另一件事是在official Theano documentation中,它提供了有关安装Microsoft Visual C++ Compiler for Python 2.7的非常具体的说明 . 似乎这个编译器也需要完全按照Theano文档指定在命令行上执行安装以使Python 3.4工作的方式安装 . 我将引用官方的Theano文档,其中说明:

    打开管理员控制台(开始,然后键入cmd,右键单击命令提示符图标并选择以管理员身份运行)cd到您的下载目录并执行msiexec / i VCForPython27.msi ALLUSERS = 1

    General advice about GPU-acceleration

    还有,仅供参考,如果您还没有尝试配置神经网络库,我强烈建议您使用GPU加速 .

相关问题