Machine Learning Experiments


Installing Keras, Theano and Dependencies on Windows 10


It seems these instruction are deprecated as the preferred method to install Theano is using Anaconda, as described on the page Converting to the new gpu back end(gpuarray).

In a previous article, I described a procedure to install Keras and Theano on Windows 10. The main downside of this procedure is that you had to downgrade to Python 3.4. This tutorial is an improved version which allows you to make Theano and Keras work with Python 3.5 on Windows 10.

Unless stated otherwise, all install options are left to their default/recommended values. In case you change installation paths, make sure you also change them in all subsequent commands.

Installing CUDA

This step is optional but highly recommended for NVidia card owners as it massively speeds up Theano by allowing it to use the GPU:

  1. Download and install Visual Studio Community 2013 update 5. This is a direct link which may not work in the future as your are now required to create a Microsoft account to download old versions of Visual Studio. Do not install Visual Studio 2015 as latest versions are not compatible with CUDA 8. Open VS2013 to see if it’s working.
  2. Add C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin to the PATH.
  3. Download and install CUDA 8.0, you have to create a free NVidia account to download the file. Open the samples directory C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0 and then the Samples_vs2013.sln file. Run any project to see if CUDA is working, for instance, 5_Simulations/oceanFFT. Right click on it, then click on Debug>Start new instance. Accept to build the project, then you should see a simulated ocean surface.
  4. The CUDA installation may have downgraded your NVidia drivers, you can upgrade them again.

Installing Theano

  1. Download and install Anaconda 64 bits with Python 3.5 for Windows. Open a command line and check that Python is working and that it is indeed the Anaconda python 3.5 version.
  2. Download and extract MinGW x86_64-5.4.0-release-posix-seh-rt_v5-rev0.7z. Make sure you’re not using a newer version as it won’t work with Theano.
  3. Add MinGW bin directory to the PATH. For instance, if you extracted MinGW on C: , then add C:\x86_64-5.4.0-release-posix-seh-rt_v5-rev0\mingw64\bin to the PATH.
  4. Open a new command prompt (to take into account the modification to the PATH) and type:
  5. Download and install Git for Windows.
  6. In the command prompt type:
  7. Open the explorer and type in the address bar %USERPROFILE%, open the .theanorc file and add the following lines:

    I assume you installed CUDA, if it is not the case, you have to replace device = gpu by device = cpu . If you have more than one GPU, you can also specify which one you want to use using gpu1 or gpu2 etc.
  8. If your Windows username contains a space or any unusual character or if you want Theano to put its temporary files to a specific place (they can use several Gb of disk space) then add base_compiledir=C:\theano_compiledir under the [global] section of your .theanorc file. Your .theanorc file should now contain:
  9. Now it s time to test if Theano is working properly. Copy the following code into a file and run it in the command line.

    If everything s OK, this code will display something like that:

Installing Keras

  1. In a command prompt, type:
  2. As Keras uses TensorFlow as the default backend, we have to change that for Theano. Open a command line and type:
  3. Create a file named keras.json in %USERPROFILE%/.keras and add the following lines:
  4. Now it s time to test if Keras is working properly. Copy the following code into a file and run it in the command line.

    If everything is working properly you should see (it can take several minutes on the first run):
  5. To be able to draw graph representation of models, there are two more dependencies to install. In the command prompt, type:
  6. Pydot may have trouble finding the path to GraphViz. Open the file in %USERPROFILE%\Anaconda3\Lib\site-packages\pydot and add

    just after


If you encounter any error message during the installation and tests, check that your PATH is clean. Open a new command prompt and type:

  1. This command should return the path where you installed Anaconda:
  2. All these command should return the path where you extracted MinGW:
  3. This command should return the path of the bin folder of your VS2013 installation:
  4. This command should return the path where you installed CUDA (if you use it):
  5. Older versions of Theano were not supposed to work with Python 3.5. If you encounter any problem, you have to bypass this limitation (without any know problem) by editing the file located in %USERPROFILE%\Anaconda3\lib\site-packages\theano\theano\ and delete the lines:


