NVIDIA / sentiment-discovery

Unsupervised Language Modeling at scale for robust sentiment classification
Other
1.06k stars 202 forks source link

running problems in classify.py #37

Open gitathrun opened 6 years ago

gitathrun commented 6 years ago

Hi, I try to use

python3 transfer.py --load_model sst_clf.pt   

But the script does not run properly with following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
Traceback (most recent call last):
  File "C:\Users\teng.fu\AppData\Local\conda\conda\envs\python35\lib\multiprocessing\spawn.py", line 106, in spawn_main
  File "classifier.py", line 155, in <module>
    exitcode = _main(fd)
    ypred = classify(model, train_data)
  File "C:\Users\teng.fu\AppData\Local\conda\conda\envs\python35\lib\multiprocessing\spawn.py", line 115, in _main
  File "classifier.py", line 119, in classify
    prepare(preparation_data)
    for i, data in enumerate(text):
  File "C:\Users\teng.fu\AppData\Local\conda\conda\envs\python35\lib\multiprocessing\spawn.py", line 226, in prepare
  File "C:\Users\teng.fu\AppData\Local\conda\conda\envs\python35\lib\site-packages\torch\utils\data\dataloader.py", line 451, in __iter__
    _fixup_main_from_path(data['init_main_from_path'])
    return _DataLoaderIter(self)
  File "C:\Users\teng.fu\AppData\Local\conda\conda\envs\python35\lib\multiprocessing\spawn.py", line 278, in _fixup_main_from_path
  File "C:\Users\teng.fu\AppData\Local\conda\conda\envs\python35\lib\site-packages\torch\utils\data\dataloader.py", line 239, in __init__
    run_name="__mp_main__")
    w.start()
  File "C:\Users\teng.fu\AppData\Local\conda\conda\envs\python35\lib\runpy.py", line 254, in run_path
  File "C:\Users\teng.fu\AppData\Local\conda\conda\envs\python35\lib\multiprocessing\process.py", line 105, in start
    pkg_name=pkg_name, script_name=fname)
    self._popen = self._Popen(self)
  File "C:\Users\teng.fu\AppData\Local\conda\conda\envs\python35\lib\runpy.py", line 96, in _run_module_code
  File "C:\Users\teng.fu\AppData\Local\conda\conda\envs\python35\lib\multiprocessing\context.py", line 212, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
    mod_name, mod_spec, pkg_name, script_name)
  File "C:\Users\teng.fu\AppData\Local\conda\conda\envs\python35\lib\multiprocessing\context.py", line 313, in _Popen
  File "C:\Users\teng.fu\AppData\Local\conda\conda\envs\python35\lib\runpy.py", line 85, in _run_code
    return Popen(process_obj)
    exec(code, run_globals)
  File "C:\Users\teng.fu\AppData\Local\conda\conda\envs\python35\lib\multiprocessing\popen_spawn_win32.py", line 66, in __init__
  File "D:\my_research\sentiment-discovery\classifier.py", line 155, in <module>
    reduction.dump(process_obj, to_child)
    ypred = classify(model, train_data)
  File "C:\Users\teng.fu\AppData\Local\conda\conda\envs\python35\lib\multiprocessing\reduction.py", line 59, in dump
  File "D:\my_research\sentiment-discovery\classifier.py", line 119, in classify
    ForkingPickler(file, protocol).dump(obj)
    for i, data in enumerate(text):
BrokenPipeError: [Errno 32] Broken pipe
  File "C:\Users\teng.fu\AppData\Local\conda\conda\envs\python35\lib\site-packages\torch\utils\data\dataloader.py", line 451, in __iter__
    return _DataLoaderIter(self)
  File "C:\Users\teng.fu\AppData\Local\conda\conda\envs\python35\lib\site-packages\torch\utils\data\dataloader.py", line 239, in __init__
    w.start()
  File "C:\Users\teng.fu\AppData\Local\conda\conda\envs\python35\lib\multiprocessing\process.py", line 105, in start
    self._popen = self._Popen(self)
  File "C:\Users\teng.fu\AppData\Local\conda\conda\envs\python35\lib\multiprocessing\context.py", line 212, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Users\teng.fu\AppData\Local\conda\conda\envs\python35\lib\multiprocessing\context.py", line 313, in _Popen
    return Popen(process_obj)
  File "C:\Users\teng.fu\AppData\Local\conda\conda\envs\python35\lib\multiprocessing\popen_spawn_win32.py", line 34, in __init__
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "C:\Users\teng.fu\AppData\Local\conda\conda\envs\python35\lib\multiprocessing\spawn.py", line 144, in get_preparation_data
    _check_not_importing_main()
  File "C:\Users\teng.fu\AppData\Local\conda\conda\envs\python35\lib\multiprocessing\spawn.py", line 137, 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.

I add some print cmd in the classify.py and it seems when the classify() function is called, when entering

with torch.no_grad():

The script start to recreate another model and start the process again, not sure what is happening here... I only add some print, nothing more.

pytorch version: 0.4.0 cuda version 9.0 python 3.5

raulpuric commented 6 years ago

Could you try with the latest version I just pushed.

It works for me with pytorch: 0.4.0 cuda version: 9.1 (shouldn't matter) python: 3.6

If the problem still persists could I ask you to try running with python 3.6 and a fresh python3 setup.py install.

Thanks

raulpuric commented 6 years ago

sorry. Don't know how syntax errors creeped in during our merge. Try the commit I pushed just now.