examples icon indicating copy to clipboard operation
examples copied to clipboard

"omit freeze_support"

Open kobykotiv opened this issue 6 years ago • 3 comments

I tried to train a model with the default settings but I received this "freeze_support" error. It tells me that freeze_support error needs to be omitted. I'm not sure where this function is. Any help would be appreciated.

(pytorch) D:\____Git\PyTorchSuperResolution>python main.py --upscale_factor 4 --nEpochs 50 --lr 0.001 --cuda
Namespace(batchSize=64, cuda=True, lr=0.001, nEpochs=50, seed=123, testBatchSize=10, threads=4, upscale_factor=4)
===> Loading datasets
===> Building model
Namespace(batchSize=64, cuda=True, lr=0.001, nEpochs=50, seed=123, testBatchSize=10, threads=4, upscale_factor=4)
Namespace(batchSize=64, cuda=True, lr=0.001, nEpochs=50, seed=123, testBatchSize=10, threads=4, upscale_factor=4)
Namespace(batchSize=64, cuda=True, lr=0.001, nEpochs=50, seed=123, testBatchSize=10, threads=4, upscale_factor=4)
Namespace(batchSize=64, cuda=True, lr=0.001, nEpochs=50, seed=123, testBatchSize=10, threads=4, upscale_factor=4)
===> Loading datasets
===> Building model
===> Loading datasets
===> Building model
===> Loading datasets
===> Building model
===> Loading datasets
===> Building model
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<string>", line 1, in <module>
  File "<string>", line 1, in <module>
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 105, in spawn_main
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 105, in spawn_main
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 114, in _main
    exitcode = _main(fd)
          File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 114, in _main
exitcode = _main(fd)prepare(preparation_data)

prepare(preparation_data)  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 114, in _main
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 225, in prepare

      File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 225, in prepare
    prepare(preparation_data)
    _fixup_main_from_path(data['init_main_from_path'])  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 225, in prepare
_fixup_main_from_path(data['init_main_from_path'])

  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path
      File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path
    _fixup_main_from_path(data['init_main_from_path'])    run_name="__mp_main__")
run_name="__mp_main__")
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path

  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\runpy.py", line 263, in run_path
      File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\runpy.py", line 263, in run_path
run_name="__mp_main__")
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\runpy.py", line 263, in run_path
        pkg_name=pkg_name, script_name=fname)
    pkg_name=pkg_name, script_name=fname)  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\runpy.py", line 96, in _run_module_code
pkg_name=pkg_name, script_name=fname)

  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\runpy.py", line 96, in _run_module_code

    mod_name, mod_spec, pkg_name, script_name)  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\runpy.py", line 85, in _run_code
mod_name, mod_spec, pkg_name, script_name)

  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\runpy.py", line 85, in _run_code

    exec(code, run_globals)  File "D:\____Git\PyTorchSuperResolution\main.py", line 92, in <module>
exec(code, run_globals)

  File "D:\____Git\PyTorchSuperResolution\main.py", line 92, in <module>
  File "D:\____Git\PyTorchSuperResolution\main.py", line 92, in <module>
    train(epoch)
train(epoch)train(epoch)  File "D:\____Git\PyTorchSuperResolution\main.py", line 54, in train


      File "D:\____Git\PyTorchSuperResolution\main.py", line 54, in train
  File "D:\____Git\PyTorchSuperResolution\main.py", line 54, in train
for iteration, batch in enumerate(training_data_loader, 1):
          File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\site-packages\torch\utils\data\dataloader.py", line 417, in __iter__
for iteration, batch in enumerate(training_data_loader, 1):for iteration, batch in enumerate(training_data_loader, 1):

  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\site-packages\torch\utils\data\dataloader.py", line 417, in __iter__
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\site-packages\torch\utils\data\dataloader.py", line 417, in __iter__
            return DataLoaderIter(self)return DataLoaderIter(self)

