Repository: pytorch/benchmark
Issue: Installation failed at detectron2_fasterrcnn_r_101_c4: Did not find branch or tag 'c470ca3', assuming revision or ref.
Root cause: Environment Incompatibility

environment: ubuntu 22.10, python 3.10 venv

```
python install.py
checking packages torch, torchvision, torchtext, torchaudio are installed...OK
checking out input files from Amazon S3 ...Checking out https://ossci-datasets.s3.amazonaws.com/torchbench/data/Background_Matting_inputs.tar.gz to /home/user/try/benchmark/torchbenchmark/data/Background_Matting_inputs.tar.gz
Checking out https://ossci-datasets.s3.amazonaws.com/torchbench/data/coco128.tar.gz to /home/user/try/benchmark/torchbenchmark/data/coco128.tar.gz
Checking out https://ossci-datasets.s3.amazonaws.com/torchbench/data/multi30k.tar.gz to /home/user/try/benchmark/torchbenchmark/data/multi30k.tar.gz
Checking out https://ossci-datasets.s3.amazonaws.com/torchbench/data/tacotron2-minimal.tar.gz to /home/user/try/benchmark/torchbenchmark/data/tacotron2-minimal.tar.gz
Checking out https://ossci-datasets.s3.amazonaws.com/torchbench/data/coco2017-minimal.tar.gz to /home/user/try/benchmark/torchbenchmark/data/coco2017-minimal.tar.gz
Checking out https://ossci-datasets.s3.amazonaws.com/torchbench/data/pytorch_stargan_inputs.tar.gz to /home/user/try/benchmark/torchbenchmark/data/pytorch_stargan_inputs.tar.gz
Checking out https://ossci-datasets.s3.amazonaws.com/torchbench/data/LearningToPaint_inputs.tar.gz to /home/user/try/benchmark/torchbenchmark/data/LearningToPaint_inputs.tar.gz
Checking out https://ossci-datasets.s3.amazonaws.com/torchbench/data/pytorch_CycleGAN_and_pix2pix_inputs.tar.gz to /home/user/try/benchmark/torchbenchmark/data/pytorch_CycleGAN_and_pix2pix_inputs.tar.gz
Checking out https://ossci-datasets.s3.amazonaws.com/torchbench/data/Super_SloMo_inputs.tar.gz to /home/user/try/benchmark/torchbenchmark/data/Super_SloMo_inputs.tar.gz
Checking out https://ossci-datasets.s3.amazonaws.com/torchbench/data/speech_transformer_inputs.tar.gz to /home/user/try/benchmark/torchbenchmark/data/speech_transformer_inputs.tar.gz
Checking out https://ossci-datasets.s3.amazonaws.com/torchbench/data/Reddit_minimal.tar.gz to /home/user/try/benchmark/torchbenchmark/data/Reddit_minimal.tar.gz
Checking out https://ossci-datasets.s3.amazonaws.com/torchbench/models/drq/obs.pkl to /home/user/try/benchmark/torchbenchmark/models/drq/obs.pkl
Checking out https://ossci-datasets.s3.amazonaws.com/torchbench/models/maml_omniglot/batch.pt to /home/user/try/benchmark/torchbenchmark/models/maml_omniglot/batch.pt
OK
decompressing input tarball: coco2017-minimal.tar.gz...OK
decompressing input tarball: Background_Matting_inputs.tar.gz...OK
decompressing input tarball: multi30k.tar.gz...OK
decompressing input tarball: coco128.tar.gz...OK
decompressing input tarball: Super_SloMo_inputs.tar.gz...OK
decompressing input tarball: tacotron2-minimal.tar.gz...OK
decompressing input tarball: pytorch_stargan_inputs.tar.gz...OK
decompressing input tarball: pytorch_CycleGAN_and_pix2pix_inputs.tar.gz...OK
decompressing input tarball: Reddit_minimal.tar.gz...OK
decompressing input tarball: speech_transformer_inputs.tar.gz...OK
decompressing input tarball: LearningToPaint_inputs.tar.gz...OK
running setup for /home/user/try/benchmark/torchbenchmark/models/BERT_pytorch...OK
running setup for /home/user/try/benchmark/torchbenchmark/models/Background_Matting...OK
running setup for /home/user/try/benchmark/torchbenchmark/models/DALLE2_pytorch...OK
running setup for /home/user/try/benchmark/torchbenchmark/models/LearningToPaint...OK
running setup for /home/user/try/benchmark/torchbenchmark/models/Super_SloMo...OK
running setup for /home/user/try/benchmark/torchbenchmark/models/alexnet...OK
running setup for /home/user/try/benchmark/torchbenchmark/models/attention_is_all_you_need_pytorch...OK
running setup for /home/user/try/benchmark/torchbenchmark/models/dcgan...OK
running setup for /home/user/try/benchmark/torchbenchmark/models/demucs...OK
running setup for /home/user/try/benchmark/torchbenchmark/models/densenet121...OK
running setup for /home/user/try/benchmark/torchbenchmark/models/detectron2_fasterrcnn_r_101_c4...FAIL
Error for /home/user/try/benchmark/torchbenchmark/models/detectron2_fasterrcnn_r_101_c4:
---------------------------------------------------------------------------
  WARNING: Did not find branch or tag 'c470ca3', assuming revision or ref.
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [389 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.10
      creating build/lib.linux-x86_64-3.10/detectron2
      copying detectron2/__init__.py -> build/lib.linux-x86_64-3.10/detectron2
      creating build/lib.linux-x86_64-3.10/tools
      copying tools/benchmark.py -> build/lib.linux-x86_64-3.10/tools
      copying tools/lightning_train_net.py -> build/lib.linux-x86_64-3.10/tools
      copying tools/convert-torchvision-to-d2.py -> build/lib.linux-x86_64-3.10/tools
      copying tools/train_net.py -> build/lib.linux-x86_64-3.10/tools
      copying tools/analyze_model.py -> build/lib.linux-x86_64-3.10/tools
      copying tools/lazyconfig_train_net.py -> build/lib.linux-x86_64-3.10/tools
...
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> detectron2

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
Traceback (most recent call last):
  File "/home/user/try/benchmark/torchbenchmark/models/detectron2_fasterrcnn_r_101_c4/install.py", line 8, in <module>
    install_detectron2(MODEL_NAME, MODEL_DIR)
  File "/home/user/try/benchmark/torchbenchmark/util/framework/detectron2/__init__.py", line 61, in install_detectron2
    pip_install_requirements()
  File "/home/user/try/benchmark/torchbenchmark/util/framework/detectron2/__init__.py", line 43, in pip_install_requirements
    subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', requirements_file])
  File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/home/user/try/env/bin/python', '-m', 'pip', 'install', '-q', '-r', '/home/user/try/benchmark/torchbenchmark/util/framework/detectron2/requirements.txt']' returned non-zero exit status 1.


---------------------------------------------------------------------------

Traceback (most recent call last):
  File "/home/user/try/benchmark/install.py", line 114, in <module>
    raise RuntimeError("Failed to complete setup")
RuntimeError: Failed to complete setup
```

