facebookresearch / mmf

A modular framework for vision & language multimodal research from Facebook AI Research (FAIR)
https://mmf.sh/
Other
5.46k stars 932 forks source link

how to run it with python script? #1182

Open chenhaoenen opened 2 years ago

chenhaoenen commented 2 years ago

❓ Questions and Help

image

base on image, I run it using the script below

from mmf_cli.run import run opts = [ "config=projects/m4c/configs/textvqa/defaults.yaml", "model=m4c", "dataset=textvqa", "run_type=train_val", ] run(opts)

But the errors I get are as follows, how to run it with python script?

/opt/conda/lib/python3.8/site-packages/omegaconf/grammar_visitor.py:253: UserWarning: In the sequenceMMF_USER_DIR,some elements are missing: please replace them with empty quoted strings. See https://github.com/omry/omegaconf/issues/572 for details. warnings.warn( /opt/conda/lib/python3.8/site-packages/omegaconf/resolvers/__init__.py:12: UserWarning: Theenvresolver is deprecated, see https://github.com/omry/omegaconf/issues/573 warnings.warn( 2022-01-10T06:31:21 | mmf.utils.configuration: Overriding option config to projects/m4c/configs/textvqa/defaults.yaml 2022-01-10T06:31:21 | mmf.utils.configuration: Overriding option model to m4c 2022-01-10T06:31:21 | mmf.utils.configuration: Overriding option datasets to textvqa 2022-01-10T06:31:21 | mmf.utils.configuration: Overriding option run_type to train_val /opt/conda/lib/python3.8/site-packages/omegaconf/grammar_visitor.py:253: UserWarning: In the sequenceMMF_LOG_DIR,some elements are missing: please replace them with empty quoted strings. See https://github.com/omry/omegaconf/issues/572 for details. warnings.warn( /opt/conda/lib/python3.8/site-packages/omegaconf/grammar_visitor.py:253: UserWarning: In the sequenceMMF_REPORT_DIR,some elements are missing: please replace them with empty quoted strings. See https://github.com/omry/omegaconf/issues/572 for details. warnings.warn( /opt/conda/lib/python3.8/site-packages/omegaconf/grammar_visitor.py:253: UserWarning: In the sequenceMMF_TENSORBOARD_LOGDIR,some elements are missing: please replace them with empty quoted strings. See https://github.com/omry/omegaconf/issues/572 for details. warnings.warn( /opt/conda/lib/python3.8/site-packages/omegaconf/grammar_visitor.py:253: UserWarning: In the sequenceMMF_WANDB_LOGDIR,some elements are missing: please replace them with empty quoted strings. See https://github.com/omry/omegaconf/issues/572 for details. warnings.warn( /opt/conda/lib/python3.8/site-packages/omegaconf/grammar_visitor.py:253: UserWarning: In the sequenceMMF_USER_DIR,some elements are missing: please replace them with empty quoted strings. See https://github.com/omry/omegaconf/issues/572 for details. warnings.warn( /opt/conda/lib/python3.8/site-packages/omegaconf/resolvers/__init__.py:12: UserWarning: Theenvresolver is deprecated, see https://github.com/omry/omegaconf/issues/573 warnings.warn( /opt/conda/lib/python3.8/site-packages/omegaconf/grammar_visitor.py:253: UserWarning: In the sequenceMMF_USER_DIR,some elements are missing: please replace them with empty quoted strings. See https://github.com/omry/omegaconf/issues/572 for details. warnings.warn( /opt/conda/lib/python3.8/site-packages/omegaconf/resolvers/__init__.py:12: UserWarning: Theenvresolver is deprecated, see https://github.com/omry/omegaconf/issues/573 warnings.warn( 2022-01-10T06:31:27 | mmf.utils.configuration: Overriding option config to projects/m4c/configs/textvqa/defaults.yaml 2022-01-10T06:31:27 | mmf.utils.configuration: Overriding option model to m4c 2022-01-10T06:31:27 | mmf.utils.configuration: Overriding option datasets to textvqa 2022-01-10T06:31:27 | mmf.utils.configuration: Overriding option run_type to train_val /opt/conda/lib/python3.8/site-packages/omegaconf/grammar_visitor.py:253: UserWarning: In the sequenceMMF_LOG_DIR,some elements are missing: please replace them with empty quoted strings. See https://github.com/omry/omegaconf/issues/572 for details. warnings.warn( /opt/conda/lib/python3.8/site-packages/omegaconf/grammar_visitor.py:253: UserWarning: In the sequenceMMF_REPORT_DIR,some elements are missing: please replace them with empty quoted strings. See https://github.com/omry/omegaconf/issues/572 for details. warnings.warn( /opt/conda/lib/python3.8/site-packages/omegaconf/grammar_visitor.py:253: UserWarning: In the sequenceMMF_TENSORBOARD_LOGDIR,some elements are missing: please replace them with empty quoted strings. See https://github.com/omry/omegaconf/issues/572 for details. warnings.warn( /opt/conda/lib/python3.8/site-packages/omegaconf/grammar_visitor.py:253: UserWarning: In the sequenceMMF_WANDB_LOGDIR,` some elements are missing: please replace them with empty quoted strings. See https://github.com/omry/omegaconf/issues/572 for details. warnings.warn( 2022-01-10T06:31:27 | mmf.utils.configuration: Overriding option config to projects/m4c/configs/textvqa/defaults.yaml 2022-01-10T06:31:27 | mmf.utils.configuration: Overriding option model to m4c 2022-01-10T06:31:27 | mmf.utils.configuration: Overriding option datasets to textvqa 2022-01-10T06:31:27 | mmf.utils.configuration: Overriding option run_type to train_val Traceback (most recent call last): File "", line 1, in File "/opt/conda/lib/python3.8/multiprocessing/spawn.py", line 116, in spawn_main exitcode = _main(fd, parent_sentinel) File "/opt/conda/lib/python3.8/multiprocessing/spawn.py", line 125, in _main prepare(preparation_data) File "/opt/conda/lib/python3.8/multiprocessing/spawn.py", line 236, in prepare _fixup_main_from_path(data['init_main_from_path']) File "/opt/conda/lib/python3.8/multiprocessing/spawn.py", line 287, in _fixup_main_from_path main_content = runpy.run_path(main_path, File "/opt/conda/lib/python3.8/runpy.py", line 265, in run_path return _run_module_code(code, init_globals, run_name, File "/opt/conda/lib/python3.8/runpy.py", line 97, in _run_module_code _run_code(code, mod_globals, init_globals, File "/opt/conda/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/code/Demo/mmf/test/test1.py", line 28, in run(opts) File "/code/Demo/mmf/mmf_cli/run.py", line 126, in run torch.multiprocessing.spawn( File "/opt/conda/lib/python3.8/site-packages/torch/multiprocessing/spawn.py", line 230, in spawn return start_processes(fn, args, nprocs, join, daemon, start_method='spawn') File "/opt/conda/lib/python3.8/site-packages/torch/multiprocessing/spawn.py", line 179, in start_processes process.start() File "/opt/conda/lib/python3.8/multiprocessing/process.py", line 121, in start self._popen = self._Popen(self) File "/opt/conda/lib/python3.8/multiprocessing/context.py", line 284, in _Popen return Popen(process_obj) File "/opt/conda/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 32, in init super().init(process_obj) File "/opt/conda/lib/python3.8/multiprocessing/popen_fork.py", line 19, in init self._launch(process_obj) File "/opt/conda/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 42, in _launch prep_data = spawn.get_preparation_data(process_obj._name) File "/opt/conda/lib/python3.8/multiprocessing/spawn.py", line 154, in get_preparation_data _check_not_importing_main() File "/opt/conda/lib/python3.8/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.