Now you should be ready to do amazing stuff with Keras and Theano. If you want to make your networks run faster, you should check my article on how to use CuDNN and CNMeM with Theano.



  1. Jeet

    Can I use Theano and other mentioned (above) packages even if I don’t have a GPU in my system?

    • Fabien Tencé

      Hi Jeet,

      You can of course use Keras and Theano on CPU. It will be slower but it will work.
      To do so, you have to skip the CUDA part and specify device = cpu in the .theanorc file.
      You can also look at my article on CNMeM and CuDNN. There is a section on OpenBLAS (skip the rest). Linking Theano to OpenBLAS should speed up a bit networks on CPU. I’m not sure if you need the, as you already put MinGW in the PATH.

  2. Lucas

    Thank you so much for this detailed tutorial. Everything seems to be working fine. One of the few straightfoward oob tutorials. Thanks!

  3. Gilsinia

    thank you. Very helpful 🙂

  4. Kyle

    Thanks for the guide. I’m getting “ImportError: No module named ‘tensorflow'” when I try to run Do you know if there’s a workaround for this or some way to get tensorflow on Windows?

    • Fabien Tencé

      Hi Kyle,

      Keras has changed its default backend from Theano to Tensorflow not too long ago. You have to edit the file keras.json in %userprofile%/.keras/ and change backend to “theano” and image_dim_ordering to “th”. I’ll add that to the article, thanks for your feedback.
      As Tensorflow cannot use the GPU on Windows for now, I’d advise against installing it and using it with Keras. Even if you’re using the CPU, Tensorflow on Windows is still not very well supported.

  5. Niv

    Thanks for this great tutorial. I’ve followed all the steps to install theano but for some reason it does not import. g++ reports that “mod.cpp” and “lazylinker_ext.pyd” are missing (which is actually true only for lazylinker.pyd). How can I fix this?

    • Fabien Tencé

      Hi Niv,

      It’s hard to tell, here’s a few guesses:

      • Did you open a new command prompt after modifying the PATH? Modifications to the PATH are only taken into account in new command prompts.
      • Is there a file named libpython35.a in %USERPROFILE%\Anaconda3\libs?
      • Does where g++ return the path where you extracted MinGW?
      • Niv

        Yes to all questions… can it be because of spaces in the user name?

        • Fabien Tencé

          Good idea, try adding the following line to your .theanorc file under the [global] section:
          This directory will be created and used by Theano to compile stuff. By default it uses the %LOCALAPPDATA%\Theano directory which, in your case, contains a space.

          edit: I can confirm this, having a space in Theano’s compile directory gave me the same error. I updated the article accordingly, thanks.

          • Niv

            Thanks for the solution. I actually managed to overcome this problem in a different way. The failure was in a cmd command that call g++. Adding quotation marks around the path for mod.cpp and lazylinker_ext.pyd (in this cmd command) seems to solve the problem. The relevant code is around line 2278 in, at %USERPROFILE%\Anaconda3\Lib\site-packages\Theano\theano\gof.
            Do you think that this issue may still cause problems in the future? should I change the default compile directory in any case?

          • Fabien Tencé

            It shouldn’t cause any problem until you update Theano.

  6. Priya


    I am trying to install theano and keras according to the tutorial. I followed all the steps exactly as mentioned. However when I run the, I get import error: No module named ‘theano’.

    I am using spyder(python 3.5). As I am still new to this field any help provided will be very much appreciated!

    • Fabien Tencé

      Hi Priya,
      Maybe there is another version of Python installed and you’re running it. Open a command prompt and run where python to make sure you’re running the Python version which comes with your Anaconda install.
      Also double check that in the %USERPROFILE%\Anaconda3\Lib\site-packages there is a theano directory.

  7. Katarina


    thanks for this tutorial. I am stuck at this step. Any guesses what I am doing wrong? Thanks.

    C:\Program Files\Anaconda3\libs>gendef ..\python35.dll
    * [..\python35.dll] Found PE+ image
    * failed to create python35.def …

    • Fabien Tencé

      Hi Katarina,
      It seems that gendef can’t create the file, maybe because you do not have the permission to write the file? Try copying the python35.dll file in another directory and run the commands and copy back the resulting libpython35.a in the libs directory. You can also try to open the command prompt with admin rights and run the commands.


    Run any project to see if CUDA is working, for instance, 5_Simulations/oceanFFT.
    I am getting the following error.
    access to path ‘C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\7_CUDALibraries\nvgraph_SSSP\nvgraph_SSSP_v2013.vcxproj’ is denied

    • Fabien Tencé

      Hi Niladri,
      It seems to me that you do not have the permission to modify files in ProgramData. Try copying the whole CUDA Samples directory to %USERPROFILE% and test from there.

  9. Patrick

    I followed the tutorial and wantet to test theano, but I always get an error and have no idea how to fix it:

    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\crtdefs.h(10): fatal error C1083: Cannot open include file: ‘corecrt.h’: No such file or directory
    ERROR (theano.sandbox.cuda): Failed to compile (‘nvcc return status’, 2, ‘for cmd’, ‘nvcc -shared -O3 -use_fast_math -Xlinker …….

    WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu is not available (error: cuda unavailable)

    Something seems to be off with using the GPU, because it just mentions that it used the cpu instead (The ocean simulation runs without problems).

    • Fabien Tencé

      Hi Patrick,
      It seems that there is something wrong with your configuration. The error message refers to “Microsoft Visual Studio 14.0” which is the 2015 version. MVS 2015 is not compatible with CUDA.
      My guess it that Theano tries to use MVS 2015 to compile its CUDA code and it fails. Just a shot in the dark, try adding:
      compiler_bindir=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin

      to your .theanorc file.

  10. Jaume

    Thanks Fabien for this (very) useful tutorial!

  11. Manasa

    Hi. Thank you so much for this tutorial. I was able to get theano working however when I run the code to test if keras is installed it tells me

    ImportError: No module named ‘keras.models’

    I am trying to run it in spyder IDE. Could you please help me out.

  12. Alabastor95

    Hi there!

    I’m quite new to this whole programming stuff: could you tell me, which path do you mean under ‘PATH’? What am i supposed to do?

    thx 🙂

    • Fabien Tencé


      PATH is an environment variable. You can modify it following these steps.

      You can modify the PATH variable for your user account or for all the accounts (under the system variables). If there is a single account on your computer, it doesn’t matter which PATH you modify but I advise you to modify your user PATH only.

  13. Yossi

    Hi Fabien,

    thank you for this tutorial.
    Understand from your post that Visual Studio 2013 is required as part of Theano installation. I don’t have Visual Studio installed in my computer.
    1. Do you have any work around?
    2. I am using Windows 7 (64bit). Is there any changes in your guide lines if the OS is Windows 7?

    Thank you.

    • Fabien Tencé

      Hi Yossi,

      Visual Studio is only required if you want to use CUDA. There is a download link to VS 2015 update 5 in the relevant section, you should use that to install it.
      As for Windows 7, I don’t know if there is any change to be made. I think it should work without any change but I’m not 100% sure.

      You’re welcome.

  14. Jaafar Ben-Abdallah

    Thank you Fabien for this excellent and straightforward tutorial. I’ve been looking for this for a while now and you just delivered a clear and easy to follow process. Now onto training some DNNs…

  15. Keerthimanu Gattu

    I am getting No module named ‘theano’ when running
    One thing I suspect is my theanorc file was empty when I opened it to append the lines mentioned in the tutorial above.

    • Fabien Tencé


      It’s hard to tell why it’s not working. Are you using an IDE? Did you restarted it? Are you sure you are running the Anaconda version of Python?

  16. Soren Pallesen

    Hi there, thanks good stuff – works like a charm !

    However i want to upgrade Theano to the lastest bleeding edge version – do you have any tips for a safe way to do this?

    Best regards

    • Fabien Tencé

      Hi Soren,

      The best way to do this is:
      cd %USERPROFILE%\Anaconda3\Lib\site-packages\Theano
      git stash
      git pull
      git stash pop
      python develop

      The git stash commands allows you to keep the modifications you made to the code so you don’t have to edit again

      You can do he same with Keras, just replace the first command by cd %USERPROFILE%\Anaconda3\Lib\site-packages\keras. You don’t need the git stash commands if you didn’t modify any files in Keras.

      • Soren Pallesen

        Wow thanks !!! I was quite nervous and looking for a way that does not skrew up the installation !

  17. Pavel

    Hi Fabien!
    I’m stuck at testing Theano. Something doesn’t work properly. I tested paths as you suggested but it still throws out the following error. and I have no idea what to do next. Can you please suggest anything?

    Microsoft Windows [Version 10.0.14393]
    (c) Корпорация Майкрософт (Microsoft Corporation), 2016. Все права защищены.

    C:\Users\Asus>where python

    C:\Users\Asus>where gcc

    C:\Users\Asus>where g++

    C:\Users\Asus>where gendef

    C:\Users\Asus>where dlltool

    Traceback (most recent call last):
    File “C:\Users\Asus\Anaconda3\lib\site-packages\theano\theano\gof\”, line 75, in
    raise ImportError()

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File “C:\Users\Asus\Anaconda3\lib\site-packages\theano\theano\gof\”, line 92, in
    raise ImportError()

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File “C:\Users\Asus\Anaconda3\lib\site-packages\theano\theano\gof\”, line 1784, in _try_compile_tmp
    os.remove(exe_path + “.exe”)
    PermissionError: [WinError 32] process cannot access the file, because the file is used by another process: ‘C:\\Users\\Asus\\AppData\\Local\\Temp\\try_march_v8u8xl9n.exe’

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File “”, line 7, in
    from theano import function, config, shared, sandbox
    File “C:\Users\Asus\Anaconda3\lib\site-packages\theano\theano\”, line 67, in
    from theano.compile import (
    File “C:\Users\Asus\Anaconda3\lib\site-packages\theano\theano\compile\”, line 10, in
    from theano.compile.function_module import *
    File “C:\Users\Asus\Anaconda3\lib\site-packages\theano\theano\compile\”, line 21, in
    import theano.compile.mode
    File “C:\Users\Asus\Anaconda3\lib\site-packages\theano\theano\compile\”, line 10, in
    import theano.gof.vm
    File “C:\Users\Asus\Anaconda3\lib\site-packages\theano\theano\gof\”, line 659, in
    from . import lazylinker_c
    File “C:\Users\Asus\Anaconda3\lib\site-packages\theano\theano\gof\”, line 125, in
    args = cmodule.GCC_compiler.compile_args()
    File “C:\Users\Asus\Anaconda3\lib\site-packages\theano\theano\gof\”, line 2088, in compile_args
    default_compilation_result, default_execution_result = try_march_flag(GCC_compiler.march_flags)
    File “C:\Users\Asus\Anaconda3\lib\site-packages\theano\theano\gof\”, line 1856, in try_march_flag
    flags=cflags, try_run=True)
    File “C:\Users\Asus\Anaconda3\lib\site-packages\theano\theano\gof\”, line 2188, in try_compile_tmp
    File “C:\Users\Asus\Anaconda3\lib\site-packages\theano\theano\gof\”, line 1789, in _try_compile_tmp
    err += “\n” + str(e)
    TypeError: can’t concat bytes to str


    • Fabien Tencé

      Hi Pavel,

      You seem to have a problem with lazylinker. Niv had the same kind of problem. You can try to add the following line to your .theanorc file under the [global] section:
      Also make sure your current user can write to this directory.

      • Pavel

        Sorry Fabien. This doesn’t seem to change anything. It still produces the same errors

      • Pavel

        Hi Fabien!
        I managed to succeed by following this instruction:
        but using your bundle of mingw. The version of migw provided there doesn’t work. That said, Theano throws out some deprecation warnings upon import
        but your test file worked out correctly.
        No thinking about how to install the same for my Python 2.7 env within my root python 3.5

        • Fabien Tencé

          Hi Pavel,

          I’m glad you managed to install Theano but I don’t understand why the other tutorial worked for you. It seems to me that there are very few differences. Do you have any idea how it solved your problem? Is it the use of pip to install Theano? Or the use of CUDA 7.5?

    • Julian S.

      Hi Pavel,

      are you using McAffe antivirus?

      I got the installation running until I updated the antivirus software. Try to deactivate the real time analysis feature in order to make your installation run.

      Thank you very much Fabien for your complete and detailed explanation!


      Julian S.

  18. Soren Pallesen

    Hi again Fabien,

    Im looking for some training benchmarks on Keras, know of any good ones?

    Preferably :
    1) with knows/public datasets
    2) CPU vs GPU
    3) LTSM networks

    Best regards

    • Fabien Tencé

      Hi Soren,

      I haven’t heard of any benchmark, sorry. There are so many factors (hardware and software) that can influence the results, it is difficult to compare. As a rule of thumb, GPU is almost always faster than CPU, consider CPU only for very specific tasks (requiring high precision for example). I don’t have any experience in LTSM, so I can’t help you there.

  19. Nghia

    It does not work for me. Here is the error:

    Traceback (most recent call last):
    File “C:\Users\Win10Home\Anaconda3\lib\site-packages\theano\theano\gof\”, line 75, in
    raise ImportError()

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File “C:\Users\Win10Home\Anaconda3\lib\site-packages\theano\theano\gof\”, line 92, in
    raise ImportError()

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File “D:\googleDrive\code\Theano\”, line 8, in
    import theano.tensor as T
    File “C:\Users\Win10Home\Anaconda3\lib\site-packages\theano\theano\”, line 70, in
    from theano.compile import (
    File “C:\Users\Win10Home\Anaconda3\lib\site-packages\theano\theano\compile\”, line 10, in
    from theano.compile.function_module import *
    File “C:\Users\Win10Home\Anaconda3\lib\site-packages\theano\theano\compile\”, line 21, in
    import theano.compile.mode
    File “C:\Users\Win10Home\Anaconda3\lib\site-packages\theano\theano\compile\”, line 10, in
    import theano.gof.vm
    File “C:\Users\Win10Home\Anaconda3\lib\site-packages\theano\theano\gof\”, line 659, in
    from . import lazylinker_c
    File “C:\Users\Win10Home\Anaconda3\lib\site-packages\theano\theano\gof\”, line 127, in
    File “C:\Users\Win10Home\Anaconda3\lib\site-packages\theano\theano\gof\”, line 2323, in compile_str
    (status, compile_stderr.replace(‘\n’, ‘. ‘)))
    Exception: Compilation failed (return status=1): D:\theano_compiledir\compiledir_Windows-10-10.0.14393-SP0-Intel64_Family_6_Model_78_Stepping_3_GenuineIntel-3.5.2-64\lazylinker_ext\mod.cpp:1:0: sorry,
    unimplemented: 64-bit mode not compiled in
    . #include
    . ^

    • Nghia

      Here is new my .theanorc, and it worked somehow.
      floatX = float32
      device = gpu
      cxx = C:\x86_64-5.4.0-release-posix-seh-rt_v5-rev0\mingw64\bin\g++.exe

      But I got another error:
      Using gpu device 0: GeForce 940MX (CNMeM is disabled, cuDNN not available)
      Traceback (most recent call last):
      File “D:\code\Theano\”, line 16, in
      x = shared(numpy.asarray(rng.rand(vlen), config.floatX))
      NameError: name ‘shared’ is not defined

      Here is the line 16: x = shared(numpy.asarray(rng.rand(vlen), config.floatX))

      • Fabien Tencé

        Hi Nghia,

        It seems you have the same problem as Pavel. I’ll investigate and report back with what I found. I suspect it is specific to the latest version of Theano but I have to check.

        edit: Updated to the last version of Theano and it’s working like a charm. The problem is specific to your configuration.
        I notice you didn’t remove the line in as theano.compile import is line 70 only in the original file. What version of Python do you use? If you’re not using Python 3.5, either update it or do the gendef/dlltool step with your version of Python (maybe python34?).

  20. Raph

    Hi Fabien,

    I have been trying to install Theano for 3days now, by following all your steps. I tried everything, I even restored W10 to be sure there is no other application which could cause problems . But it’s still not working , when I come to the “python install” step I get this message in the end:
    “UnicodeEncodeError: ‘ascii’ codec can’t encode character ‘\xeb’ in position 16: ordinal not in range(128)”.
    I have tried a lot of solutions found on forums to fix it, but nothing works.
    Do you have any Idea for me?
    Thank you

    • Fabien Tencé

      Hi Raph,

      I’m not sure but “\xeb” seems to be the “ë” character. Do you have a “ë” in your username? If so, it may be the cause of the problem. Install Anaconda in another directory and use the base_compiledir flag (see in the article or in the comments). Also make sure your user have read and write rights in the directory you installed Anaconda.
      Or, less subtle, create another account with ascii characters only.

      • Raph

        Merci bcp!
        Oui effectivement ça pourrait provenir de mon nom d’Utilisateur, je vais tester et je vous tiens au courant

  21. Aa

    Great tutorial, it just works! Is there a reason, why you didn’t use “conda install theano”? I followed your CUDA chapter, but then installed theano directly via conda, created the .theanorc file as you suggested and then imported theano for the first time in python and it worked perfectly. Finally, I followed the Keras chapter to get Keras up and running.

    • Fabien Tencé


      Yes, using Theano from GitHub give you access to the latest improvements (but also bugs), the same goes with Keras. If your installation is working fine and you don’t have any problem or speed issues, you can stick to conda install theano.

  22. Martin Novak

    Hi Fabien!

    I’m experiencing an error “ERROR (theano.sandbox.cuda): nvcc compiler not found on $PATH. Check your nvcc installation and try again.”

    I understand what it says, but I’ve checked the $PATH several times, and it has correctly the “C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin” directory, so I don’t know why I get this error. My “.theanorc” is correct too.

    I’ve checked with VS2013 if CUDA works, like you’ve suggested it in the tutorial, and it worked. How can I solve this?

    • Fabien Tencé

      Hi Martin!

      The nvcc compiler should be in C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\. It should have been added to your system PATH by the CUDA installer. You should try to reinstall CUDA and check that where nvcc returns C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\nvcc.exe. I don’t remember if the CUDA installer asks you if you want the PATH to be updated, but if it does, be sure to check that option.

      • Martin Novak

        This was the problem! I’ve added it to $PATH, and now it works like a charm!

        Thank you!

  23. Charles

    Fabien great post!

    I am having a problem getting theano to run off my GPU. Everything installs correctly and my PATH is updated for all the dependencies but it still only runs on my CPU.

    My theanorc file specifies GPU and the CUDA software works when I run the test you suggested. The only other strange thing was I did not have to edit the file, it did not have that if statement in it.

    Any help is much appreciated!!

    • Charles

      Please ignore my comment!

      Also, despite what you read on the internet do not put a ‘.’ after the .theanorc file name!

      Once again great post, I would have a very expensive useless GPU if it was not for this! Thank you.

      • Fabien Tencé

        Hi Charles,

        You’re right, I also saw some sources telling you to add a ‘.’ after the .theanorc file name but it doesn’t work!
        You’re also right, the check for Python 3.5 was removed few days ago, I’ll update my article, thank you for the feedback.

  24. Aravind

    Thanks a lot for this concise tutorial!
    Helped a lot.

  25. Gabriel

    I can’t imagine the number of hours that you saved windows users. Thank you. And thanks for the graphviz installation too, I spent way too much time on this before reading this tutorial.

  26. Andrea


    Great tutorial, although I’m facing some problems. I want to run on a GTX1060 GPU

    I could not run the CUDA 8.0 tutorials on VisualStudio2013:

    C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\5_Simulations\oceanFFT\oceanFFT_vs2013.vcxproj(36,5): The imported project “C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations\CUDA 8.0.props” was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

    But it ran fine on visual studio 15

    I could proceed until the I cd in its folder and run “python” — it shows some errors:

    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\crtdefs.h(10): fatal error C1083: Cannot open include file: ‘corecrt.h’: No such file or directory
    nvcc warning : The ‘compute_20’, ‘sm_20’, and ‘sm_21’ architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).

    WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu is not available (error: cuda unavailable)

    Looping 1000 times took 15.088387 seconds
    Result is [ 1.23178029 1.61879337 1.52278066 …, 2.20771813 2.29967761
    Used the cpu

    – Should I fix the visualstudio 2013 problem? If so, how
    – Can I stick with 2015? if so, how to make gpu work?

    • Andrea


      thanks for this

      btw anaconda users can skip the mingw installation by doing:
      conda install theano

      • How did you solve it? On my Windows 7 machine the instructions worked flawlessly and reestablished (a little bit) my faith in humanity. It has to be said I am not so sure about the cd %USERPROFILE%\Anaconda3\libs part. Anacondas installation gave me no such directories under USERPROFILE, so instead I used Anacondas install dir where everything was. On my windows 10 machine I already had VS2015 and Cuda, and discovered a whole bunch of libs and includes had to be correctly edited somewhere (there seems to have been some moving around of stuff since 2013), finally I copied a lot of stuff from the Windows SDK into Anaconda and it started working – don’t try this at home! Except, keras is giving me the weirdest behavior, I can import it when I start python shell, but something like “python” says keras not found. It is a “typical” Python problem and perhaps related that Anaconda is on a different drive from %USERPROFILE% , but still mysterious to me, since the theano test works.

  27. jimmy wood


    Thanks for the tutorial. I have completed all the steps, including trying various modifications suggested in the comments above relating to similar problems to mine, but I cannot get the theano test file to run. It produces the error below. Any suggestions would be most welcome, thanks

    Problem occurred during compilation with the command line below:
    C:\MinGw64\mingw64\bin\g++.exe -shared -g -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -m64 -DMS_WIN64 -I”C:\Users\Dell\Anaconda3\lib\site-packages\numpy\core\include” -I”C:\Users\Dell\Anaconda3\include” -I”C:\Users\Dell\Anaconda3\lib\site-packages\theano\theano\gof” -L”C:\Users\Dell\Anaconda3\libs” -L”C:\Users\Dell\Anaconda3″ -o c:\theano_compiledir\compiledir_Windows-10-10.0.14393-SP0-Intel64_Family_6_Model_94_Stepping_3_GenuineIntel-3.5.2-64\lazylinker_ext\lazylinker_ext.pyd c:\theano_compiledir\compiledir_Windows-10-10.0.14393-SP0-Intel64_Family_6_Model_94_Stepping_3_GenuineIntel-3.5.2-64\lazylinker_ext\mod.cpp -lpython35
    The system cannot find the path specified.

    Traceback (most recent call last):
    File “C:\Users\Dell\Anaconda3\lib\site-packages\theano\theano\gof\”, line 75, in
    raise ImportError()

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File “C:\Users\Dell\Anaconda3\lib\site-packages\theano\theano\gof\”, line 92, in
    raise ImportError()

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File “”, line 1, in
    from theano import function, config, shared, sandbox
    File “C:\Users\Dell\Anaconda3\lib\site-packages\theano\theano\”, line 66, in
    from theano.compile import (
    File “C:\Users\Dell\Anaconda3\lib\site-packages\theano\theano\compile\”, line 10, in
    from theano.compile.function_module import *
    File “C:\Users\Dell\Anaconda3\lib\site-packages\theano\theano\compile\”, line 21, in
    import theano.compile.mode
    File “C:\Users\Dell\Anaconda3\lib\site-packages\theano\theano\compile\”, line 10, in
    import theano.gof.vm
    File “C:\Users\Dell\Anaconda3\lib\site-packages\theano\theano\gof\”, line 659, in
    from . import lazylinker_c
    File “C:\Users\Dell\Anaconda3\lib\site-packages\theano\theano\gof\”, line 127, in
    File “C:\Users\Dell\Anaconda3\lib\site-packages\theano\theano\gof\”, line 2308, in compile_str
    (status, compile_stderr.replace(‘\n’, ‘. ‘)))
    . ception: Compilation failed (return status=1): The system cannot find the path specified.

  28. Thank you for sharing the installation steps – detailed and concise – it works for me both with or without GPU in Windows machines. You have saved me potentially many hours of trials and errors.

  29. Excellent guide! thank you so much for sharing your knowledge 🙂
    Quick question, the NVCC cmd prompt window keeps popping up when i run the Keras code. Do you know how it can be suppressed to run in background?

    • Fabien Tencé

      Hi Fillan,

      I never saw any NVCC cmd prompt so I’m not of any help. Maybe someone has a solution…

  30. Hong


    I have installed Keras according to your guide.
    The guide is very nice!
    My OS is window 10, I installed CUDA 8.0 and VisualStudio2013.
    I installed a GTX 1070 card.
    For the python , the version is 3.5.2.
    When I run the, it report a issue that “python has stoped work”.
    I debug into and find the below detail issue:

    Unhandled exception at 0x00007FF93A918283 (ntdll.dll) in python.exe: 0xC0000374: 堆已损坏。 (parameters: 0x00007FF93A96F6B0).

    But if I chang the nb_epoch from 20 to 10, there is no such issue.

    Do you know the reason? Do I need to try the python 3.4?


    • Hong

      I debug into the visual studio and find the call stack as below:
      ntdll.dll!00007ffabbbb8283() Unknown
      ntdll.dll!00007ffabbbb8bda() Unknown
      ntdll.dll!00007ffabbb65b9a() Unknown
      ntdll.dll!00007ffabbafc895() Unknown
      > ucrtbase.dll!00007ffab8eee3bb() Unknown
      python35.dll!tupledealloc(PyTupleObject * op) Line 235 C
      python35.dll!code_dealloc(PyCodeObject * co) Line 366 C
      python35.dll!tupledealloc(PyTupleObject * op) Line 235 C
      python35.dll!code_dealloc(PyCodeObject * co) Line 366 C
      python35.dll!func_dealloc(PyFunctionObject * op) Line 551 C
      python35.dll!free_keys_object(_dictkeysobject * keys) Line 352 C
      python35.dll!PyDict_Clear(_object * op) Line 1358 C
      python35.dll!dict_tp_clear(_object * op) Line 2550 C
      python35.dll!delete_garbage(_gc_head * collectable, _gc_head * old) Line 867 C
      python35.dll!collect(int generation, __int64 * n_collected, __int64 * n_uncollectable, int nofail) Line 1019 C
      python35.dll!PyImport_Cleanup() Line 481 C
      python35.dll!Py_Finalize() Line 579 C
      python35.dll!Py_Main(int argc, wchar_t * * argv) Line 804 C
      [External Code]

      The issue seem to be directly related with ucrtbase.dll.
      When I search this file , and find severl different version:
      C:\Program Files\Anaconda3\Library\bin

      How to know which version of this dll file is used by python 3.5? If I find the “C:\Windows\System32” one is used, how to correct it?
      Anybody can help me?


  31. Julius

    Hi, thanks for the tutorial! I’m not able to get CUDA to work with Visual Studio. When I try to build the ocean simulation as you suggested I get the following error:

    Error 45 error : The CUDA Toolkit v8.0 directory ” does not exist. Please verify the CUDA Toolkit is installed properly or define the CudaToolkitDir property to resolve this error.

    I checked on the CUDA installation guide for windows ( and Table 2 says that Visual Studio Community 2015 DOES have support for CUDA 8.0 but it doesn’t list VS Community 2013. Has this changed since you wrote your instructions? I’m uninstall VSC 2013 update 5 and trying it with VSC 2015.

    • Fabien Tencé

      Hi Julius,

      CUDA and Visual Studio compatibilities evolves pretty fast so my tutorial may be deprecated on this point. It should however work with VS2013 so the error may have another cause.

  32. Elle

    Hi Fabien,

    This is a great tutorial, Thank you! I managed to get Theano working fine, but am now stuck on getting Keras working.

    I have un-installed and re-installed Keras but the same error persists:
    raise JSONDecodeError(“Extra data”, s, end)

    JSONDecodeError: Extra data

    How can I find the cause of this error? I am so close and yet so far! :-/

    • Elle

      SOLVED: The cause of the problem was some python comments in the top of the file that configures it to use Theano as the backend.

      After deleting those surplus comments, the test import of keras worked just fine.

  33. Talfan

    Made fantastically straightforward, thanks!

  34. Mike

    Amazing Fabien, thank you very much, this is the best step by step installation post I have ever seen!

  35. Anthony

    Hi Fabien,

    I dont know if you could help me.
    Im stuck in the Cuda test step.
    Whenever i make the instance, the Windows where i supossed the ocean should appear closes and brings me this

    First-chance exception at 0x00007FFF503F7788 in oceanFFT.exe: Microsoft C++ exception: cufftResult_t at memory location 0x000000524FD1FBD8.
    The thread 0x1424 has exited with code 1 (0x1).
    The thread 0xb54 has exited with code 1 (0x1).
    The thread 0x13f4 has exited with code 1 (0x1).
    The program ‘[5896] oceanFFT.exe’ has exited with code 1 (0x1).

    Thank you for your time and answer.

    I dont know if everything is okay cuz it doesnt say crash anywhere but i didnt see any ocean neither. Than

  36. AbdL

    thank you very much for this step-by-step installation instructions!
    I just had to add one extra line in the .theanorc file
    to make it work

    cxx = C:\mingw64\bin\g++.exe

  37. Val Madrid

    Awesome guide! Was able to do it step by step without a hitch. 🙂 This will help me greatly in my image processing modules for classification

  38. Chris Patmore

    Hi Fabien,

    I seem to be having a problem others were seeing, but am unable to find a solution.
    I have followed your steps exactly but the Theano test fails to run.
    The error messages are as follows:

    Problem occurred during compilation with the command line below:
    “C:\Users\Chris\MinGWFiles\mingw64\bin\g++.exe” -shared -g -march=haswell -mmmx -mno-3dnow -msse -msse2 -msse3 -mssse3 -mno-sse4a -mcx16 -msahf -mmovbe -maes -mno-sha -mpclmul -mpopcnt -mabm -mno-lwp -mfma -mno-fma4 -mno-xop -mbmi -mbmi2 -mno-tbm -mavx -mavx2 -msse4.2 -msse4.1 -mlzcnt -mno-rtm -mno-hle -mrdrnd -mf16c -mfsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mxsave -mxsaveopt -mno-avx512f -mno-avx512er -mno-avx512cd -mno-avx512pf -mno-prefetchwt1 -mno-clflushopt -mno-xsavec -mno-xsaves -mno-avx512dq -mno-avx512bw -mno-avx512vl -mno-avx512ifma -mno-avx512vbmi -mno-clwb -mno-pcommit -mno-mwaitx –param l1-cache-size=32 –param l1-cache-line-size=64 –param l2-cache-size=6144 -mtune=haswell -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -m64 -DMS_WIN64 -I”C:\Users\Chris\Anaconda3\lib\site-packages\numpy\core\include” -I”C:\Users\Chris\Anaconda3\include” -I”C:\Users\Chris\Anaconda3\lib\site-packages\theano\theano\gof” -L”C:\Users\Chris\Anaconda3\libs” -L”C:\Users\Chris\Anaconda3″ -o C:\theano_compiledir\compiledir_Windows-10-10.0.14393-SP0-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-3.5.2-64\lazylinker_ext\lazylinker_ext.pyd C:\theano_compiledir\compiledir_Windows-10-10.0.14393-SP0-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-3.5.2-64\lazylinker_ext\mod.cpp -lpython35

    Traceback (most recent call last):
    File “C:\Users\Chris\Anaconda3\lib\site-packages\theano\theano\gof\”, line 75, in
    raise ImportError()

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File “C:\Users\Chris\Anaconda3\lib\site-packages\theano\theano\gof\”, line 92, in
    raise ImportError()

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File “”, line 1, in
    from theano import function, config, shared, sandbox
    File “C:\Users\Chris\Anaconda3\lib\site-packages\theano\theano\”, line 66, in
    from theano.compile import (
    File “C:\Users\Chris\Anaconda3\lib\site-packages\theano\theano\compile\”, line 10, in
    from theano.compile.function_module import *
    File “C:\Users\Chris\Anaconda3\lib\site-packages\theano\theano\compile\”, line 21, in
    import theano.compile.mode
    File “C:\Users\Chris\Anaconda3\lib\site-packages\theano\theano\compile\”, line 10, in
    import theano.gof.vm
    File “C:\Users\Chris\Anaconda3\lib\site-packages\theano\theano\gof\”, line 663, in
    from . import lazylinker_c
    File “C:\Users\Chris\Anaconda3\lib\site-packages\theano\theano\gof\”, line 127, in
    File “C:\Users\Chris\Anaconda3\lib\site-packages\theano\theano\gof\”, line 2309, in compile_str
    (status, compile_stderr.replace(‘\n’, ‘. ‘)))

    all installations are found correctly when checked with where. I have also included base_compiledir=C:\theano_compiledir in the .theanorc file

    Many Thanks

  39. Sky

    Great tutorial – maybe this is obvious to other people but it might be good to add a note saying to make sure to install Anaconda only for the local user. I had problems using using the graphing libraries when I had it installed for the super user (am in the process of reinstalling now)

    • Fabien Tencé

      Hi Sky,

      You’re right, things are much simpler if you install only for the local user but it should work too if you install for all.

  40. Lin

    Fabien Tencé thanks for you instruction it really help me successfully install keras

  41. Alister

    I was wrestling to install Theano ,if you’re keep facing this problem “module ‘theano’ has no attribute ‘gof'” it means there is problem with your theano installation . all you need to do is downloadng theano zip file then extract it in the Anaconda3\Lib\site-packages folder and install it again . i hope it helps some of you !

  42. Arun V

    Hi Fabien,

    I tried running the testKeras code and seems to giving me this error: FileNotFoundError: [WinError 3] The system cannot find the path specified: ‘C:/blaslapack’

    The compiler pointed to error in line. I went through “where cl” command and it couldnt find the path nor could it find for nvcc but I added this for cl C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin and for nvcc I added the line
    compiler_bindir=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin
    in theano file

    I do have numpy and scipy installed and am using anaconda

  43. Ali Abul Hawa

    Hi Fabien,

    Thanks for the detailed and clear installation instructions. I installed theano/keras/cuda… a few months ago, and it worked like a charm.

    After formatting my disk, I re-installed everything today, and it also worked, however, theano’s new version (, throws the following warning:

    Using Theano backend.
    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:

    Using gpu device 0: GeForce GTX 960M (CNMeM is disabled, cuDNN not available)

    It would be great if you can add the necessary modifications to your instructions that would use the gpuarray backend

    Many thanks!

  44. Yann

    Thanks Fabien for the details!
    I just want to let you know that it s works well with anaconda 4.3.0 (so python 3.6)

  45. al

    I love you

  46. Raghu

    Hi Fabien:

    I am having some problems getting the gpu going (cpu works) with your fantastic directions.

    I have followed with your checks as shown in the end of the message.

    The cpu goes through but not the gpu though I have installed CUDA and an nvidia card. I get the error below:

    ERROR (theano.gpuarray): pygpu was configured but could not be imported or is too old (version 0.6 or higher required)
    NoneType: None
    Looping 1000 times took 12.478316 seconds
    Result is [ 1.23178029 1.61879337 1.52278066 …, 2.20771813 2.29967761
    Used the cpu
    [Finished in 16.6s]

    Would appreciate your feedback.

    Thank you and Regards.


    > where python

    > where gcc

    > where g++

    > where gendef

    > where dlltool

    > where cl
    f:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe

    > where nvcc
    F:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\nvcc.exe

  47. Kai

    Everything went well, but you have to use import keras at the beginning, he then creates or checks for your already created *.json file. you can also run import keras in notebook and then alter the created json file. this is considered for everyone who gets the keras.model not found (folowing it exactly like me). This could also be realted to me using Python 3.6 8it woirks fine jsut at the beginning isntead python35 use python36 all time. cheers and thx for the great work.

  48. Hanan

    Hi, thank you for your blogpost.
    Tried to follow it yet I get:
    File “C:\Users\\Anaconda3\lib\site-packages\theano\theano\gof\”, line 302, in dlimport
    rval = __import__(module_name, {}, {}, [module_name])
    ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.

  49. i3v

    It looks like some things changed since this article was written. I’ve used it to install theano and keras a while ago, and it perfectly worked. But today it looks a bit outdated.

    I’ve just successfully installed theano 0.9.0 and keras 2.0.2 to an Anaconda virtual environment with python 3.6 on Windows 7 x64.
    * It’s OK to simply install theano 0.9.0 from anaconda. It just works. (It’s still a good idea to check if GPU is working OK with the script provided here)
    * I ran into “Unknown MS Compiler version 1900” issue, when installing keras (described here: This simple patch helps:

    • Fabien Tencé


      Thanks for this feedback, it looks like I’ll have to update (again!) this article.

  50. Tom

    Hi Fabien, how do you add a directory “to the path”, as mentioned in the step 2) of “Installing CUDA”, and step 3) of “Installing Theano” ?


    • Fabien Tencé

      Hi Tom,

      A bit late, but I cited this article in the comments on how to update your PATH.

  51. Hi Fabian,

    Thanks for the article, I have used it to install all the libraries and it is working perfectly.

    I have also installed Tensorflow with gpu very easily using pip install tensorflow-gpu and cuDNN, and I wrote an article to explain it in detail:


  52. Sam Ranade

    Hello all,
    I have windows 10, python3.5, 4GB grphics card. I had downloaded the CUDA network installer. I stopped the install when it said it would overwrite the existing display driver. This shwn I panicked and stopped the install.
    @Fabien and others
    Have you experienced the same dire warning of display drivers being overwritten and still gone ahead?
    Can I safely assume that I will in fact see folders like C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0 and in that a file Samples_vs2013.sln?

    I am acomplete techno-Nancy so relying on you all as support network.

    Thanks in advance.

    • Fabien Tencé

      Hi Sam,

      I had the same warning about the installer overwriting the current display driver and you can continue the install. It only downgrades your current display driver to an older version. Everything should work fine after the downgrade but you can (and should) reinstall the latest drivers you can find on After this operation, you should have both CUDA and the latest drivers for your card.
      You should be able to follow the rest of the tutorial from here.

  53. Aris

    I followed the instructions and I get this error :
    ValueError: Invalid value (“cpu”) for configuration variable “gpu”. Valid options start with one of “device”, “opencl”, “cuda”

    • Aris

      Traceback (most recent call last):

      File “”, line 1, in
      import theano

      File “C:\Users\user\Anaconda3\lib\site-packages\theano\theano\”, line 67, in
      from theano.configdefaults import config

      File “C:\Users\user\Anaconda3\lib\site-packages\theano\theano\”, line 113, in

      File “C:\Users\user\Anaconda3\lib\site-packages\theano\theano\”, line 285, in AddConfigVar
      configparam.__get__(root, type(root), delete_key=True)

      File “C:\Users\user\Anaconda3\lib\site-packages\theano\theano\”, line 333, in __get__
      self.__set__(cls, val_str)

      File “C:\Users\user\Anaconda3\lib\site-packages\theano\theano\”, line 344, in __set__
      self.val = self.filter(val)

      File “C:\Users\user\Anaconda3\lib\site-packages\theano\theano\”, line 100, in filter
      % (self.default, val, self.fullname)))

      ValueError: Invalid value (“cpu”) for configuration variable “gpu”. Valid options start with one of “device”, “opencl”, “cuda”

  54. Mina

    Dear Fabien Tence,
    I did everything according to this tutorial step by step , but when I want to run, I encounter “No module named ‘tensorflow’ “. I also changed backend to “theano” and image_dim_ordering to “th” but it does not work.
    I would be grateful if you help me with this problem.

  55. Nader

    Can you please update the step by step installation.
    Thank you

  56. Nader

    Please note that according to the following link and theano, we should not install mingw …. please let me know if I understand this correctly.

  57. Robert Schnabel

    well I’ve spent 2 solid days trying to install Keras, Theano, TensorFlow for Python on Windows 10.
    Total FAILURE for mysterious version/dependency reasons.
    I’m not the world’s greatest computer engineer but I’d really like to study these packages.
    It’s truly discouraging how HARD it is to install them. Surely there’s gotta be an easier way.
    You are aware there are DOZENs of ‘sure-fire’ INSTALL instructions out there…each one different and NONE of em work (for me at least)….
    Thanks anyway…..

  58. Benny

    thanks a lot!!! I can finally use Keras with theano 🙂

  59. I have noticed that your blog needs some fresh content.
    Writing manually takes a lot of time, but there is tool
    for this boring task, search for: unlimited content Wrastain’s tools

  60. Pranav

    Hi Fabien
    I’m having a bit of a problem. I followed all the steps till installation of theano, and when I try to run the test theano file I’m getting this error:

    Can not use cuDNN on context None: cannot compile with cuDNN. We got this error:
    b’C:\\Users\\prana\\AppData\\Local\\Temp\\try_flags_ncc2e93w.c:4:19: fatal error: cudnn.h: No such file or directory\r\ncompilation terminated.\r\n’
    Mapped name None to device cuda: GeForce GTX 1050 Ti (0000:01:00.0)

    Please help. Thanks

  61. Thomas

    Thanks, this guide helped me get the missing pieces in place. You’re a life saver!

  62. Ary

    When I try to execute the command ” gendef ..\python35.dll “, I get an error message saying This app can’t run on your PC. To find a version for your PC, contact the software publisher. And there’s “Access is denied” in the command prompt. Any help ?

  63. Dor


    Great tutorial 🙂
    small question:

    1. I didn’t install Conda (using CPU) – How can I operate step 5 in Keras :

    conda install graphviz
    pip install git+

    • Fabien Tencé

      Hi Dor,

      This step is optional, you only have to install that if you want to draw graphs representing the different layers of your networks.
      If it is what you want, you should be able to install graphviz with the commandpip install graphviz (with admin rights or not, depending on your installation).

  64. Nikiforos

    Hello, I followed your steps but when i try to execute the theano code i get the following error, did not find any solution online..

    Traceback (most recent call last):
    File “”, line 1, in
    import theano.tensor as T
    File “C:\Users\310297685\Anaconda3_4.2.0\lib\site-packages\theano\theano\”, line 68, in
    from theano.version import version as __version__
    File “C:\Users\310297685\Anaconda3_4.2.0\lib\site-packages\theano\theano\”, line 14, in
    IndexError: list index out of range

    Any ideas to fix it? Thanks a lot.

    • Nikiforos

      Fixed my problem! I had many Theno’s installed. I had to execute ‘conda uninstall theano’ multiple times till no Theano is present. Then I installed again and no problem.

      • Fabien Tencé

        Hi Nikiforos,

        Thanks for giving the solution, it might help someone having the same problem.

  65. Alex G

    Great set of instructions but for some reason I can’t quite cross the finish-line with cuDNN. I’ve through the trouble of doing a clean install of Anaconda3 (v5.0) and creating a separate environment with python 3.5 with Theano Tensorflow and Keras installed. If I run with the cnDNN flag as False, no errors or issues. If I set it to True, I get this-

    ERROR (theano.gpuarray): Could not initialize pygpu, support disabled
    Traceback (most recent call last):
    File “C:\Users\Sasha\Anaconda3\envs\py35\lib\site-packages\theano\gpuarray\”, line 164, in
    File “C:\Users\Sasha\Anaconda3\envs\py35\lib\site-packages\theano\gpuarray\”, line 151, in use
    File “C:\Users\Sasha\Anaconda3\envs\py35\lib\site-packages\theano\gpuarray\”, line 66, in init_dev
    avail = dnn.dnn_available(name)
    File “C:\Users\Sasha\Anaconda3\envs\py35\lib\site-packages\theano\gpuarray\”, line 174, in dnn_available
    if not dnn_present():
    File “C:\Users\Sasha\Anaconda3\envs\py35\lib\site-packages\theano\gpuarray\”, line 165, in dnn_present
    RuntimeError: You enabled cuDNN, but we aren’t able to use it: cannot compile with cuDNN. We got this error:
    b’C:\\Users\\Sasha\\AppData\\Local\\Temp\\try_flags_u4afi317.c:4:19: fatal error: cudnn.h: No such file or directory\r\ncompilation terminated.\r\n’

    This is my .theanorc-

    floatX = float32
    device = gpu

    compiler_bindir=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin

    cnmem = 0.8

    ldflags=-LC:\openblas -lopenblas

    enabled = True

    • Fabien Tencé

      Hi Alex,

      It seems you use the new Theano GPU backend (gpuarray), and I don’t know much on this, sorry. Maybe a clean install using these instructions could help you.

  66. ale b

    Hello thx for the tutorial. would this work with cuda 9?

    • Fabien Tencé


      I didn’t test this setup, so I can’t be sure. It should work, however you should be careful with the version of Visual Studio you’re using, as there are still compatibility issues between CUDA and VS 2017 (see this post on SO).
      Be sure to check for CUDA/CuDNN compatibility too, see on the download page.

Leave a Reply

Theme by Anders Norén