6adb63b915
date: 2026-06-04T09:49:56 master commit: c0ab3550eca2e9daf197c46b7e4b24aa9637cf2e
27 lines
790 B
Python
27 lines
790 B
Python
import json
|
|
from pathlib import Path
|
|
|
|
MODELS_DIR = Path(__file__).resolve().parent / 'models'
|
|
TG_INPUT_DEVICES_PATH = MODELS_DIR / 'tg_input_devices.json'
|
|
USBGPU_VID = 0xADD1
|
|
USBGPU_PID = 0x0001
|
|
|
|
|
|
def get_tg_input_devices(process_name: str, usbgpu: bool):
|
|
with open(TG_INPUT_DEVICES_PATH) as f:
|
|
return json.load(f)[process_name]['default' if not usbgpu else 'usbgpu']
|
|
|
|
def modeld_pkl_path(usbgpu: bool):
|
|
prefix = 'big_' if usbgpu else ''
|
|
return MODELS_DIR / f'{prefix}driving_tinygrad.pkl'
|
|
|
|
def usbgpu_present() -> bool:
|
|
for d in Path("/sys/bus/usb/devices").glob("*"):
|
|
try:
|
|
if int((d / "idVendor").read_text(), 16) == USBGPU_VID and \
|
|
int((d / "idProduct").read_text(), 16) == USBGPU_PID:
|
|
return True
|
|
except Exception:
|
|
pass
|
|
return False
|