问题描述
我正在尝试导入C ++中的python模块并执行此模块的功能。使用g++
编译器,一切正常,并打印出所需的内容。使用mpicxx
和mpiexec
不会输出任何内容,但是我不会遇到任何分段错误,并且代码会终止。可能出什么问题了?
c_opt.cpp
#include <pybind11/embed.h>
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
#include <pybind11/stl.h>
#include <Python.h>
#include <omp.h>
#include <Python.h>
#include <iostream>
#include <mpi.h>
namespace py = pybind11;
int main(int argc,char** argv){
{
py::initialize_interpreter();
py::module initialize_data = py::module::import("test_py");
initialize_data.attr("test")();
}
std::cout << "finished "<< std::endl;
return 0;
py::finalize_interpreter();
}
test.py
def test():
print("in test module")
使用简单的g++
编译器编译(删除#include <mpi.h>
):
$g++ -O3 -Wall -std=c++14 `python3 -m pybind11 --includes` c_opt.cpp -o c_opt.o -lpython3.6m
$./c_opt.o //works perfectly
使用mpi编译器:
mpicxx -O3 -Wall -std=c++14 `python3 -m pybind11 --includes` c_opt.cpp -o c_opt.o -lpython3.6m
mpiexec -n 4 ./c_opt.o //this doesn't display anything
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)