-
Notifications
You must be signed in to change notification settings - Fork 0
/
sys_check.py
41 lines (30 loc) · 1.06 KB
/
sys_check.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from camera_perception.common import pytorch_info
# YOLO check
import ultralytics
ultralytics.checks()
# CUDA/CPU check
import torch
import torchvision
version, engine = pytorch_info(torch.__version__)
version_vision, engine_vision = pytorch_info(torchvision.__version__)
if engine != engine_vision:
print(
f"torch and torchvision packages are not compatible:\n"
f"torch: {engine} {version}\n"
f"torchvision: {engine_vision} {version_vision}"
)
exit(1)
if engine == "cu" and not torch.cuda.is_available():
print(
f"CUDA is not available but PyTorch {engine.upper()} {version} is installed. "
f"Check environment configuration for conflicted packages."
)
exit(1)
if not torch.cuda.is_available():
print(f"CUDA is not available. PyTorch {engine.upper()} {version} will be used.")
exit(0)
if engine == "cpu" and torch.cuda.is_available():
print(
f"CUDA is available but PyTorch {engine.upper()} {version} is used. "
f"Check environment configuration for better performance."
)