Could you add the following code after [this line](https://github.com/pytorch/benchmark/blob/main/torchbenchmark/__init__.py#L143) and try again? I remember I've seen this before. 

```
import time
time.sleep(1)
```

This is a warning, not the actuall root cause error. Can you try `pip install -r /home/user/try/benchmark/torchbenchmark/util/framework/detectron2/requirements.txt` and provide the actual error message?

> Could you add the following code after [this line](https://github.com/pytorch/benchmark/blob/main/torchbenchmark/__init__.py#L143) and try again? I remember I've seen this before.
> 
> ```
> import time
> time.sleep(1)
> ```

Thanks for the suggestion. Unfortunately, this doesn't help. I got the same error.

> This is a warning, not the actuall root cause error. Can you try `pip install -r /home/user/try/benchmark/torchbenchmark/util/framework/detectron2/requirements.txt` and provide the actual error message?

this is the way. I was able to identify that g++ was not installed in my system.
```
      subprocess.CalledProcessError: Command '['which', 'x86_64-linux-gnu-g++']' returned non-zero exit status 1.
```
and after installing g++ the problem disappeared. 

I'd suggest that you mention it in the readme, that packages python3-dev and build-essential are necessary to successfully build the benchmark.

> > This is a warning, not the actuall root cause error. Can you try `pip install -r /home/user/try/benchmark/torchbenchmark/util/framework/detectron2/requirements.txt` and provide the actual error message?
> 
> this is the way. I was able to identify that g++ was not installed in my system.
> 
> ```
>       subprocess.CalledProcessError: Command '['which', 'x86_64-linux-gnu-g++']' returned non-zero exit status 1.
> ```
> 
> and after installing g++ the problem disappeared.
> 
> I'd suggest that you mention it in the readme, that packages python3-dev and build-essential are necessary to successfully build the benchmark.

Thanks for the suggestion. The name of the packages are distribution-dependent, and we can't enumerate the package names for all Linux distributions. But I think at least we can provide the names for our CI environment, which is Ubuntu 20.04.