sklearn-compiledtrees
sklearn-compiledtrees copied to clipboard
OSError: [Errno 24] Too many open files when RandomForestRegressor has 140 estimators
Here's a loop that fits and compiles trees, stepping up the number of estimators each time:
from sklearn import datasets, ensemble
import compiledtrees
data = datasets.load_boston()
X, y = data.data, data.target
for i in range(20, 250, 20):
print(i)
model = ensemble.RandomForestRegressor(n_jobs=4, n_estimators=i)
model.fit(X, y)
model = compiledtrees.CompiledRegressionPredictor(model)
h = model.predict(X)
It crashes on 140:
$ python test_script.py
20
40
60
80
100
120
140
Traceback (most recent call last):
File "/Users/ollieglass/code/test_compiled_trees/lib/python3.5/site-packages/joblib/_parallel_backends.py", line 344, in __call__
return self.func(*args, **kwargs)
File "/Users/ollieglass/code/test_compiled_trees/lib/python3.5/site-packages/joblib/parallel.py", line 131, in __call__
return [func(*args, **kwargs) for func, args, kwargs in self.items]
File "/Users/ollieglass/code/test_compiled_trees/lib/python3.5/site-packages/joblib/parallel.py", line 131, in <listcomp>
return [func(*args, **kwargs) for func, args, kwargs in self.items]
File "/Users/ollieglass/code/test_compiled_trees/lib/python3.5/site-packages/compiledtrees/code_gen.py", line 173, in _compile
_call([CXX_COMPILER, cpp_f, "-c", "-fPIC", "-o", o_f.name, "-O3", "-pipe"])
File "/Users/ollieglass/code/test_compiled_trees/lib/python3.5/site-packages/compiledtrees/code_gen.py", line 179, in _call
shell=True, stdout=DEVNULL, stderr=DEVNULL)
File "/usr/local/Cellar/python3/3.5.2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 576, in check_call
retcode = call(*popenargs, **kwargs)
File "/usr/local/Cellar/python3/3.5.2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 557, in call
with Popen(*popenargs, **kwargs) as p:
File "/usr/local/Cellar/python3/3.5.2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "/usr/local/Cellar/python3/3.5.2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 1454, in _execute_child
errpipe_read, errpipe_write = os.pipe()
OSError: [Errno 24] Too many open files
This is on mac OS.
I haven't looked into workarounds - perhaps I can increase the number of files that can be open at once. But if there's a way to limit the open files in the library, that would probably be better.