Skip to content

Instantly share code, notes, and snippets.

View dwf's full-sized avatar

David Warde-Farley dwf

View GitHub Profile
@dwf
dwf / gist:f071422e3d3e09a4024a70c649b7cd51
Created April 8, 2024 21:30
Error log from attempted jax-rocm build
Python 3.11.8 (main, Feb 6 2024, 21:21:21) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import jax
2024-04-08 22:23:25.127712: E external/xla/xla/stream_executor/plugin_registry.cc:91] Invalid plugin kind specified: DNN
>>> X = jax.numpy.zeros((5000, 6000))
:1:hip_code_object.cpp :516 : 809713991079 us: [pid:3362424 tid:0x7ffff7eaf740] hipErrorNoBinaryForGpu: Unable to find code object for all current devices!
:1:hip_code_object.cpp :517 : 809713991085 us: [pid:3362424 tid:0x7ffff7eaf740] Devices:
:1:hip_code_object.cpp :520 : 809713991086 us: [pid:3362424 tid:0x7ffff7eaf740] amdgcn-amd-amdhsa--gfx1100 - [Not Found]
:1:hip_code_object.cpp :524 : 809713991091 us: [pid:3362424 tid:0x7ffff7eaf740] Bundled Code Objects:
:1:hip_code_object.cpp :540 : 809713991092 us: [pid:3362424 tid:0x7ffff7eaf740] host-x86_64-unknown-linux-- - [Unsupported]
@dwf
dwf / flake.nix
Created January 2, 2024 00:33
Minimal example of YAML as flake output
# Copyright 2024 Google LLC.
# SPDX-License-Identifier: Apache-2.0
{
description = "Demo of generating a YAML file as a flake output";
outputs = { self, nixpkgs }: let
forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
in {
packages = forAllSystems (system:
let pkgs = nixpkgs.legacyPackages.${system};
in {
@dwf
dwf / flash-nanocul-evofw3.mk
Created March 21, 2022 23:14
Makefile for flashing a nanoCUL stick with the latest version of the evofw3 firmware.
# Copyright 2022 Google LLC.
# SPDX-License-Identifier: Apache-2.0
#
# Makefile for flashing a nanoCUL stick with evofw3 using arduino-cli.
#
# Get arduino-cli and make with `nix shell nixpkgs#gnumake nixpkgs#arduino-cli`.
# Then run make -f flash-nanocul.mk.
# One of atmega328p, atmega32u4. Only tested with atmega328p, the one I have.
BOARD=atmega328p
@dwf
dwf / coventry_regex.py
Created August 28, 2018 18:00
Autofill CoventryBS's silly 2FA with Bitwarden regex custom fields.
"""
Take in a CoventryBS grid card as a text file, output regex custom fields for
Bitwarden to autofill your grid card challenge for you.
"""
from __future__ import print_function
import fileinput
import itertools
import sys
COLS = 'ABCDEFGHIJ'
@dwf
dwf / bcefl.py
Created April 10, 2017 16:00
Stable binary cross-entropy, operating on logit predictions instead of relying on Theano to correctly optimize the sigmoid output.
from theano import tensor
def binary_crossentropy_from_logits(logits, targets):
"""Binary cross-entropy computed from model logits.
Parameters
----------
predictions : TensorVariable
The unnormalized log probabilities of a probabilistic binary
classifier.
targets : TensorVariable
@dwf
dwf / simple_mnist_gan.py
Created January 20, 2017 14:27
Single-script Blocks reproduction of the Goodfellow et al (2014) MNIST GAN.
from collections import OrderedDict
from blocks.algorithms import GradientDescent, Momentum
from blocks.bricks import (
MLP, Rectifier, Logistic, Linear, LinearMaxout, Sequence, Random
)
from blocks.extensions import Printing, Timing
from blocks.extensions.training import SharedVariableModifier
from blocks.extensions.monitoring import (DataStreamMonitoring,
TrainingDataMonitoring)
@dwf
dwf / interleaved.ipynb
Created October 12, 2016 04:37
Example of interleaving data streams with Fuel and conditional processing with Blocks.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dwf
dwf / sshft.sh
Created October 9, 2016 18:28
Easily forward ports through an SSH login node.
sshft() {
if [ $# -lt 2 ]; then
echo "usage: sshft host [port|local:remote|local:bridge:remote] ...]"
return 1
fi
if [ -z "$DEFAULT_SSH_PROXY_HOST" ]; then
echo "No DEFAULT_SSH_PROXY_HOST set."
return 1
fi
FIRST_SSH_ARGS="$DEFAULT_SSH_PROXY_HOST"
@dwf
dwf / lib.py
Last active December 20, 2016 00:45
Minimal examples of using the Blocks MainLoop and checkpointing machinery.
# It's important not to define any classes you want serialized in
# the script you're running as pickle doesn't like that (if you pass
# save_main_loop=False to Checkpoint it's fine, though).
from theano import tensor
import numpy
import theano
from picklable_itertools import imap, izip, repeat
# Your algorithm object just needs two required methods: initialize()
@dwf
dwf / segmented_epoch_stream.py
Created September 28, 2016 17:04
Fuel DataStream that segments the epochs of another DataStream.
"""Fuel DataStream that segments the epochs of another DataStream."""
__license__ = """
Copyright (c) 2016 Universite de Montreal
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