Occassional OverflowError with mps running yolov7
Labels: triaged, module: mps

### 🐛 Describe the bug

clone the project from https://github.com/WongKinYiu/yolov7 and instal packages in `requirments.txt`
and modify function ```select_device``` in ./utils/pytorch_utils.py like below
```python
def select_device(device='', batch_size=None):
    # device = 'cpu' or '0' or '0,1,2,3'
    s = f'YOLOR 🚀 {git_describe() or date_modified()} torch {torch.__version__} '  # string
    cpu = device.lower() == 'cpu'
    if cpu:
        os.environ['CUDA_VISIBLE_DEVICES'] = '-1'  # force torch.cuda.is_available() = False
    elif device:  # non-cpu device requested
        os.environ['CUDA_VISIBLE_DEVICES'] = device  # set environment variable
        assert torch.cuda.is_available(), f'CUDA unavailable, invalid device {device} requested'  # check availability

    cuda = not cpu and torch.cuda.is_available()
    mps = not cpu and torch.backends.mps.is_available()
    if cuda:
        n = torch.cuda.device_count()
        if n > 1 and batch_size:  # check that batch_size is compatible with device_count
            assert batch_size % n == 0, f'batch-size {batch_size} not multiple of GPU count {n}'
        space = ' ' * len(s)
        for i, d in enumerate(device.split(',') if device else range(n)):
            p = torch.cuda.get_device_properties(i)
            s += f"{'' if i == 0 else space}CUDA:{d} ({p.name}, {p.total_memory / 1024 ** 2}MB)\n"  # bytes to MB
    elif mps:
        s += 'MPS\n'
    else:
        s += 'CPU\n'

    logger.info(s.encode().decode('ascii', 'ignore') if platform.system() == 'Windows' else s)  # emoji-safe
    return torch.device('cuda:0' if cuda else 'mps' if mps else 'cpu')
```
this literally select mps when it is available.
then run with command
```export PYTORCH_ENABLE_MPS_FALLBACK=1; python detect.py --weights yolov7-e6e.pt --source path/to/source.png```
The error 
```
Traceback (most recent call last):
  File "/Users/Frank/PycharmProjects/yolov7/detect.py", line 197, in <module>
    detect()
  File "/Users/Frank/PycharmProjects/yolov7/detect.py", line 130, in detect
    plot_one_box(xyxy, im0, label=label, color=colors[int(cls)], line_thickness=1)
  File "/Users/Frank/PycharmProjects/yolov7/utils/plots.py", line 61, in plot_one_box
    c1, c2 = (int(x[0]), int(x[1])), (int(x[2]), int(x[3]))
OverflowError: cannot convert float infinity to integer
Namespace(weights=['yolov7-e6e.pt'], source='/Users/Frank/Notebooks/jupyter/skiing_img/images/0.png', img_size=640, conf_thres=0.25, iou_thres=0.45, device='', view_img=False, save_txt=False, save_conf=False, nosave=False, classes=None, agnostic_nms=False, augment=False, update=False, project='runs/detect', name='exp', exist_ok=False, no_trace=False)
```
occurs 4 times out of 11 runs.

### Versions

```PyTorch version: 1.13.1
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 13.1 (arm64)
GCC version: Could not collect
Clang version: 14.0.0 (clang-1400.0.29.202)
CMake version: version 3.23.0
Libc version: N/A

Python version: 3.9.15 (main, Nov 24 2022, 08:28:41)  [Clang 14.0.6 ] (64-bit runtime)
Python platform: macOS-13.1-arm64-arm-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] numpy==1.23.5
[pip3] torch==1.13.1
[pip3] torchvision==0.14.1
[conda] numpy                     1.23.5                   pypi_0    pypi
[conda] torch                     1.13.1                   pypi_0    pypi
[conda] torchvision               0.14.1                   pypi_0    pypi
```
gcc version given by `gcc --version`is 
```
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin22.2.0
Thread model: posix
```

cc @kulinseth @albanD @malfet @DenisVieriu97 @razarmehr @abhudev