小编nya*_*sui的帖子

用cython包装c ++和CUDA代码

我想用cython包装c ++和CUDA代码.我看了npcuda-example(https://github.com/rmcgibbo/npcuda-example),我按如下方式更改setup.py.

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"])
Run Code Online (Sandbox Code Playgroud)

而且,我为我的代码运行setup.py,但是,我有一个nvcc错误,"fatal error: 'mutex' file not found" 我猜"-std = c ++ 11"选项无法通过nvcc编译器.如何包装c ++和CUDA代码包含c ++ 11代码?

python cuda cython c++11

5
推荐指数
1
解决办法
2515
查看次数

标签 统计

c++11 ×1

cuda ×1

cython ×1

python ×1