Skip to content

Commit

Permalink
Merge pull request #12 from shamspias/feat/rt-detr
Browse files Browse the repository at this point in the history
set cuda device
  • Loading branch information
shamspias authored Sep 16, 2024
2 parents 16f4e81 + c97e89d commit 38bb650
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ def __init__(self, config, video_path, frame_rate, output_dir, model_path, class
self.image_processor = ImageProcessor(output_size=self.transformations.get('size', (640, 640)))

# Set the device (CUDA or CPU)
self.device = 'cuda' if torch.cuda.is_available() else 'cpu'

# Ensure CUDA is available
if torch.cuda.is_available():
torch.cuda.set_device(0) # Sets GPU 0 (modify if using multiple GPUs)
self.device = 'cuda'
else:
self.device = 'cpu'
# Only initialize SahiUtils if SAHI is enabled
if sahi_config:
self.sahi_utils = SahiUtils(self.config.debug, self.supported_classes_map,
Expand Down

0 comments on commit 38bb650

Please sign in to comment.