Skip to content

Instantly share code, notes, and snippets.

View matomatical's full-sized avatar
🐢
The unexamined life is not to be lived.

Matthew Farrugia-Roberts matomatical

🐢
The unexamined life is not to be lived.
View GitHub Profile
@skye
skye / tpu_topology_env_vars.py
Last active March 28, 2024 05:52
You can use these environment variables to run a Python process on a subset of the TPU cores on a Cloud TPU VM. This allows running multiple TPU processes at the same time, since only one process can access a given TPU chip at a time. Note that on TPU v2 and v3, 1 TPU chip = 2 TpuDevice as reported by `jax.devices()` (8 devices total). On v4, 1 …
# ==== Non-communicating processes
# 4x 1 chip per process:
os.environ["TPU_CHIPS_PER_PROCESS_BOUNDS"] = "1,1,1"
os.environ["TPU_PROCESS_BOUNDS"] = "1,1,1"
# Different per process:
os.environ["TPU_VISIBLE_DEVICES"] = "0" # "1", "2", "3"
# Pick a unique port per process
os.environ["TPU_MESH_CONTROLLER_ADDRESS"] = "localhost:8476"
os.environ["TPU_MESH_CONTROLLER_PORT"] = "8476"
@swablueme
swablueme / echodownloader.py
Last active July 3, 2018 11:01
downloads unimelb echo lectures
import requests
import os.path
import json
import re
#URL for echo
baseurl="https://echo360.org.au"
#list of subject names with which to name folders
subjectname=["COMP10001", "another_subject"]
@Joshua1989
Joshua1989 / fg_helper.py
Last active April 2, 2019 19:23
Fast tikz Factor Graph drawing based on python3+tkinter, just run it, build your graph by clicking and hit return, then the tikz code is in your clipboard
from tkinter import *
from string import Template
import clipboard
root = Tk()
# Make the window transparent, bring it to topmost
root.wait_visibility(root)
root.attributes('-alpha', 0.5)
# Note sometimes this causes other windows to hide, still figuring what happened
root.attributes('-topmost', True)