MogensR's picture
4.41.3
23dc493
raw
history blame contribute delete
598 Bytes
# utils/perf_tuning.py
import os, logging
try:
import cv2
except Exception:
cv2 = None
import torch
def apply():
os.environ.setdefault("OMP_NUM_THREADS", "4")
if cv2:
try:
cv2.setNumThreads(4)
except Exception as e:
logging.info("cv2 threads not set: %s", e)
if torch.cuda.is_available():
torch.backends.cudnn.benchmark = True
try:
logging.info("CUDA device %s β€” cuDNN benchmark ON", torch.cuda.get_device_name(0))
except Exception:
logging.info("CUDA available β€” cuDNN benchmark ON")