我想在Python中包含几个CUDA加速函数。因此,我在调查Cython。但是,我如何告诉Cython使用nvcc编译器?我在文件hello.c
中有以下C代码:
#include <stdio.h>
#include <cuda.h>
#include <cublas_v2.h>
#include <cuda_runtime.h>
cuComplex test_datatype() {
return make_cuComplex(1, 2);;
}
void f() {
printf("%s", "Hello world!\n");
cuComplex test;
test = test_datatype();
printf("(%5.3f,%5.3fi) \n", test.x, test.y);
}
int main(int argc, const char* argv[]) {
f();
return 0;
}
这个组合使用nvcc -o hello.exe hello.c
对于Cython,我已经设置了一个文件hello_caller.pyx
cdef extern from "hello.c":
void f()
cpdef myf():
f()
和setup.py
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
sourcefiles = ['hello_caller.pyx']
ext_modules = [Extension("hello_caller",
sourcefiles
)]
setup(
name = 'Hello World app',
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules
)
我尝试使用
python setup.py build_ext --inplace --compiler=nvcc
没有成功。输出状态
error: don't know how to compile C/C++ code on platform 'nt' with 'nvcc' compiler
如何建议distutils使用nvcc编译器?我的目标是在下一步中获得Python公开的函数测试数据类型。在这里,我的目标是从函数返回一个numpy数组。关于如何实现这一点的评论也非常欢迎
目前没有回答
相关问题 更多 >
编程相关推荐