You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I mainly use Julia to write computational intensive function to mitigate the overhead of python, and use python just as a script to call Julia function. I am also writing a package that my lab member can use in python (that's why I use Python to call Julia instead of use Julia to call Python). The goal that I rewrite original python code in julia is to accelerate original python code, with julia's fast and simple UX for thread based parallel computing.
For example,
functiontest()
Threads.@threadsfor i in1:20
a =rand(1000,1000,1000).^2endend
I find out that in python calling julia function with Threads.@threads macro inside will lead to segfault without turning of GC, even this function does not include any python object. Currently the best I can get is PythonCall.GC.disable() before and PythonCall.GC.enable() after computation.
functiontest()
PythonCall.GC.enable()
Threads.@threadsfor i in1:20
a =rand(1000,1000,1000).^2end
PythonCall.GC.disable()
end
Sometimes, disable GC will cause memory overflow, we need to manually collect the unused resource, which is a tedious work. This will lose the simplicity of julia's thread macro and introduce unnecessary cognitive burden to the user, I came up with this discussion to talk about a better way to handle for python to call julia multi-thread function.
I am not a professional computer science student, so there may be a lot of limitation for my understanding. I am not very familiar with the idea of different parallel model and different garbage collection solution. If I made any mistake please feel free to point it out.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, I mainly use Julia to write computational intensive function to mitigate the overhead of python, and use python just as a script to call Julia function. I am also writing a package that my lab member can use in python (that's why I use Python to call Julia instead of use Julia to call Python). The goal that I rewrite original python code in julia is to accelerate original python code, with julia's fast and simple UX for thread based parallel computing.
For example,
I find out that in python calling julia function with
Threads.@threads
macro inside will lead to segfault without turning of GC, even this function does not include any python object. Currently the best I can get isPythonCall.GC.disable()
before andPythonCall.GC.enable()
after computation.Sometimes, disable GC will cause memory overflow, we need to manually collect the unused resource, which is a tedious work. This will lose the simplicity of julia's thread macro and introduce unnecessary cognitive burden to the user, I came up with this discussion to talk about a better way to handle for python to call julia multi-thread function.
I am not a professional computer science student, so there may be a lot of limitation for my understanding. I am not very familiar with the idea of different parallel model and different garbage collection solution. If I made any mistake please feel free to point it out.
Beta Was this translation helpful? Give feedback.
All reactions