Skip to content

Instantly share code, notes, and snippets.

View afspies's full-sized avatar
🐐

Alex Spies afspies

🐐
View GitHub Profile
@afspies
afspies / gpu_allocation.py
Last active May 2, 2024 07:20
Automatic GPU Allocation
# EDIT 10/04/2022 - This version was provided by @jayelm who fixed some bugs and made the function much more robust
import os
import subprocess
import time
def assign_free_gpus(threshold_vram_usage=1500, max_gpus=2, wait=False, sleep_time=10):
"""
Assigns free gpus to the current process via the CUDA_AVAILABLE_DEVICES env variable
This function should be called after all imports,
@shawwn
shawwn / What happens when you allocate a JAX tensor on a TPU.md
Last active April 15, 2023 04:11
JAX C++ stack trace walkthrough for TpuExecutor_Allocate
@shawwn
shawwn / libtpujesus.c
Created November 2, 2021 06:41
An example of building a custom "stub" libtpu.so library, with the ultimate goal of implementing your own "TPU" device for JAX.
/* libtpujesus.c
Copyright 2021 Shawn Presser
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@dblalock
dblalock / ML Meta-analyses.md
Last active November 28, 2023 14:50
List of meta-analyses / independent benchmarking of machine learning and data mining papers
@sayakpaul
sayakpaul / rand_augment_tfrecords.py
Last active April 30, 2023 07:03
Example of incorporating RandAugment in a tf.data pipeline for image classification.
from imgaug import augmenters as iaa
import imgaug as ia
ia.seed(4)
import tensorflow as tf
tf.random.set_seed(666)
aug = iaa.RandAugment(n=2, m=9)
BATCH_SIZE = 224
@patrickmineault
patrickmineault / downsample.py
Created December 28, 2020 19:37
Downsample a stack of 2d images in PyTorch
def downsample_2d(X, sz):
"""
Downsamples a stack of square images.
Args:
X: a stack of images (batch, channels, ny, ny).
sz: the desired size of images.
Returns:
The downsampled images, a tensor of shape (batch, channel, sz, sz)
"""Configuration library for experiments."""
from typing import Dict, Any
import logging
import pprint
import sys
import argparse
logger = logging.getLogger(__name__)
parser = argparse.ArgumentParser(description=__doc__, fromfile_prefix_chars="@")
@npearce
npearce / install-docker.md
Last active April 19, 2024 12:35
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start