I have been having a problem with multithreading in Julia that I have managed to break down to the simple example:
The script
using PyCall, PyPlot
@pyimport numpy as np
N = 1000
a = np.zeros(N)
Threads.@threads for i in 1:length(a)
#println("hello from thread ",Threads.threadid())
a[i] = sin(i*pi/N)
end
plt.plot(a)
runs, whereas
using PyCall, PyPlot
@pyimport numpy as np
N = 1000
a = np.zeros(N)
Threads.@threads for i in 1:length(a)
#println("hello from thread ",Threads.threadid())
a[i] = np.sin(i*pi/N)
end
plt.plot(a)
does not. Instead the jupyter kernel dies. So apparently there is a problem using functions from pyimport inside of a parallel loop in Julia? The loop also runs well with numpy call in serial.
I am using jupyter lab on a redhat cluster. Using 32 threads. Running Julia 1.7.1