I want to wrap c++ and CUDA code with cython. I looked npcuda-example (https://github.com/rmcgibbo/npcuda-example) and I change setup.py as follows.
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"])
And, I run setup.py for my code,
but, I have a nvcc error "fatal error: 'mutex' file not found"
I guess "-std=c++11" option can not pass nvcc compiler.
How can I wrap c++ and CUDA code include c++11 code?
Thank you for answering.
I solved this problem. Command "distutils.util.get_platform()" return mac os x 10.5 on my Mac. So I change python anaconda to system default python, I can compile c++11 code. But I can not compile my all code.
In accordance with Saullo Castro's answer, first I build my code to library using CUDA_ADD_LIBRARY of CMake CUDA Package. And I compile only wrapper.pyx with this library. Then I can wrap my c++ code with cython.
Thank you!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With