csuhan / opendet2

Official code of the paper "Expanding Low-Density Latent Regions for Open-Set Object Detection" (CVPR 2022)
https://arxiv.org/abs/2203.14911
104 stars 11 forks source link

error: Multiple top-level packages discovered in a flat-layout: ['demo', 'configs', 'opendet2', 'datasets', 'detectron2']. #6

Closed ChibisukeDragon closed 2 years ago

ChibisukeDragon commented 2 years ago

When I followed the README to install opendet2, I got some trouble. Here is my command. I have several rtx3090 gpus.

# CUDA V11.1
# torch 1.9.0
# python 3.8
conda create -n opendet2 python=3.8 -y
conda activate opendet2
# get pytorch 1.9.0. I got RuntimeError: CUDA error: device-side assert triggered when using torch 1.8.1
pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html
# build opencv
pip install opencv-python
pip install opencv-contrib-python
# build detectron2. DO NOT build detectron2 from latest SOURCE. In the latest version, some named methods have been removed.
pip install detectron2==0.5 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu111/torch1.9/index.html
# build opendet2
cd opendet2
pip install -v -e .

When I run the last command pip install -v -e ., I got these error message:

(opendet2) yupeng@ubuntu:~/opendet/opendet2$ pip install -v -e .
Using pip 21.2.4 from /home/yupeng/anaconda3/envs/opendet2/lib/python3.8/site-packages/pip (python 3.8)
Looking in indexes: https://mirrors.bfsu.edu.cn/pypi/web/simple/
Obtaining file:///home/yupeng/opendet/opendet2
    Running command python setup.py egg_info
    error: Multiple top-level packages discovered in a flat-layout: ['demo', 'configs', 'opendet2', 'datasets', 'detectron2'].

    To avoid accidental inclusion of unwanted files or directories,
    setuptools will not proceed with this build.

    If you are trying to create a single distribution with multiple packages
    on purpose, you should not rely on automatic discovery.
    Instead, consider the following options:

    1. set up custom discovery (`find` directive with `include` or `exclude`)
    2. use a `src-layout`
    3. explicitly set `py_modules` or `packages` with a list of names

    To find more information, look for "package discovery" on setuptools docs.
WARNING: Discarding file:///home/yupeng/opendet/opendet2. Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
(opendet2) yupeng@ubuntu:~/opendet/opendet2$

I could use pip install setuptools==58.2.0 and retry pip install -v -e ., then everything is fine. It seems there are some problems by using the lateset setuptools>=61.0. Maybe you can find more information in the link below: https://github.com/pypa/setuptools/issues/3197 https://github.com/pypa/setuptools/issues/3227 https://github.com/facebookresearch/detectron2/issues/3943 https://github.com/facebookresearch/detectron2/issues/3811 Good luck.

ChibisukeDragon commented 2 years ago

Thank for your CVPR work.

ChibisukeDragon commented 2 years ago

When I wanted to train_net in a new server, I got a new problem.

Traceback (most recent call last):
  File "train_net.py", line 101, in <module>
    launch(
  File "/home/yupeng/opendet2/opendet2/detectron2/detectron2/engine/launch.py", line 82, in launch
    main_func(*args)
  File "train_net.py", line 59, in main
    trainer = OpenDetTrainer(cfg)
  File "/home/yupeng/opendet2/opendet2/opendet2/engine/defaults.py", line 121, in __init__
    self.register_hooks(self.build_hooks())
  File "/home/yupeng/opendet2/opendet2/opendet2/engine/defaults.py", line 195, in build_hooks
    ret.append(hooks.PeriodicWriter(self.build_writers(), period=20))
  File "/home/yupeng/opendet2/opendet2/opendet2/engine/defaults.py", line 207, in build_writers
    return default_writers(self.cfg.OUTPUT_DIR, self.max_iter)
  File "/home/yupeng/opendet2/opendet2/detectron2/detectron2/engine/defaults.py", line 253, in default_writers
    TensorboardXWriter(output_dir),
  File "/home/yupeng/opendet2/opendet2/detectron2/detectron2/utils/events.py", line 145, in __init__
    from torch.utils.tensorboard import SummaryWriter
  File "/home/yupeng/anaconda3/envs/opendet2/lib/python3.8/site-packages/torch/utils/tensorboard/__init__.py", line 13, in <module>
    from .writer import FileWriter, SummaryWriter  # noqa: F401
  File "/home/yupeng/anaconda3/envs/opendet2/lib/python3.8/site-packages/torch/utils/tensorboard/writer.py", line 9, in <module>
    from tensorboard.compat.proto.event_pb2 import SessionLog
  File "/home/yupeng/anaconda3/envs/opendet2/lib/python3.8/site-packages/tensorboard/compat/proto/event_pb2.py", line 17, in <module>
    from tensorboard.compat.proto import summary_pb2 as tensorboard_dot_compat_dot_proto_dot_summary__pb2
  File "/home/yupeng/anaconda3/envs/opendet2/lib/python3.8/site-packages/tensorboard/compat/proto/summary_pb2.py", line 17, in <module>
    from tensorboard.compat.proto import tensor_pb2 as tensorboard_dot_compat_dot_proto_dot_tensor__pb2
  File "/home/yupeng/anaconda3/envs/opendet2/lib/python3.8/site-packages/tensorboard/compat/proto/tensor_pb2.py", line 16, in <module>
    from tensorboard.compat.proto import resource_handle_pb2 as tensorboard_dot_compat_dot_proto_dot_resource__handle__pb2
  File "/home/yupeng/anaconda3/envs/opendet2/lib/python3.8/site-packages/tensorboard/compat/proto/resource_handle_pb2.py", line 16, in <module>
    from tensorboard.compat.proto import tensor_shape_pb2 as tensorboard_dot_compat_dot_proto_dot_tensor__shape__pb2
  File "/home/yupeng/anaconda3/envs/opendet2/lib/python3.8/site-packages/tensorboard/compat/proto/tensor_shape_pb2.py", line 36, in <module>
    _descriptor.FieldDescriptor(
  File "/home/yupeng/anaconda3/envs/opendet2/lib/python3.8/site-packages/google/protobuf/descriptor.py", line 560, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
(opendet2) yupeng@node01:/home/yupeng/opendet2/opendet2$

I can solve this by using pip install protobuf==3.20.1