{"id":24475579,"url":"https://github.com/nathom/tpu-utils","last_synced_at":"2025-03-14T15:43:19.039Z","repository":{"id":272696889,"uuid":"917459927","full_name":"nathom/tpu-utils","owner":"nathom","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-16T05:02:19.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-09T19:56:08.329Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nathom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-16T02:57:40.000Z","updated_at":"2025-01-16T05:06:29.000Z","dependencies_parsed_at":"2025-01-16T04:30:32.868Z","dependency_job_id":"915eee85-2dfc-4485-821f-ca2b47a6e0be","html_url":"https://github.com/nathom/tpu-utils","commit_stats":null,"previous_names":["nathom/tpu-utils"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathom%2Ftpu-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathom%2Ftpu-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathom%2Ftpu-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathom%2Ftpu-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nathom","download_url":"https://codeload.github.com/nathom/tpu-utils/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243603243,"owners_count":20317800,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-21T09:15:28.362Z","updated_at":"2025-03-14T15:43:19.010Z","avatar_url":"https://github.com/nathom.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tpu-utils\n\nSome handy scripts for TPU pods.\n\nTo install, clone this repo and create a file called `secrets.py` that contain the following 4 variables:\n\n```python\nTPU_NAME = \"your-tpu-name\"\nZONE = \"your-zone\"\nPROJECT = \"your-project-id\"\n\n# environment variables to inject\nenvironment = {\n    'WANDB_API_KEY': 'your-wandb-api-key',\n    'HF_TOKEN': 'your-hf-token',\n    'CUDA_VISIBLE_DEVICES': '-1',\n    # etc.\n}\n\n# other stuff you want in .bashrc\nmisc_bashrc = \"\"\"\nset -o vi\n\"\"\"\n```\n\nThen run `setup_tpu.py`, and restart the shell. \nNow you should have access to the following commands on your machine:\n\n- `podrun \u003ccommand\u003e [-f|--file \u003cscript.sh\u003e]`: Executes a shell command or script on all TPU workers. You can either pass the command directly or specify a file containing the script.\n\n- `podrunpy \u003ccommand\u003e [-f|--file \u003cscript.py\u003e]`: Executes a Python command or script on all TPU workers. You can either pass the command directly or specify a file containing the script.\n\n- `podkill`: Terminates all Python processes running on the TPU workers.\n\nIf you want to install this on every machine:\n\n```bash\npodrunpy setup_tpu.py -i pod_commands.sh secrets.py\n```\n\nWe include the two files because `setup_tpu.py` depends on them.\n\n## Command reference\n\n### `podrun`\n\n**Description:**\nExecutes a command on all workers of a TPU VM.\n\n**Usage:**\n```sh\npodrun \u003ccommand\u003e [-f|--file \u003cscript.sh\u003e]\n```\n\n**Arguments:**\n- `\u003ccommand\u003e`: The command to execute on the TPU VM workers.\n- `-f|--file \u003cscript.sh\u003e`: Optional. Specifies a script file whose contents will be executed on the TPU VM workers.\n\n**Example:**\n```sh\npodrun \"echo Hello, World!\"\npodrun -f my_script.sh\n```\n\n### `podrunpy`\n\n**Description:**\nExecutes a Python script or command on all workers of a TPU VM. Supports including additional files or directories.\n\n**Usage:**\n```sh\npodrunpy \u003cscript.py\u003e [-i|--include FILE...] | -c|--command \u003cpython_code\u003e [-i|--include FILE...]\n```\n\n**Arguments:**\n- `\u003cscript.py\u003e`: The Python script file to execute on the TPU VM workers.\n- `-i|--include FILE...`: Optional. Specifies additional files or directories to include when executing the script or command.\n- `-c|--command \u003cpython_code\u003e`: Optional. Specifies a raw Python command to execute on the TPU VM workers.\n\n**Example:**\n```sh\npodrunpy my_script.py\npodrunpy my_script.py -i helper_module.py config.json\npodrunpy -c \"print('Hello, World!')\" -i helper_module.py\n```\n\n### `podkill`\n\n**Description:**\nKills all Python processes running on all workers of a TPU VM.\n\n**Usage:**\n```sh\npodkill\n```\n\n**Example:**\n```sh\npodkill\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathom%2Ftpu-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnathom%2Ftpu-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathom%2Ftpu-utils/lists"}