Skip to content

Instantly share code, notes, and snippets.

https://cdn.shopify.com/s/files/1/0317/7116/4804/files/Rasur_Guide_Updated_2022_komprimiert.pdf
"""
Repro for ownership issue with Python stores for torch.distributed.
rm -rf /tmp/store_bug; for i in {0..1}; do python -u store_bug.py $i 2 & done && wait
"""
import os
import datetime
import sys
import time
import os
import sys
import ctypes
ld = ctypes.CDLL(None, use_errno=True)
SPLICE_F_NONBLOCK = getattr(os, "SPLICE_F_NONBLOCK", 0x02)
def tee(fd_in, fd_out, length, flags=SPLICE_F_NONBLOCK):
@heiner
heiner / shm.py
Last active June 20, 2022 16:06 — forked from jakirkham/shm.py
Some Python ctypes-based POSIX shared memory functions
import os
import sys
try:
from _posixshmem import shm_open, shm_unlink
except ImportError:
import ctypes
dllname = None
if sys.platform.startswith("linux"):
@heiner
heiner / README.md
Last active February 14, 2022 14:04

Experiment data from the moolib whitepaper.

import contextlib
import fcntl
import os
import sys
import termios
import tty
@contextlib.contextmanager
def no_echo():
import queue
import threading
import gym
def target(resetqueue, readyqueue):
while True:
env = resetqueue.get()
if env is None:
@heiner
heiner / plot.py
Created September 21, 2021 09:22
#!/usr/bin/env python
"""
Script for plotting results.
```
python plot.py logs.tsv
```
"""
import argparse
import glob
import ctypes
import os
import time
def _sendfile(trgt_fd, src_fd):
# Cf. https://github.com/python/cpython/blob/3.8/Lib/shutil.py#L114
# which we cannot easily use directly.
try:
blocksize = max(os.fstat(src_fd).st_size, 2 ** 23) # min 8MiB
import collections
import sys
import pprint
class Entry:
pass
def load_file(filename):