See how skypilot does it: https://github.com/skypilot-org/skypilot/blob/master/sky/provision/primeintellect/utils.py#L81