Skip to content

Instantly share code, notes, and snippets.

@NeilPandya
Created September 21, 2024 18:54
Show Gist options
  • Save NeilPandya/1c24d866e4a06dfd00bc63cd74053a71 to your computer and use it in GitHub Desktop.
Save NeilPandya/1c24d866e4a06dfd00bc63cd74053a71 to your computer and use it in GitHub Desktop.
Check OpenCV with PyTorch
import torch
import os
print('availabe:',torch.cuda.is_available() )
print('devices available', torch.cuda.device_count())
print('device id:',torch.cuda.current_device() )
print('device address', torch.cuda.device(0))
print('gpu model',torch.cuda.get_device_name(0))
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
print('Using device:', device)
#Additional Info when using cuda
if device.type == 'cuda':
print(torch.cuda.get_device_name(0))
print('Memory Usage:')
print('Allocated:', round(torch.cuda.memory_allocated(0)/1024**3,1), 'GB')
print('Cached: ', round(torch.cuda.memory_reserved(0)/1024**3,1), 'GB')
import cv2
print("DNN_BACKEND_CUDA",cv2.dnn.DNN_BACKEND_CUDA)
print("DNN_BACKEND_CUDA",cv2.dnn.DNN_TARGET_CUDA)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment