Closed baggepinnen closed 3 years ago
I can add that if I add some addprocs
~it seems to work~, but I guess it would be good to support also the single-process setting?
EDIT: it worked for a while, then I got a segmentation fault. Unfortunately, vscode kills the terminal once you get the segmentation fault so I cannot copy the trace :/
Hey @baggepinnen, thanks for trying it out! Sorry it's not giving you useful error messages - I should add some warning about workers not being set up.
But yeah, unfortunately it only works in a distributed fashion for right now, for example,
using Distributed
procs = addprocs(4)
@everywhere using SymbolicRegression
X = randn(Float32, 5, 100)
y = 2 * cos.(X[4, :]) + X[1, :] .^ 2 .- 2
options = SymbolicRegression.Options(
binary_operators=(+, *, /, -),
unary_operators=(cos, exp),
npopulations=20
)
niterations = 5
hallOfFame = EquationSearch(X, y, niterations=niterations, options=options)
rmprocs(procs)
However, the (draft) pull request #7 should add functionality to automatically set up workers internal to the module. It should be much easier to set up then!
Cheers, Miles
By the way, when you used addprocs
, did you also import with @everywhere
? That might be why it got the segfault-perhaps one of the workers can't call the module functions.
Yep, I called it exactly like so
procs = addprocs(4)
@everywhere using SymbolicRegression
Before it crashed, it ran for about 5 minutes and some 20-30 iterations, producing some outputs in the terminal. I'll experiment a bit more from the standard terminal and see if it happens again.
Would definitely be good for this package to support serial computation too; I'll add it to my todo list.
Weird, did you call rmprocs(procs)
at the end? I get some errors if I don't remove the workers before exiting. This code runs okay for me:
procs = addprocs(4)
@everywhere using SymbolicRegression
options = SymbolicRegression.Options(
binary_operators=(+, *, /, -),
unary_operators=(cos, sin, sqrt),
npopulations=20
)
niterations = 5
X = randn(3, 10)
y = randn(10)
hallOfFame = EquationSearch(X, y, niterations=niterations, options=options)
rmprocs(procs)
Hey @baggepinnen;
Try out v0.4.0 - it sets up the workers automatically! No more having to call Distributed
and @everywhere
in your script.
e.g.,
using SymbolicRegression
X = randn(Float32, 5, 100)
y = 2 * cos.(X[4, :]) + X[1, :] .^ 2 .- 2
options = SymbolicRegression.Options(
binary_operators=(+, *, /, -),
unary_operators=(cos, exp),
npopulations=20
)
hallOfFame = EquationSearch(X, y, niterations=5, options=options, numprocs=4)
FYI @baggepinnen with v0.4.1 I also added a mechanism for entirely non-distributed code. Just use numprocs=0
in the call to EquationSearch
, and all computation will happen sequentially.
I'm trying a very simple example on v0.3.3 (julia v1.6 beta1) and it just freezes without using any CPU. If I ctrl-C, I get the error below