Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

es.tell() Takes Forever to Run and Returns "Process finished with exit code 137 (interrupted by signal 9:SIGKILL)" #272

Open
deringezgin opened this issue Oct 22, 2024 · 7 comments

Comments

@deringezgin
Copy link

Hi everyone,

I am trying to optimize the weights of an LSTM using the CMA-ES. In my current code, I create the LSTM model, initialize random weights, and create the CMA-ES model.

Following this, I ask for solutions from the CMA-ES, and I get a fitness value for each solution. When I have all the possible solutions, I update the "cma.CMAEvolutionStrategy" object using tell.

During this process, the program uses excessive memory, around 80 GB. Moreover, when I come to the es.tell part, the program takes forever to respond and returns the exit code 137 error in the title.

This is a pseudo-code of what I am doing:

model = LSTM(
        input_size=INPUT_SIZE,
        hidden_size=128,
        output_size=OUTPUT_SIZE,
        num_lstm_layers=1,
        num_fc_layers=3,
        fc_hidden_size=64
    )

start_weights = model.get_weights()
es = cma.CMAEvolutionStrategy(start_weights, sigma)
for i in range(100):
       gen_fitness = []
       solutions = es.ask()
       for solution in solutions:
                 gen_fitness.append(get_fitness(solution))
       es.tell(solutions, gen_fitness)

I hope that this is enough information to explain the problem, and I hope that you can help me with it. My program crashes in the first iteration of es.tell(), so this is not a memory piling-up issue.

@nikohansen
Copy link
Contributor

What is the size of start_weights?

@deringezgin
Copy link
Author

Hi, thank you so much for your reply.

In the current configuration, the length of the LSTM start_weights is 102470.

I hope that this information helps. Have a nice day!

@nikohansen
Copy link
Contributor

Looks like you are running out of memory which is quadratic in the above number (hence, if I am not mistaken, in the order of a few 100GB).

I suggest to replace

es = cma.CMAEvolutionStrategy(start_weights, sigma)

with

es = cma.CMAEvolutionStrategy(start_weights, sigma, {'CMA_diagonal': True})

and see how it goes.

@deringezgin
Copy link
Author

Thank you for your answer.

I tried this and can see that I can run with these configurations.

What would be the downsides of optimizing such a model using a diagonal covariance matrix? I hope that you can clarify this for me. I would like to know what changes.

Thank you so much for your help.

@nikohansen
Copy link
Contributor

The diagonal model is the middle in Figure 1 in the tutorial.

@nikohansen
Copy link
Contributor

Otherwise, these sampler are alternatives for high dimension which do learn correlations too.

@deringezgin
Copy link
Author

Thank you for your responses. I will check them out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants