pythontheanonvcctheano-cuda

Error to load compiler libraries while importing Theano: fatal error C1083


I'm trying to use Theano with my GPU for several days in my Python environment. While importing theano, I obtain this error:

d:\anaconda2\include\pyconfig.h(239) : fatal error C1083: Cannot open include file: 'basetsd.h': No such file or directory

I tried to include "D:\Anaconda2\MinGW\x86_64-w64-mingw32\include" (this folder contains "pyconfig.h") in PYTHONPATH, in PATH and in .theanorc.txt, with the same error message.

Do you have any ideas to connect anaconda/cuda/nvcc to the compiler in Theano?

Here is my configuration:

I can "import theano" with the CPU, but I want to use GPU for computations.

After typing "import theano" (with device=gpu), I can see a console window launching "nvcc.exe" before showing the error.

I tested CUDA with Visual Studio 2012 and it's working, for example "bilateralFilter" works in Visual Studio without error:

Found 1 CUDA Capable device(s) supporting CUDA
Device 0: "GeForce GTX 950"
CUDA Runtime Version: 8.0
CUDA Compute Capability: 5.2
...
Running Standard Demonstration with GLUT loop...

Solution

  • I found a solution for my problem.

    Short answer

    1. Add C:\Windows\System32 to PATH
    2. Launch C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\amd64\vcvars64.bat

    End.

    For information, here is my new current PATH:

    C:\Windows\System32
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin
    C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\amd64
    D:\Anaconda2
    D:\Anaconda2\Scripts
    D:\Anaconda2\Library\bin
    

    Here is my PYTHONPATH:

    nothing

    Here is my .theanorc.txt:

    [global]
    device=gpu
    floatx = float32
    

    Some details

    In addition with PATH, one needs to configure Windows registry, as explained in this post: compilation error in visual studio linked with python26 . It is done by launching vcvars64.bat

    I did this before, but I forgot to notice that a message appeared:

    ERROR: Cannot determine the location of the VS Common Tools folder.
    

    According to https://social.msdn.microsoft.com/Forums/en-US/78703f6b-f610-456c-b770-76a12be3e1ae/error-cannot-determine-the-location-of-the-vs-common-tools-folder?forum=vssetup , the solution is to add C:\Windows\System32 to PATH.