Skip to content

Instantly share code, notes, and snippets.

View SomeoneSerge's full-sized avatar
πŸ’­
Completely swamped again

Someone SomeoneSerge

πŸ’­
Completely swamped again
View GitHub Profile
@SomeoneSerge
SomeoneSerge / check_par.py
Last active June 4, 2021 10:16
An attempt to evaluate multiple pytorch models in parallel on a single GPU without threading or mpi
import itertools
from copy import deepcopy
from functools import partial
from itertools import cycle
from pprint import pprint
from timeit import timeit
from typing import List, Tuple
import numpy as np
import pandas as pd
@SomeoneSerge
SomeoneSerge / Dockerfile
Created June 9, 2021 18:04
Nix with Flakes support on top of ubuntu:20.04 docker
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update \
&& apt-get --yes install curl xz-utils sudo \
&& apt-get clean && rm -rf /var/lib/apt/lists/ \
&& useradd -m -G sudo --password "!" --shell /bin/bash my-user \
&& (echo 'my-user ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers)
{ lib, config, pkgs, ... }:
let
ldconfig = pkgs.writeScript "ldconfig" ''
#! /usr/bin/env bash
cleanup() {
rm -f "$TMP"
}
trap cleanup EXIT
#! /usr/bin/env nix-shell
#! nix-shell -i python -p "(import ./. { config = { allowUnfree = true; cudaSupport = true; }; }).python3.withPackages (ps: with ps; [ pytorch ])"
import torch
a = torch.randn(1, 3, 128, 128, device="cuda")
torch.nn.functional.conv2d(a, torch.randn(1, 3, 2, 2, device="cuda"))
print("ok")
This file has been truncated, but you can view the full file.
30c30
< cmake -GNinja -DBUILD_DOCS=0 -DBUILD_NAMEDTENSOR=1 -DBUILD_PYTHON=True -DBUILD_TEST=False -DCMAKE_BUILD_TYPE=Release -DCMAKE_INCLUDE_PATH=/nix/store/x3bc3xh6560gbx0npb17z14l0g960wp1-blas-3-dev/include:/nix/store/83s0r0nydjnh72hay6nks21q3045xh3w-openblas-0.3.20-dev/include:/nix/store/480wkg7xhhrgydn1710bp6ay1s5l64ir-cudatoolkit-11-cudnn-8.3.2/include:/nix/store/xaqsmhgkmfpgb5a0vj2d809fkygfw6wy-magma-2.6.2/include:/nix/store/pzqv19y0v3ypzkyiqiyr5p181h68hvrb-nccl-2.12.10-1-cuda-11.6-dev/include:/nix/store/4y54n3qssgc49bsr0xbbavg3qjpc0z9q-numactl-2.0.14/include:/nix/store/hym1n0ygqp9wcm7pxn4sfrql3fg7xa09-python3-3.9.12/include:/nix/store/hym1n0ygqp9wcm7pxn4sfrql3fg7xa09-python3-3.9.12/include -DCMAKE_INSTALL_PREFIX=/build/source/torch -DCMAKE_LIBRARY_PATH=/nix/store/n904zi6lspddqm5y8cc51xnsz37rn1j8-blas-3/lib:/nix/store/lwfgy55vscqdxxn1w2gz1b3vck5v7792-openblas-0.3.20/lib:/nix/store/480wkg7xhhrgydn1710bp6ay1s5l64ir-cudatoolkit-11-cudnn-8.3.2/lib:/nix/store/xaqsmhgkmfpgb5a0vj2d809fkygfw6wy-magma-2.6.2/lib:
This file has been truncated, but you can view the full file.
/nix/store/kb30f9livrnxswcx53cgwq9m49k1ksnj-python3.9-pytorch-1.11.0.drv
β”œβ”€β”€β”€/nix/store/9krlzvny65gdc8s7kpb6lkx8cd02c25b-default-builder.sh
β”œβ”€β”€β”€/nix/store/d0gl66iq1mld4qkmx5vs0ffzf7qnj01r-bash-5.1-p16.drv
β”‚ β”œβ”€β”€β”€/nix/store/0zhkga32apid60mm7nh92z2970im5837-bootstrap-tools.drv
β”‚ β”‚ β”œβ”€β”€β”€/nix/store/b7irlwi2wjlx5aj1dghx4c8k3ax6m56q-busybox.drv
β”‚ β”‚ β”œβ”€β”€β”€/nix/store/bzq60ip2z5xgi7jk6jgdw8cngfiwjrcm-bootstrap-tools.tar.xz.drv
β”‚ β”‚ └───/nix/store/wzdwpgqf2384hr2npma78mqillg5lv08-unpack-bootstrap-tools.sh
β”‚ β”œβ”€β”€β”€/nix/store/1h2k4r9m23y3mkp8dzahfhf9izhcqy41-bash51-005.drv
β”‚ β”œβ”€β”€β”€/nix/store/38n3s6l5ijf0hsqqbjbknj0ipwzya5vk-bash51-011.drv
β”‚ β”œβ”€β”€β”€/nix/store/9krlzvny65gdc8s7kpb6lkx8cd02c25b-default-builder.sh [...]
let
pkgs = import <nixpkgs> { config.cudaSupport = true; config.allowUnfree = true; };
py = pkgs.python3.withPackages (ps: with ps; [
pytorch
]);
in pkgs.dockerTools.buildLayeredImage {
name = "docker-pytorch";
contents = [
py
];
@SomeoneSerge
SomeoneSerge / rid-of-safelinks.user.js
Last active July 10, 2022 23:36
GreaseMonkey script to clean up links (remove "https://eur02.safelinks.protection.outlook.com/..." bits) in the emails as displayed by ms outlook web app
import binascii
import codecs
from miio.discovery import Discovery
from miio.miioprotocol import MiIOProtocol
if __name__ == "__main__":
reply = MiIOProtocol.discover("192.168.5.1", timeout=60)
token = codecs.encode(reply.checksum, "hex")
device_id = binascii.hexlify(reply.header.value.device_id).decode()
-- test.sql
-- watch "sqlite3 < test.sql"
.mode table
CREATE TABLE t
(name TEXT)
;