I'm facing freeze_support() (multiprocessing - spawn)error while using Statsforecast model in streamlit app

I’m currently working on the hierarchical forecasting with stats forecast and hierarchical forecast(nixtla) module. When I try to execute the statsforecast model training part, I’m facing the below error:

File "C:\Users\abhishek.rawat\AppData\Roaming\Python\Python310\site-packages\statsforecast\core.py", line 1486, in forecast

    return super().forecast(

  File "C:\Users\abhishek.rawat\AppData\Roaming\Python\Python310\site-packages\statsforecast\core.py", line 751, in forecast

    res_fcsts = self._forecast_parallel(h=h, fitted=fitted, X=X, level=level)

  File "C:\Users\abhishek.rawat\AppData\Roaming\Python\Python310\site-packages\statsforecast\core.py", line 1009, in _forecast_parallel

    with Pool(self.n_jobs, **pool_kwargs) as executor:

  File "C:\Program Files\Python310\lib\multiprocessing\context.py", line 119, in Pool

    return Pool(processes, initializer, initargs, maxtasksperchild,

  File "C:\Program Files\Python310\lib\multiprocessing\pool.py", line 215, in __init__

    self._repopulate_pool()

  File "C:\Program Files\Python310\lib\multiprocessing\pool.py", line 306, in _repopulate_pool

    return self._repopulate_pool_static(self._ctx, self.Process,

  File "C:\Program Files\Python310\lib\multiprocessing\pool.py", line 329, in _repopulate_pool_static

    w.start()

  File "C:\Program Files\Python310\lib\multiprocessing\process.py", line 121, in start

    self._popen = self._Popen(self)

  File "C:\Program Files\Python310\lib\multiprocessing\context.py", line 336, in _Popen

    return Popen(process_obj)

  File "C:\Program Files\Python310\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__

    prep_data = spawn.get_preparation_data(process_obj._name)

  File "C:\Program Files\Python310\lib\multiprocessing\spawn.py", line 154, in get_preparation_data

    _check_not_importing_main()

  File "C:\Program Files\Python310\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main

    raise RuntimeError('''

RuntimeError:

        An attempt has been made to start a new process before the

        current process has finished its bootstrapping phase.
 
        This probably means that you are not using fork to start your

        child processes and you have forgotten to use the proper idiom

        in the main module:
 
            if __name__ == '__main__':

                freeze_support()

                ...
 
        The "freeze_support()" line can be omitted if the program

        is not going to be frozen to produce an executable.

Help me how to resolve this one!

In your trying to execute the statsforecast model training part, you are probably not using fork to start your child processes and you have forgotten to use the proper idiom in the main module:

if __name__ == '__main__':
   freeze_support()

We already tried. Negative!

Then something else must be wrong, but I don’t know what it can be.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.