Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] wrong import of tools/train_net.py #216

Open
rayleizhu opened this issue Feb 24, 2023 · 5 comments
Open

[BUG] wrong import of tools/train_net.py #216

rayleizhu opened this issue Feb 24, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@rayleizhu
Copy link
Contributor

rayleizhu commented Feb 24, 2023

Sometimes, python interpreter can find the wrong train_net.py (i.e. detrex/detectron2/tools/train_net.py). It is due to in PYTHONPATH, detrex/detection2/ is in front of detrex/.

Possible workarounds are:

  1. pip uninstall detrex && pip uninstall detectron2 && pip install -e . && pip install -e detectron2 (tested)
  2. export PYTHONPATH=${PWD}:${PYTHONPATH} (not tested)

See if you have more elegant solutions.

@rentainhe
Copy link
Collaborator

We will check this later~

@rentainhe
Copy link
Collaborator

Sometimes, python interpreter can find the wrong train_net.py (i.e. detrex/detectron2/tools/train_net.py). It is due to in PYTHONPATH, detrex/detection2/ is in front of detrex/.

Possible workarounds are:

  1. pip uninstall detrex && pip uninstall detectron2 && pip install -e . && pip install -e detectron2 (tested)
  2. export PYTHONPATH=${PWD}:${PYTHONPATH} (not tested)

See if you have more elegant solutions.

I have the same PYTHONPATH but I can not reproduce your bug here, we will do more tests on this

@rayleizhu
Copy link
Contributor Author

I tried installation on two machines. On the first one, it works well. On the second machine, when I run tools/train_net.py, an error occurs as below.

File "/mnt/lustre/zhulei1/GitRepo/detrex-custom/detectron2/tools/train_net.py", line 125, in main
    cfg = setup(args)
  File "/mnt/lustre/zhulei1/GitRepo/detrex-custom/detectron2/tools/train_net.py", line 117, in setup
    cfg.merge_from_file(args.config_file)
  File "/mnt/lustre/zhulei1/GitRepo/detrex-custom/detectron2/detectron2/config/config.py", line 46, in merge_from_file
    loaded_cfg = self.load_yaml_with_base(cfg_filename, allow_unsafe=allow_unsafe)
  File "/mnt/lustre/zhulei1/miniconda3/envs/detrex/lib/python3.7/site-packages/fvcore/common/config.py", line 61, in load_yaml_with_base
    cfg = yaml.safe_load(f)
  File "/mnt/lustre/zhulei1/miniconda3/envs/detrex/lib/python3.7/site-packages/yaml/__init__.py", line 125, in safe_load
    return load(stream, SafeLoader)
  File "/mnt/lustre/zhulei1/miniconda3/envs/detrex/lib/python3.7/site-packages/yaml/__init__.py", line 81, in load
    return loader.get_single_data()
  File "/mnt/lustre/zhulei1/miniconda3/envs/detrex/lib/python3.7/site-packages/yaml/constructor.py", line 49, in get_single_data
    node = self.get_single_node()
  File "/mnt/lustre/zhulei1/miniconda3/envs/detrex/lib/python3.7/site-packages/yaml/composer.py", line 39, in get_single_node
    if not self.check_event(StreamEndEvent):
  File "/mnt/lustre/zhulei1/miniconda3/envs/detrex/lib/python3.7/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
  File "/mnt/lustre/zhulei1/miniconda3/envs/detrex/lib/python3.7/site-packages/yaml/parser.py", line 174, in parse_document_start
    self.peek_token().start_mark)
yaml.parser.ParserError: expected '<document start>', but found '<scalar>'

Obviously, python found the wrong file /mnt/lustre/zhulei1/GitRepo/detrex-custom/detectron2/tools/train_net.py. I'm not sure why this happens. Anyway, this is not a fatal problem and has already some workarounds.

@rentainhe
Copy link
Collaborator

rentainhe commented Mar 2, 2023

I tried installation on two machines. On the first one, it works well. On the second machine, when I run tools/train_net.py, an error occurs as below.

File "/mnt/lustre/zhulei1/GitRepo/detrex-custom/detectron2/tools/train_net.py", line 125, in main
    cfg = setup(args)
  File "/mnt/lustre/zhulei1/GitRepo/detrex-custom/detectron2/tools/train_net.py", line 117, in setup
    cfg.merge_from_file(args.config_file)
  File "/mnt/lustre/zhulei1/GitRepo/detrex-custom/detectron2/detectron2/config/config.py", line 46, in merge_from_file
    loaded_cfg = self.load_yaml_with_base(cfg_filename, allow_unsafe=allow_unsafe)
  File "/mnt/lustre/zhulei1/miniconda3/envs/detrex/lib/python3.7/site-packages/fvcore/common/config.py", line 61, in load_yaml_with_base
    cfg = yaml.safe_load(f)
  File "/mnt/lustre/zhulei1/miniconda3/envs/detrex/lib/python3.7/site-packages/yaml/__init__.py", line 125, in safe_load
    return load(stream, SafeLoader)
  File "/mnt/lustre/zhulei1/miniconda3/envs/detrex/lib/python3.7/site-packages/yaml/__init__.py", line 81, in load
    return loader.get_single_data()
  File "/mnt/lustre/zhulei1/miniconda3/envs/detrex/lib/python3.7/site-packages/yaml/constructor.py", line 49, in get_single_data
    node = self.get_single_node()
  File "/mnt/lustre/zhulei1/miniconda3/envs/detrex/lib/python3.7/site-packages/yaml/composer.py", line 39, in get_single_node
    if not self.check_event(StreamEndEvent):
  File "/mnt/lustre/zhulei1/miniconda3/envs/detrex/lib/python3.7/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
  File "/mnt/lustre/zhulei1/miniconda3/envs/detrex/lib/python3.7/site-packages/yaml/parser.py", line 174, in parse_document_start
    self.peek_token().start_mark)
yaml.parser.ParserError: expected '<document start>', but found '<scalar>'

Obviously, python found the wrong file /mnt/lustre/zhulei1/GitRepo/detrex-custom/detectron2/tools/train_net.py. I'm not sure why this happens. Anyway, this is not a fatal problem and has already some workarounds.

I am wondering how did you install detectron2 and detrex~

Maybe you can follow the official installation guide to see if this problem can be solved~

@rentainhe rentainhe added the bug Something isn't working label Mar 2, 2023
@rayleizhu
Copy link
Contributor Author

I remember that I followed the official installation guide to install detrex exactly. I think you can ignore my problem at this time. Those users who meet the same problem can find this issue and workarounds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants