导入 Theano 时加载编译器库出错:致命错误 C1083
Error to load compiler libraries while importing Theano: fatal error C1083
我试图在我的 Python 环境中将 Theano 与我的 GPU 一起使用几天。
导入 theano 时,出现此错误:
d:\anaconda2\include\pyconfig.h(239) : fatal error C1083: Cannot open include file: 'basetsd.h': No such file or directory
我试图在 PYTHONPATH、PATH 和 .theanorc.txt 中包含 "D:\Anaconda2\MinGW\x86_64-w64-mingw32\include"(此文件夹包含 "pyconfig.h"),但出现相同的错误消息。
您有什么想法可以将 anaconda/cuda/nvcc 连接到 Theano 中的编译器吗?
这是我的配置:
- OS: Windows 7
- 显卡:GeForce GTX 950
- cl.exe : D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin
- nvcc.exe : C:\Program Files\NVIDIA GPU 计算 Toolkit\CUDA\v8.0\bin
- Python IDE: 来自 Anaconda 2 的 Spyder,在 Python 2.
- Theano 0.8.2
我可以 "import theano" 使用 CPU,但我想使用 GPU 进行计算。
输入 "import theano"(使用 device=gpu)后,我可以看到控制台 window 在显示错误之前启动 "nvcc.exe"。
我用 Visual Studio 2012 测试了 CUDA,它工作正常,例如 "bilateralFilter" 在 Visual Studio 中工作没有错误:
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...
这是我的theanorc.txt文件(有或没有[nvcc]和[cuda]都会出现同样的错误)
[global]
device = gpu
floatX = float32
[cuda]
root = -LC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0
[nvcc]
flags = -LD:\Anaconda\libs
fastmath = True
compiler-bindir = -LD:\Anaconda2\MinGW\x86_64-w64-mingw32\include
这是我的路径
D:\Anaconda2\MinGW\x86_64-w64-mingw32\include
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\libnvvp
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin
D:\Anaconda2
D:\Anaconda2\Scripts
D:\Anaconda2\Library\bin
C:\Program Files (x86)\Windows Kits.0\Windows Performance Toolkit\
C:\Program Files\Microsoft SQL Server0\Tools\Binn\
这是我的 PYTHONPATH
D:\Anaconda2\MinGW\x86_64-w64-mingw32\include
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\amd64
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin
这是在 Spyder 中键入 "import theano" 后的完整错误消息(在 theanorc.txt 中使用 device=gpu):
1 #define _CUDA_NDARRAY_C
2
3 #include <Python.h>
4 #include <structmember.h>
5 #include "theano_mod_helper.h"
6
7 #include <numpy/arrayobject.h>
8 #include <iostream>
...
5358 /*
5359 Local Variables:
5360 mode:c++
5361 c-basic-offset:4
5362 c-file-style:"stroustrup"
5363 indent-tabs-mode:nil
5364 fill-column:79
5365 End:
5366 */
5367 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=79 :
5368
===============================
c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h(849) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h(1787) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h(2637) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h(3492) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h(4431) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h(5345) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h(6252) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h(7142) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h(7956) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\device_functions.h : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\device_functions.h(774) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\device_functions.h(1618) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\device_double_functions.h : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\sm_20_intrinsics.h : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\sm_20_intrinsics.h(943) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
d:\anaconda2\include\pyconfig.h(239) : fatal error C1083: Cannot open include file: 'basetsd.h': No such file or directory
ERROR (theano.sandbox.cuda): Failed to compile cuda_ndarray.cu: ('nvcc return status', 2, 'for cmd', 'nvcc -shared -O3 -LD:\Anaconda\libs -use_fast_math -Xlinker /DEBUG -D HAVE_ROUND -m64 -Xcompiler -DCUDA_NDARRAY_CUH=c72d035fdf91890f3b36710688069b2e,-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION,/Zi,/MD -ID:\Anaconda2\lib\site-packages\theano\sandbox\cuda -ID:\Anaconda2\lib\site-packages\numpy\core\include -ID:\Anaconda2\include -ID:\Anaconda2\lib\site-packages\theano\gof -o C:\Users\Administrator\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-2.7.13-64\cuda_ndarray\cuda_ndarray.pyd mod.cu -LD:\Anaconda2\libs -LD:\Anaconda2 -lcublas -lpython27 -lcudart')
WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu is not available (error: cuda unavailable)
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).
mod.cu
['nvcc', '-shared', '-O3', '-LD:\Anaconda\libs', '-use_fast_math', '-Xlinker', '/DEBUG', '-D HAVE_ROUND', '-m64', '-Xcompiler', '-DCUDA_NDARRAY_CUH=c72d035fdf91890f3b36710688069b2e,-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION,/Zi,/MD', '-ID:\Anaconda2\lib\site-packages\theano\sandbox\cuda', '-ID:\Anaconda2\lib\site-packages\numpy\core\include', '-ID:\Anaconda2\include', '-ID:\Anaconda2\lib\site-packages\theano\gof', '-o', 'C:\Users\Administrator\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-2.7.13-64\cuda_ndarray\cuda_ndarray.pyd', 'mod.cu', '-LD:\Anaconda2\libs', '-LD:\Anaconda2', '-lcublas', '-lpython27', '-lcudart']
我找到了解决问题的方法。
简答
- 将 C:\Windows\System32 添加到 PATH
- 启动 C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\amd64\vcvars64.bat
结束。
有关信息,这是我当前的新路径:
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
这是我的 PYTHONPATH:
无
这是我的。theanorc.txt:
[global]
device=gpu
floatx = float32
一些细节
除了 PATH 之外,还需要配置 Windows 注册表,如 post 中所述:compilation error in visual studio linked with python26
.这是通过启动 vcvars64.bat
来完成的
我以前也这样做过,但是我忘了注意到出现了一条消息:
ERROR: Cannot determine the location of the VS Common Tools folder.
根据 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 ,解决方案是将 C:\Windows\System32 添加到 PATH.
我试图在我的 Python 环境中将 Theano 与我的 GPU 一起使用几天。 导入 theano 时,出现此错误:
d:\anaconda2\include\pyconfig.h(239) : fatal error C1083: Cannot open include file: 'basetsd.h': No such file or directory
我试图在 PYTHONPATH、PATH 和 .theanorc.txt 中包含 "D:\Anaconda2\MinGW\x86_64-w64-mingw32\include"(此文件夹包含 "pyconfig.h"),但出现相同的错误消息。
您有什么想法可以将 anaconda/cuda/nvcc 连接到 Theano 中的编译器吗?
这是我的配置:
- OS: Windows 7
- 显卡:GeForce GTX 950
- cl.exe : D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin
- nvcc.exe : C:\Program Files\NVIDIA GPU 计算 Toolkit\CUDA\v8.0\bin
- Python IDE: 来自 Anaconda 2 的 Spyder,在 Python 2.
- Theano 0.8.2
我可以 "import theano" 使用 CPU,但我想使用 GPU 进行计算。
输入 "import theano"(使用 device=gpu)后,我可以看到控制台 window 在显示错误之前启动 "nvcc.exe"。
我用 Visual Studio 2012 测试了 CUDA,它工作正常,例如 "bilateralFilter" 在 Visual Studio 中工作没有错误:
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...
这是我的theanorc.txt文件(有或没有[nvcc]和[cuda]都会出现同样的错误)
[global] device = gpu floatX = float32 [cuda] root = -LC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0 [nvcc] flags = -LD:\Anaconda\libs fastmath = True compiler-bindir = -LD:\Anaconda2\MinGW\x86_64-w64-mingw32\include
这是我的路径
D:\Anaconda2\MinGW\x86_64-w64-mingw32\include C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\libnvvp C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin D:\Anaconda2 D:\Anaconda2\Scripts D:\Anaconda2\Library\bin C:\Program Files (x86)\Windows Kits.0\Windows Performance Toolkit\ C:\Program Files\Microsoft SQL Server0\Tools\Binn\
这是我的 PYTHONPATH
D:\Anaconda2\MinGW\x86_64-w64-mingw32\include C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\amd64 C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin
这是在 Spyder 中键入 "import theano" 后的完整错误消息(在 theanorc.txt 中使用 device=gpu):
1 #define _CUDA_NDARRAY_C 2 3 #include <Python.h> 4 #include <structmember.h> 5 #include "theano_mod_helper.h" 6 7 #include <numpy/arrayobject.h> 8 #include <iostream> ... 5358 /* 5359 Local Variables: 5360 mode:c++ 5361 c-basic-offset:4 5362 c-file-style:"stroustrup" 5363 indent-tabs-mode:nil 5364 fill-column:79 5365 End: 5366 */ 5367 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=79 : 5368 =============================== c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h(849) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h(1787) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h(2637) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h(3492) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h(4431) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h(5345) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h(6252) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h(7142) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h(7956) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\device_functions.h : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\device_functions.h(774) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\device_functions.h(1618) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\device_double_functions.h : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\sm_20_intrinsics.h : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\sm_20_intrinsics.h(943) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss d:\anaconda2\include\pyconfig.h(239) : fatal error C1083: Cannot open include file: 'basetsd.h': No such file or directory ERROR (theano.sandbox.cuda): Failed to compile cuda_ndarray.cu: ('nvcc return status', 2, 'for cmd', 'nvcc -shared -O3 -LD:\Anaconda\libs -use_fast_math -Xlinker /DEBUG -D HAVE_ROUND -m64 -Xcompiler -DCUDA_NDARRAY_CUH=c72d035fdf91890f3b36710688069b2e,-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION,/Zi,/MD -ID:\Anaconda2\lib\site-packages\theano\sandbox\cuda -ID:\Anaconda2\lib\site-packages\numpy\core\include -ID:\Anaconda2\include -ID:\Anaconda2\lib\site-packages\theano\gof -o C:\Users\Administrator\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-2.7.13-64\cuda_ndarray\cuda_ndarray.pyd mod.cu -LD:\Anaconda2\libs -LD:\Anaconda2 -lcublas -lpython27 -lcudart') WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu is not available (error: cuda unavailable) 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). mod.cu ['nvcc', '-shared', '-O3', '-LD:\Anaconda\libs', '-use_fast_math', '-Xlinker', '/DEBUG', '-D HAVE_ROUND', '-m64', '-Xcompiler', '-DCUDA_NDARRAY_CUH=c72d035fdf91890f3b36710688069b2e,-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION,/Zi,/MD', '-ID:\Anaconda2\lib\site-packages\theano\sandbox\cuda', '-ID:\Anaconda2\lib\site-packages\numpy\core\include', '-ID:\Anaconda2\include', '-ID:\Anaconda2\lib\site-packages\theano\gof', '-o', 'C:\Users\Administrator\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-2.7.13-64\cuda_ndarray\cuda_ndarray.pyd', 'mod.cu', '-LD:\Anaconda2\libs', '-LD:\Anaconda2', '-lcublas', '-lpython27', '-lcudart']
我找到了解决问题的方法。
简答
- 将 C:\Windows\System32 添加到 PATH
- 启动 C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\amd64\vcvars64.bat
结束。
有关信息,这是我当前的新路径:
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
这是我的 PYTHONPATH:
无
这是我的。theanorc.txt:
[global]
device=gpu
floatx = float32
一些细节
除了 PATH 之外,还需要配置 Windows 注册表,如 post 中所述:compilation error in visual studio linked with python26 .这是通过启动 vcvars64.bat
来完成的我以前也这样做过,但是我忘了注意到出现了一条消息:
ERROR: Cannot determine the location of the VS Common Tools folder.
根据 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 ,解决方案是将 C:\Windows\System32 添加到 PATH.