Closed BirenMer closed 1 week ago
I cannot help you without more information. When CUDA is not available you will receive a message similar to this
ValueError: Invalid CUDA 'device=0' requested. Use 'device=cpu' or pass valid CUDA device(s) if available, i.e. 'device=0' or 'device=0,1,2,3' for Multi-GPU.
torch.cuda.is_available(): False
torch.cuda.device_count(): 0
os.environ['CUDA_VISIBLE_DEVICES']: None
See https://pytorch.org/get-started/locally/ for up-to-date torch install instructions if no CUDA devices are seen by torch.
I cannot help you without more information. When CUDA is not available you will receive a message similar to this
ValueError: Invalid CUDA 'device=0' requested. Use 'device=cpu' or pass valid CUDA device(s) if available, i.e. 'device=0' or 'device=0,1,2,3' for Multi-GPU. torch.cuda.is_available(): False torch.cuda.device_count(): 0 os.environ['CUDA_VISIBLE_DEVICES']: None See https://pytorch.org/get-started/locally/ for up-to-date torch install instructions if no CUDA devices are seen by torch.
Sir I am actually getting no error messages, When I see my gpu usage while running the code they are near to zero and my cpu usage is sky rocketing, If I stop the tracking part and run only YOLO for detection then my CPU usage is normal.
So at this point I am also confused why it is happening.
Try device=0
Search before asking
Question
Below is my code for initializing a tracker strong sort or deep_oc_sort, also my problem is no matter what I do the code runs on my CPU insted of my GPU card (I have two GPU's in th system)
from pathlib import Path from boxmot import StrongSORT from boxmot import DeepOCSORT
def tracker_init(tracker_name:str='strong_sort',reid_model_path:str='models/osnet_x0_25_msmt17.pt',cuda_device:bool=True,cuda_device_number:int=0): """ Usage: Used to initialize trackers || Default=strong_sort Currently support two Trackers :
deep_oc_sort Args :
Returns : Returns a tracker object
List of available reid model : ['resnet50', 'resnet101', 'mobilenetv2_x1_0', 'mobilenetv2_x1_4', 'hacnn', 'mlfn', 'osnet_x1_0', 'osnet_x0_75', 'osnet_x0_5', 'osnet_x0_25', 'osnet_ibn_x1_0', 'osnet_ain_x1_0', 'osnet_ain_x0_75', 'osnet_ain_x0_5', 'osnet_ain_x0_25', 'lmbn_n', 'clip'] """ tracker=None if tracker_name=='deep_oc_sort': tracker = DeepOCSORT( model_weights=Path(reid_model_path), # which ReID model to use device=f'cuda:{cuda_device_number}' if cuda_device else 'cpu', fp16=False, )
else: tracker = StrongSORT( model_weights=Path(reid_model_path), # which ReID model to use device=f'cuda:{cuda_device_number}' if cuda_device else 'cpu', fp16=False, ) return tracker
Please let me know what I am doing wrong