USB+AMD device lock not released after open fails
Author: elkoledCreated Sep 24, 2026Updated Sep 24, 2026
Bug on pinned tinygrad in openpilot master 9d0446a4b.
USBPCIDevice.__init__ doesn't release lock and USB handle on failure, so the device can't be opened again in the same process.
Repro (comma four)
echo 0 | sudo tee /sys/bus/usb/devices/4-1/authorized
GMMU=0 DEV=USB+AMD python3
>>> from tinygrad import Device
>>> Device["AMD"]
RuntimeError: libusb_claim_interface: Entity not found
# reconnect in another shell:
echo 1 | sudo tee /sys/bus/usb/devices/4-1/authorized
>>> Device["AMD"]
RuntimeError: Failed to acquire lock file am_usb:4-2.lockSource: tinygrad/tinygrad