facebookresearch / maskrcnn-benchmark

Fast, modular reference implementation of Instance Segmentation and Object Detection algorithms in PyTorch.
MIT License
9.31k stars 2.49k forks source link

if torch._six.PY3: AttributeError: module 'torch._six' has no attribute 'PY3' #1341

Closed Souryadipstan closed 2 years ago

Souryadipstan commented 2 years ago

from maskrcnn_benchmark.utils.imports import import_file File "/home/nikhilanand_1921cs24/Souryadip/Extra/vilbert-multi-task/maskrcnn-benchmark/maskrcnn_benchmark/utils/imports.py", line 4, in if torch._six.PY3: AttributeError: module 'torch._six' has no attribute 'PY3'

Error showing while running the script after installation.

torch version : 1.10.1, Cuda : 11.3, python : 3.7.13

Souryadipstan commented 2 years ago

Found out torch._six.PY3 is not available with the latest pytorch versions. But, .PY37 is present in the torch._six module. So, Changing .PY3 to .PY37 in the imports.py file worked somehow and the code ran without any issue.

ProtossDragoon commented 2 years ago

Hi, could you share some tips to run on CUDA >= 11 / torch >= 1.10? (python3.7) When I call python setup.py build develop, compile error raised.

ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "/miniconda/envs/py37/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1814, in _run_ninja_build
    env=env)
  File "/miniconda/envs/py37/lib/python3.7/subprocess.py", line 468, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "setup.py", line 65, in <module>
    cmdclass={"build_ext": torch.utils.cpp_extension.BuildExtension},
  File "/miniconda/envs/py37/lib/python3.7/site-packages/setuptools/__init__.py", line 87, in setup
    return distutils.core.setup(**attrs)
  File "/miniconda/envs/py37/lib/python3.7/site-packages/setuptools/_distutils/core.py", line 185, in setup
    return run_commands(dist)
  File "/miniconda/envs/py37/lib/python3.7/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
    dist.run_commands()
  File "/miniconda/envs/py37/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 973, in run_commands
    self.run_command(cmd)
  File "/miniconda/envs/py37/lib/python3.7/site-packages/setuptools/dist.py", line 1217, in run_command
    super().run_command(command)
  File "/miniconda/envs/py37/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 992, in run_command
    cmd_obj.run()
  File "/miniconda/envs/py37/lib/python3.7/site-packages/setuptools/command/build.py", line 24, in run
    super().run()
  File "/miniconda/envs/py37/lib/python3.7/site-packages/setuptools/_distutils/command/build.py", line 132, in run
    self.run_command(cmd_name)
  File "/miniconda/envs/py37/lib/python3.7/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
    self.distribution.run_command(command)
  File "/miniconda/envs/py37/lib/python3.7/site-packages/setuptools/dist.py", line 1217, in run_command
    super().run_command(command)
  File "/miniconda/envs/py37/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 992, in run_command
    cmd_obj.run()
  File "/miniconda/envs/py37/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 79, in run
    _build_ext.run(self)
  File "/miniconda/envs/py37/lib/python3.7/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
    _build_ext.build_ext.run(self)
  File "/miniconda/envs/py37/lib/python3.7/site-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
    self.build_extensions()
  File "/miniconda/envs/py37/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 765, in build_extensions
    build_ext.build_extensions(self)
  File "/miniconda/envs/py37/lib/python3.7/site-packages/Cython/Distutils/old_build_ext.py", line 195, in build_extensions
    _build_ext.build_ext.build_extensions(self)
  File "/miniconda/envs/py37/lib/python3.7/site-packages/setuptools/_distutils/command/build_ext.py", line 466, in build_extensions
    self._build_extensions_serial()
  File "/miniconda/envs/py37/lib/python3.7/site-packages/setuptools/_distutils/command/build_ext.py", line 492, in _build_extensions_serial
    self.build_extension(ext)
  File "/miniconda/envs/py37/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 202, in build_extension
    _build_ext.build_extension(self, ext)
  File "/miniconda/envs/py37/lib/python3.7/site-packages/setuptools/_distutils/command/build_ext.py", line 554, in build_extension
    depends=ext.depends,
  File "/miniconda/envs/py37/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 595, in unix_wrap_ninja_compile
    with_cuda=with_cuda)
  File "/miniconda/envs/py37/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1492, in _write_ninja_file_and_compile_objects
    error_prefix='Error compiling objects for extension')
  File "/miniconda/envs/py37/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1824, in _run_ninja_build
    raise RuntimeError(message) from e
RuntimeError: Error compiling objects for extension
ProtossDragoon commented 2 years ago

Thanks!

https://github.com/facebookresearch/maskrcnn-benchmark/issues/1340