Running on Windows 11, installed using the pip command on the website.
CUDA 1.8
I am able to run using the CPU but when I set device=‘0’ it crashes giving me the following error:
Could not run 'torchvision::nms' with arguments from the 'CUDA' backend. This could be because the operator doesn't exist for this backend, or was omitted during the selective/custom build process (if using custom build). If you are a Facebook employee using PyTorch on mobile, please visit https://fburl.com/ptmfixes for possible resolutions. 'torchvision::nms' is only available for these backends: [CPU, QuantizedCPU, BackendSelect, Python, FuncTorchDynamicLayerBackMode, Functionalize, Named, Conjugate, Negative, ZeroTensor, ADInplaceOrView, AutogradOther, AutogradCPU, AutogradCUDA, AutogradXLA, AutogradMPS, AutogradXPU, AutogradHPU, AutogradLazy, AutogradMeta, Tracer, AutocastCPU, AutocastCUDA, FuncTorchBatched, FuncTorchVmapMode, Batched, VmapMode, FuncTorchGradWrapper, PythonTLSSnapshot, FuncTorchDynamicLayerFrontMode, PythonDispatcher].
Running on Windows 11
Verifying pytorch in my console:
PS C:\Users\Dusti> python
Python 3.10.10 (tags/v3.10.10:aad5f6a, Feb 7 2023, 17:20:36) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.rand(3)
tensor([0.2497, 0.1301, 0.3781])
>>> torch.cuda.is_available()
True
>>> torch.cuda.device_count()
1
>>> torch.cuda.current_device()
0
>>> torch.cuda.device(0)
<torch.cuda.device object at 0x0000017B6D0104F0>
>>> torch.cuda.get_device_name(0)
'NVIDIA GeForce RTX 3070 Ti'
My script:
import cv2
from ultralytics import YOLO
def main():
cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 780)
model = YOLO("yolov8l.pt")
while True:
ret, frame = cap.read()
cv2.imshow("yolov8", frame)
result = model(frame, device='0')
if(cv2.waitKey(30) == 27):
break
if __name__ == "__main__":
main()