我有一个非常简单的使用prange
的cython代码,它在linux中工作正常。但是,当我尝试在Windows中执行此操作时。我遇到一个问题,它可以被编译,但不能输入:使用/ openmp编译的模块不能被导入?
ImportError: DLL load failed: This application has failed to start because the a
pplication configuration is incorrect. Reinstalling the application may fix this
problem.
此外,在Windows我不能from cython.parallel import threadlocal
?!奇怪......
有没有人可以指出方向?
系统工作正常:LINUX64,编译器GCC,包装:的Python 2.7,用Cython 0.16
系统有问题:Win64的,编译器:MSVC VS2008,包装:Python 2.7版,cython 0.16
这是我简单的cyx pyx:
cimport cython
from cython.parallel import prange
def f(int n):
cdef int i
cdef int sum = 0
for i in prange(n, nogil=True):
sum += i
print sum
这里是我的setup.py:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy as np
setup(
cmdclass = {'build_ext': build_ext},
include_dirs = [np.get_include()],
ext_modules = [Extension("pcython1", ["pcython1.pyx"],extra_compile_args=['/openmp',],),]
)
如果将prange替换为范围,代码是否可以在Windows下正常工作? – DaveP 2012-08-03 07:02:09
@DaveP感谢您的回复! 没有'/ openmp','range'和'prange'都可以工作。有了它,它们都不起作用。 – Wang 2012-08-04 14:16:04
如果系统没有安装'MS visual studio',但只安装了'VC++ redustributable',它可以正常工作......困惑...... CPU范围与'prange'版本完全不同。所以openMP正在工作,只是它不能在安装了调试DLL的系统上工作,我猜。 – Wang 2012-08-04 15:06:47