Youtube tutorial: https://youtu.be/Us3oB6JwwBQ
Ultralytics recommend to install pytorch first from official website as per your cuda version-
https://pytorch.org/get-started/locally.
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
pip install Ultralytics