大家好!
使用julia中发现@threads后的for循环如果需要调用python程序,Julia会崩溃。如下是一个简单例子。请各位大佬给一个解决方案!多谢!
using Base.Threads
using PyCall
const itg = pyimport(“scipy.integrate”)
function test()
@threads for i in 1:10
println(i)
temp=itg.quad(exp,0,i)
end
end
test()
大家好!
使用julia中发现@threads后的for循环如果需要调用python程序,Julia会崩溃。如下是一个简单例子。请各位大佬给一个解决方案!多谢!
using Base.Threads
using PyCall
const itg = pyimport(“scipy.integrate”)
function test()
@threads for i in 1:10
println(i)
temp=itg.quad(exp,0,i)
end
end
test()
用Julia自己的quad
改用多进程
using Distributed
@everywhere using PyCall
function test()
@sync @distributed for i in 1:10
println(i)
itg = pyimport("scipy.integrate")
temp=itg.quad(exp,0,i)
end
end
test()
如果只是算积分,建议使用Julia的quad。