Backport gpu hang fixes from master

Cherry-pick