return DataLoaderIter(self)  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\site-packages\torch\utils\data\dataloader.py", line 234, in __init__
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\site-packages\torch\utils\data\dataloader.py", line 234, in __init__

      File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\site-packages\torch\utils\data\dataloader.py", line 234, in __init__
    w.start()    w.start()
w.start()
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\process.py", line 105, in start

  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\process.py", line 105, in start
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\process.py", line 105, in start
            self._popen = self._Popen(self)self._popen = self._Popen(self)self._popen = self._Popen(self)

  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\context.py", line 223, in _Popen
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\context.py", line 223, in _Popen

  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\context.py", line 223, in _Popen
            return _default_context.get_context().Process._Popen(process_obj)return _default_context.get_context().Process._Popen(process_obj)return _default_context.get_context().Process._Popen(process_obj)


  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\context.py", line 322, in _Popen
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\context.py", line 322, in _Popen
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\context.py", line 322, in _Popen
        return Popen(process_obj)return Popen(process_obj)

      File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\popen_spawn_win32.py", line 33, in __init__
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\popen_spawn_win32.py", line 33, in __init__
return Popen(process_obj)
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\popen_spawn_win32.py", line 33, in __init__
        prep_data = spawn.get_preparation_data(process_obj._name)
prep_data = spawn.get_preparation_data(process_obj._name)      File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 143, in get_preparation_data

prep_data = spawn.get_preparation_data(process_obj._name)  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 143, in get_preparation_data

_check_not_importing_main()  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 143, in get_preparation_data

    _check_not_importing_main()  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 136, in _check_not_importing_main
_check_not_importing_main()

  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 136, in _check_not_importing_main
is not going to be frozen to produce an executable.''')  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 136, in _check_not_importing_main

    is not going to be frozen to produce an executable.''')RuntimeErroris not going to be frozen to produce an executable.''')
:
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.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.
        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.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 114, in _main
    prepare(preparation_data)
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 225, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path
    run_name="__mp_main__")
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\____Git\PyTorchSuperResolution\main.py", line 92, in <module>
    train(epoch)
  File "D:\____Git\PyTorchSuperResolution\main.py", line 54, in train
    for iteration, batch in enumerate(training_data_loader, 1):
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\site-packages\torch\utils\data\dataloader.py", line 417, in __iter__
    return DataLoaderIter(self)
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\site-packages\torch\utils\data\dataloader.py", line 234, in __init__
    w.start()
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\process.py", line 105, in start
    self._popen = self._Popen(self)
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\context.py", line 223, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\context.py", line 322, in _Popen
    return Popen(process_obj)
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\popen_spawn_win32.py", line 33, in __init__
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 143, in get_preparation_data
    _check_not_importing_main()
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\spawn.py", line 136, in _check_not_importing_main
    is not going to be frozen to produce an executable.''')
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.
Traceback (most recent call last):
  File "main.py", line 92, in <module>
    train(epoch)
  File "main.py", line 54, in train
    for iteration, batch in enumerate(training_data_loader, 1):
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\site-packages\torch\utils\data\dataloader.py", line 275, in __next__
    idx, batch = self._get_batch()
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\site-packages\torch\utils\data\dataloader.py", line 254, in _get_batch
    return self.data_queue.get()
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\queues.py", line 335, in get
    res = self._reader.recv_bytes()
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\connection.py", line 216, in recv_bytes
    buf = self._recv_bytes(maxlength)
  File "D:\Vitrual.C.Drive\Anaconda\envs\pytorch\lib\multiprocessing\connection.py", line 306, in _recv_bytes
    [ov.event], False, INFINITE)
KeyboardInterrupt

kobykotiv avatar Apr 03 '18 15:04 kobykotiv

See #353.

peterjc123 avatar May 15 '18 09:05 peterjc123

Not all scripts have been updated with the required if __name__ == '__main__':

robmarkcole avatar May 25 '21 11:05 robmarkcole

@robmarkcole would you like to make the PR to fix this?

msaroufim avatar Mar 10 '22 00:03 msaroufim