Open rayleizhu opened 1 year ago
We will check this later~
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:
- pip uninstall detrex && pip uninstall detectron2 && pip install -e . && pip install -e detectron2 (tested)
- 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
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 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~
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.
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:
See if you have more elegant solutions.