Skip to content

Instantly share code, notes, and snippets.

View lochbrunner's full-sized avatar

Matthias Lochbrunner lochbrunner

  • Deepmind
  • London
View GitHub Profile
@lochbrunner
lochbrunner / check_sizes.py
Last active February 14, 2021 09:31
Calculate the file size of folders respect to a ignore-file
#!/usr/bin/env python3
from pathlib import Path
import argparse
from hurry.filesize import size
from pathspec import PathSpec
from dataclasses import dataclass
@dataclass
@lochbrunner
lochbrunner / README.md
Last active November 30, 2020 17:57
Install cuda+libcudnn

Install PyTorch, CUDA and libcudnn

Motivation

If you write a PyTorch extension utilarizing the GPU and you want to build a unit test using CMake for it you have to install several packages by yourself.

Download

Test what CUDA is supported by your driver

@lochbrunner
lochbrunner / foo.hpp
Last active April 22, 2020 14:01
Example of using a generic Thread Pool for CUDA like kernel calls
#pragma once
#include <cstdint>
void foo(const uint64_t begin, uint64_t *result)
{
uint64_t prev[] = {begin, 0};
for (uint64_t i = 0; i < 1000000000; ++i)
{
const auto tmp = (prev[0] + prev[1]) % 1000;
@lochbrunner
lochbrunner / bieber_lstm.py
Last active September 4, 2022 09:11
Using pytorch, LSTM, mini-batches and DataSets to train a toy model. This GIST is inspired by https://gist.github.com/williamFalcon/f27c7b90e34b4ba88ced042d9ef33edd but trying to be complete, working and a bit more simpler than the orig. Additionaly it uses torch datasets.
#!/usr/bin/env python
import torch
import torch.nn as nn
import torch.nn.utils.rnn as rnn
import torch
import torch.optim as optim
from torch.utils.data import Dataset, DataLoader
from torch.nn import functional as F
@lochbrunner
lochbrunner / install-vscode-extensions.sh
Created May 5, 2018 08:53
Installation script of my current vscode extensions
#!/bin/sh
code --install-extension DavidAnson.vscode-markdownlint
code --install-extension PeterJausovec.vscode-docker
code --install-extension avli.clojure
code --install-extension cssho.vscode-svgviewer
code --install-extension donjayamanne.githistory
code --install-extension eamodio.gitlens
code --install-extension eg2.tslint
code --install-extension jamesnorton.continuum
@lochbrunner
lochbrunner / linear-regression-sgd.ts
Created October 1, 2017 10:00
A linear regression to find polynom coefficients via sgd (inspired by the book "Deep Learning" by Ian Goodfellow, Section 5.1.4 )
// Linear regression with SGD
// Run this file with ts-node ./traditional.ts
import * as fs from 'fs';
import {Matrix, Input} from '../../lib/tensors';
// Some helper functions
function printVector(vector: number[], description: string) {
console.log(`${description}: ${vector.map(t => t.toString()).join(', ')}`);