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

Kernel appears to have died in Jupyter Notebook using TPOTClassifier #546

Closed
ben0it8 opened this issue Aug 15, 2017 · 18 comments
Closed

Kernel appears to have died in Jupyter Notebook using TPOTClassifier #546

ben0it8 opened this issue Aug 15, 2017 · 18 comments
Labels

Comments

@ben0it8
Copy link

ben0it8 commented Aug 15, 2017

Hello,

When calling the fit method from a Jupyter Notebook, the kernel seems to die.
I use Python 2.7 with the latest Jupyter release and an upgraded version of tpot.
First I have this DeprecationWarning:
screen shot 2017-08-15 at 12 21 13

Then, after a couple of seconds I get the following window popping up:
screen shot 2017-08-15 at 12 21 25

Do you guys have any idea what could be the reason?

@weixuanfu
Copy link
Contributor

I think it may be related to the issue #508. Please try to set n_jobs=1 with python 2.7 or try use forkserver start mode in python 3.4+ (see the demo codes in issue #508)

@jonathanng
Copy link

I'm getting the same thing with TPOTRegressor.

@weixuanfu
Copy link
Contributor

weixuanfu commented Aug 21, 2017

jonathanng Could you please let me know whether setting n_jobs=1 or using forkserver start mode in python 3.4+ in TPOTRegressor can solve this issue? Below is a demo for TPOTClassifier.

import multiprocessing
if __name__ == '__main__':
    multiprocessing.set_start_method('forkserver')
    # Note: need move import sklearn into main unless a RuntimeError (RuntimeError: context has already been set) will raise
    from sklearn.datasets import make_classification
    from tpot import TPOTClassifier
    # make a huge dataset
    X, y = make_classification(n_samples=50000, n_features=200,
                                        n_informative=20, n_redundant=20,
                                        n_classes=5, random_state=42)
    
    # max_eval_time_mins=0.04 means 2 seconds limits for evaluating a single pipeline 
    # working in python 3.4+ in Linux OS and MacOS
    tpot = TPOTClassifier(generations=5, population_size=50, offspring_size=100, random_state=42, n_jobs=2, max_eval_time_mins=0.04, verbosity=3) 
    tpot.fit(X, y)

@jonathanng
Copy link

I'm using Python 3.6.1. I tried both n_jobs=1 and n_jobs=-1. Both gave me the error.

Also, when I run:

import multiprocessing
multiprocessing.set_start_method('forkserver')

I get the following error:

RuntimeError: context has already been set

I'm trying your timeout_pipe branch now. Will you let you know the results.

@weixuanfu
Copy link
Contributor

weixuanfu commented Aug 21, 2017

I met this error before. You need restart the terminal and then start with:

import multiprocessing
if __name__ == '__main__':
    multiprocessing.set_start_method('forkserver')
    # Note: need move import sklearn into main unless a RuntimeError (RuntimeError: context has already been set) will raise

@weixuanfu weixuanfu reopened this Aug 21, 2017
@weixuanfu
Copy link
Contributor

weixuanfu commented Aug 21, 2017

@jonathanng please check the comment above.

@jonathanng
Copy link

This is all within a Jupyter notebook, so I don't think: if __name__ == '__main__': is necessary, right?

@weixuanfu
Copy link
Contributor

@jonathanng oh you are right. It is not necessary in a jupyter notebook.

@jonathanng
Copy link

For both n_jobs=1 and n_jobs=-1, the timeout_pipe branch works.

Will this be merged into master?

@weixuanfu
Copy link
Contributor

How about using forkserver start mode in current master branch?

The timeout_pipe branch is a compromising solution, and I tested it had some issues in Windows OS and also the performance of n_jobs was not as good as current master branch. We need refine this solution before merging if forkserver does not work or we need find a better solution to solve this fork issue.

@jonathanng
Copy link

With the timeout_pipe branch, it ran successfully, resulting in RandomForestRegressor as the best. But then I ran the data using XGBoost, and I get better results.

Did all the XGBoost runs fail in the pipeline_optimizer. How would I know if they didn't work.

@rhiever
Copy link
Contributor

rhiever commented Aug 26, 2017

You can inspect all of the pipelines that were successfully evaluated during the run with the evaluated_individuals_ property of your TPOT object. Does XGBoost show up in any of the pipelines?

@jonathanng
Copy link

Ok, yes, I do see it. Thanks!

@jonathanng
Copy link

Everything ran successfully after setting n_jbos to half the # of processors and converting all the data to numpy arrays before feeding it into fit.

forkserver was not necessary.

@rhiever
Copy link
Contributor

rhiever commented Aug 28, 2017

Interesting. Maybe it was a memory issue (not enough memory to run all jobs)?

@rhiever
Copy link
Contributor

rhiever commented Oct 10, 2017

Closing this issue. Please feel free to re-open or file a new issue if you have any further questions or comments.

@rhiever rhiever closed this as completed Oct 10, 2017
@vikeshsingh37
Copy link

I got same error when I installed xgboost. I tried all the solutions above but nothing worked for me. The problem disappeared after uninstalling xgboost. However, xgboost.XGBRegressor was not by TPOT.

@RamiroCope
Copy link

Thanks @vikeshsingh37 . This fixed the issue for me as well. Removing xgboost.XGBClassifier in my case did the job.

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

No branches or pull requests

6 participants