Skip to content

Instantly share code, notes, and snippets.

View ttamg's full-sized avatar

Matt G ttamg

  • London
View GitHub Profile
ttamg /
Last active June 9, 2022 15:49
Python function to round number to significant figures
from math import floor, log10
def sig_figs(x: float, precision: int):
Rounds a number to number of significant figures
- x - the number to be rounded
- precision (integer) - the number of significant figures
ttamg /
Created March 25, 2022 17:18
Simple script to connect to GPU server and map Jupyter and Tensorboard ports
ssh -L 8888:localhost:8888 -L 6006:localhost:6006 bob@
ttamg /
Last active March 25, 2022 15:02
Script to mount GPU server drive on Mac OS - requires SSHFS and MacFUSE
remotedir="bob@" # TODO Add directory on the remote machine
mountdir="/Users/bob/gpu" # TODO Add local directory
echo "Mounting (${mountdir})..."
#Unmount if it's already mounted
if mount | grep "on $mountdir" > /dev/null; then
umount ${mountdir}
ttamg /
Last active March 13, 2022 21:08
Simple Pytorch script using MNIST to confirm installation is working
# Simple MNIST training script on Pytorch to confirm installation is working correctly
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import torchvision
n_epochs = 3
ttamg /
Created March 13, 2022 17:08
AI-benchmark run script
from ai_benchmark import AIBenchmark
benchmark = AIBenchmark()
results =
ttamg /
Last active March 13, 2022 17:06
A simple Tensorflow 2 MNIST training example to confirm installation is working
# A simple Tensorflow 2 MNIST training script to test installation is working correctly.
import tensorflow as tf
import tensorflow_datasets as tfds
(ds_train, ds_test), ds_info = tfds.load(
split=['train', 'test'],
ttamg / docker-compose.yml
Created December 10, 2021 10:38
Update backend to receive from Traefik
build: .
- 8999:80
env_file: .env
restart: unless-stopped
- "traefik.enable=true"
- "traefik.http.routers.backend.rule=Host(``)"
- "traefik.http.routers.backend.entrypoints=websecure"
ttamg / docker-compose.yml
Created December 10, 2021 10:31
Traefik https service for docker-compose
image: "traefik:v2.5"
container_name: "traefik"
#- "--log.level=DEBUG"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.websecure.address=:443"
- "--certificatesresolvers.myresolver.acme.tlschallenge=true"
ttamg / docker-compose.yml
Last active December 10, 2021 10:47
Simple FastApi docker-compose - no proxy
version: "3.4"
build: .
- 80:80
env_file: .env
restart: unless-stopped
ttamg /
Last active March 9, 2021 13:21
Getting the current module's PATH for use when doing file imports
import os
CWD = os.path.dirname(os.path.abspath(__file__))
#CWD then has the absolute path to this current file