/opt/conda/lib/python3.8/site-packages/omegaconf/grammar_visitor.py:253: UserWarning: In the sequence MMF_LOG_DIR, some elements are missing: please replace them with empty quoted strings. See https://github.com/omry/omegaconf/issues/572 for details. warnings.warn( /opt/conda/lib/python3.8/site-packages/omegaconf/grammar_visitor.py:253: UserWarning: In the sequence MMF_REPORT_DIR, some elements are missing: please replace them with empty quoted strings. See https://github.com/omry/omegaconf/issues/572 for details. warnings.warn( /opt/conda/lib/python3.8/site-packages/omegaconf/grammar_visitor.py:253: UserWarning: In the sequence MMF_TENSORBOARD_LOGDIR, some elements are missing: please replace them with empty quoted strings. See https://github.com/omry/omegaconf/issues/572 for details. warnings.warn( /opt/conda/lib/python3.8/site-packages/omegaconf/grammar_visitor.py:253: UserWarning: In the sequence MMF_WANDB_LOGDIR, some elements are missing: please replace them with empty quoted strings. See https://github.com/omry/omegaconf/issues/572 for details. warnings.warn( Traceback (most recent call last): File "", line 1, in File "/opt/conda/lib/python3.8/multiprocessing/spawn.py", line 116, in spawn_main exitcode = _main(fd, parent_sentinel) File "/opt/conda/lib/python3.8/multiprocessing/spawn.py", line 125, in _main prepare(preparation_data) File "/opt/conda/lib/python3.8/multiprocessing/spawn.py", line 236, in prepare _fixup_main_from_path(data['init_main_from_path']) File "/opt/conda/lib/python3.8/multiprocessing/spawn.py", line 287, in _fixup_main_from_path main_content = runpy.run_path(main_path, File "/opt/conda/lib/python3.8/runpy.py", line 265, in run_path return _run_module_code(code, init_globals, run_name, File "/opt/conda/lib/python3.8/runpy.py", line 97, in _run_module_code _run_code(code, mod_globals, init_globals, File "/opt/conda/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/code/Demo/mmf/test/test1.py", line 28, in run(opts) File "/code/Demo/mmf/mmf_cli/run.py", line 126, in run torch.multiprocessing.spawn( File "/opt/conda/lib/python3.8/site-packages/torch/multiprocessing/spawn.py", line 230, in spawn return start_processes(fn, args, nprocs, join, daemon, start_method='spawn') File "/opt/conda/lib/python3.8/site-packages/torch/multiprocessing/spawn.py", line 179, in start_processes process.start() File "/opt/conda/lib/python3.8/multiprocessing/process.py", line 121, in start self._popen = self._Popen(self) File "/opt/conda/lib/python3.8/multiprocessing/context.py", line 284, in _Popen return Popen(process_obj) File "/opt/conda/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 32, in init super().init(process_obj) File "/opt/conda/lib/python3.8/multiprocessing/popen_fork.py", line 19, in init self._launch(process_obj) File "/opt/conda/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 42, in _launch prep_data = spawn.get_preparation_data(process_obj._name) File "/opt/conda/lib/python3.8/multiprocessing/spawn.py", line 154, in get_preparation_data _check_not_importing_main() File "/opt/conda/lib/python3.8/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.

Traceback (most recent call last): File "/code/Demo/mmf/test/test1.py", line 28, in run(opts) File "/code/Demo/mmf/mmf_cli/run.py", line 126, in run torch.multiprocessing.spawn( File "/opt/conda/lib/python3.8/site-packages/torch/multiprocessing/spawn.py", line 230, in spawn return start_processes(fn, args, nprocs, join, daemon, start_method='spawn') File "/opt/conda/lib/python3.8/site-packages/torch/multiprocessing/spawn.py", line 188, in start_processes while not context.join(): File "/opt/conda/lib/python3.8/site-packages/torch/multiprocessing/spawn.py", line 139, in join raise ProcessExitedException( torch.multiprocessing.spawn.ProcessExitedException: process 0 terminated with exit code 1`

arcb01 commented 1 year ago

Hi!

This worked for me:

I created a file in the root mmf directory called my_run.py containing the following:

from mmf_cli.run import run
from mmf_cli.predict import predict

opts = ["config=projects/m4c/configs/textvqa/defaults.yaml",
        "datasets=textvqa",
        "model=m4c",
        "run_type=test",
       "checkpoint.resume_zoo=m4c.textvqa.defaults"]

run(opts, predict=False)

Hope it helps!