How do I install theano in Anaconda ver. 2.1 Windows 64 bit for Python 3.4?

前端 未结 3 1858
一整个雨季
一整个雨季 2020-11-28 16:20

I\'ve installed Anaconda. Now I want to install the Theano library in Anaconda. I have tried:

  1. The Theano installer for Anaconda from http://deeplearning.net

相关标签:
3条回答
  • 2020-11-28 17:15

    Note to moderator: This is NOT a duplicate post. All of my other posts were deleted, so I'm leaving this one here and will flag the other questions as duplicate.

    I could never get a working installation of Theano using Anaconda with Python 3.4, and I also could never get the manual installation working with MinGW, but I was able to get it working flawlessly using WinPython 3.4.

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

    If you're using Windows, Theano can be tricky to install and configure. I was able to get it working by following a combination of these tutorials:

    • Installing Keras and Theano with GPU-acceleration on Windows 10
    • Making Theano faster on Windows 10 with CuDNN and CNMeM
    • Official Theano installation instructions for Windows

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

    It was much easier to get Theano working on Python 3.4 when using WinPython instead of Anaconda Python, but WinPython stores environment settings in its settings directory (e.g. C:\SciSoft\WinPython-64bit-3.4.4.2\settings\.keras\) rather than looking in your %USERPROFILE% for the keras.json file when you're wanting it to pick up your environment settings (as explained in the setup guides). Also, if you are still having trouble, you might just need to set the THEANO_FLAGS system environment variable to something like this: floatX=float32,device=gpu,nvcc.fastmath=True,lib.cnmem=0.8,blas.ldflags=-LC:\src\OpenBLAS -lopenblas. (Note that this environment variable overrides the settings in any .theanorc setup file as detailed here in the Theano configuration documentation except if using WinPython, the .theanorc file would go into C:\SciSoft\WinPython-64bit-3.4.4.2\settings\.theanorc rather than %USERPROFILE\.theanorc.)

    When installing Theano with WinPython, installation is much easier if you use the suggested Theano installation location (C:\SciSoft\). In that case, your installation directory should look like this:

    Fixing bugs in Theano environment batch file when using WinPython

    The other issue I ran into with the Theano installation guides is that the batch script had some bugs in it that were causing the dependency paths to be incorrect. Here was my final version of the env.bat file:

    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
    

    If using Theano, your .keras file will need to be setup like:

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

    Issue with installing CuDNN

    Another key thing was that the CuDNN DLLs need to be copied into their corresponding folders in the CUDA installation directory in order for them to be detected. Instructions are detailed here: Instructions for installing CuDNN into CUDA on Windows

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

    Then please review the information here: 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

    Another thing I was tripped up by is that in the official Theano documentation, it provides very specific instructions on installing the Microsoft Visual C++ Compiler for Python 2.7. It seems to be that this compiler is also required to be installed in exactly the way that the Theano documentation specifies to perform the installation on the command line to get Python 3.4 to work. I will quote the official Theano documentation, which states:

    1. open an administrator’s console (got to start, then type cmd, right-click on the command prompt icon and select run as administrator)
    2. cd to your downloads directory and execute msiexec /i VCForPython27.msi ALLUSERS=1

    General advice about GPU-acceleration

    And FYI, if you haven't tried configuring a neural network library, I highly recommend that you use GPU-acceleration.

    0 讨论(0)
  • 2020-11-28 17:18

    Running Theano on Python 3.4 is complicated. So far I would recommend that you run Theano in Python 2.7. The libraries written for Theano are Python 2.6+ based. So in order to get Theano running in Python 3.4, you would be needing the 2to3 automated python 2 to 3 code translation tool. I haven't tested Theano using 2to3, so I can't comment on whether it would work or not. But, I am using Python 2.7 and Theano works smoothly. Also, you might want to use AnacondaCE with Python 2.7 installer which pretty much gives you everything you need to start developing.

    You would also need to reinstall Theano using

    pip install Theano
    
    0 讨论(0)
  • 2020-11-28 17:18

    As we can see, you have tried to use Theano under Windows. Please, ensure that you have a MinGW compiler. Further, ensure that you have MinGW and libpython packages.

    Generally, I recommend to use the answer How do I install Keras and Theano in Anaconda Python 2.7 on Windows?, but without the last step.

    0 讨论(0)
提交回复
热议问题