我想用cython包装C++和CUDA代码。 我看了npcuda-example(https://github.com/rmcgibbo/npcuda-example),我改变了setup.py,如下所示。用cython包装C++和CUDA代码
ext = Extension('MyWrap',
sources=['src/my_code.cu', 'python/my_wrap.pyx'],
library_dirs=[CUDA['lib']],
libraries=['cudart'],
language='c++',
runtime_library_dirs=[CUDA['lib']],
# this syntax is specific to this build system
# we're only going to use certain compiler args with nvcc and not with gcc
# the implementation of this trick is in customize_compiler() below
extra_compile_args={'clang++': ['-std=c++11','-O3'],
'nvcc': ['-std=c++11','-gencode','arch=compute_30,code=sm_30']},
include_dirs = [numpy_include, CUDA['include'], 'src'],
extra_link_args=["-std=c++11"])
而且,我跑setup.py我的代码, 但是,我有一个NVCC错误"fatal error: 'mutex' file not found"
我猜 “-std = C++ 11” 选项不能通过编译器NVCC。 如何包装C++和CUDA代码包含C++ 11代码?
出于好奇:你为什么要这么做?如果您已经在C++和CUDA中使用了高性能代码,那么您需要什么样的Cython? – Chiel
是的,我有C++和CUDA代码。 我想让我的代码的python界面。 – nyatsui
我解决了这个问题。我用pyenv使用mac os x和anaconda。 distutils.util.get_platform()返回mac os x 10.5。然后我将python anaconda更改为系统默认的python,我可以编译我的代码。 – nyatsui