RuntimeError: The current installed version of g++ (11.3.0) is greater than the maximum required version by CUDA 11.2. Please make sure to use an adequate version of g++ (>=5.0.0, <11.0)
gcc --version
sudo apt -y install gcc-10 g++-10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10
https://github.com/facebookresearch/detectron2/issues/667
subprocess.CalledProcessError: Command '['which', 'c++']' returned non-zero exit status 1
As INSTALL.md says you need gcc>=4.9.