Runtime error on using next(iter(dataloader))

username: Rashmi_S_Murthy
cooked: <p>Please provide inputs on what is creating this following runtime error and how can I solve this?<br>
Thanks</p>
<p>Traceback (most recent call last):<br>
File “”, line 1, in <br>
File “C:\Users\Rashmi\anaconda3\envs\torch-cpu\lib\multiprocessing\spawn.py”, line 116, in spawn_main<br>
exitcode = _main(fd, parent_sentinel)<br>
File “C:\Users\Rashmi\anaconda3\envs\torch-cpu\lib\multiprocessing\spawn.py”, line 125, in _main<br>
prepare(preparation_data)<br>
File “C:\Users\Rashmi\anaconda3\envs\torch-cpu\lib\multiprocessing\spawn.py”, line 236, in prepare<br>
_fixup_main_from_path(data[‘init_main_from_path’])<br>
File “C:\Users\Rashmi\anaconda3\envs\torch-cpu\lib\multiprocessing\spawn.py”, line 287, in _fixup_main_from_path<br>
main_content = runpy.run_path(main_path,<br>
File “C:\Users\Rashmi\anaconda3\envs\torch-cpu\lib\runpy.py”, line 265, in run_path<br>
return _run_module_code(code, init_globals, run_name,<br>
File “C:\Users\Rashmi\anaconda3\envs\torch-cpu\lib\runpy.py”, line 97, in _run_module_code<br>
_run_code(code, mod_globals, init_globals,<br>
File “C:\Users\Rashmi\anaconda3\envs\torch-cpu\lib\runpy.py”, line 87, in _run_code<br>
exec(code, run_globals)<br>
File “C:\Users\Rashmi\idgan-master\train.py”, line 155, in <br>
x_real, ytest = utils.get_nsamples(train_loader, ntest)<br>
File “C:\Users\Rashmi\idgan-master\gan_training\utils.py”, line 18, in get_nsamples<br>
x_next, y_next = next(iter(data_loader))<br>
File “C:\Users\Rashmi\anaconda3\envs\torch-cpu\lib\site-packages\torch\utils\data\dataloader.py”, line 355, in <strong>iter</strong><br>
return self._get_iterator()<br>
File “C:\Users\Rashmi\anaconda3\envs\torch-cpu\lib\site-packages\torch\utils\data\dataloader.py”, line 301, in _get_iterator<br>
return _MultiProcessingDataLoaderIter(self)<br>
File “C:\Users\Rashmi\anaconda3\envs\torch-cpu\lib\site-packages\torch\utils\data\dataloader.py”, line 914, in <strong>init</strong><br>
w.start()<br>
File “C:\Users\Rashmi\anaconda3\envs\torch-cpu\lib\multiprocessing\process.py”, line 121, in start<br>
self._popen = self._Popen(self)<br>
File “C:\Users\Rashmi\anaconda3\envs\torch-cpu\lib\multiprocessing\context.py”, line 224, in _Popen<br>
return _default_context.get_context().Process._Popen(process_obj)<br>
File “C:\Users\Rashmi\anaconda3\envs\torch-cpu\lib\multiprocessing\context.py”, line 327, in _Popen<br>
return Popen(process_obj)<br>
File “C:\Users\Rashmi\anaconda3\envs\torch-cpu\lib\multiprocessing\popen_spawn_win32.py”, line 45, in <strong>init</strong><br>
prep_data = spawn.get_preparation_data(process_obj._name)<br>
File “C:\Users\Rashmi\anaconda3\envs\torch-cpu\lib\multiprocessing\spawn.py”, line 154, in get_preparation_data<br>
_check_not_importing_main()<br>
File “C:\Users\Rashmi\anaconda3\envs\torch-cpu\lib\multiprocessing\spawn.py”, line 134, in _check_not_importing_main<br>
raise RuntimeError(’’’<br>
RuntimeError:<br>
An attempt has been made to start a new process before the<br>
current process has finished its bootstrapping phase.</p>
<pre><code>    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()
            ...</code></pre>

username: ptrblck
cooked: <p>The error is caused by using multiprocessing on Windows without the if-clause protection.<br>
Did you add the suggested fix posted in the error message or as described <a href="https://pytorch.org/docs/stable/notes/windows.html">here</a>?</p>