Skip to content

Instantly share code, notes, and snippets.

@JohanAR
JohanAR / eigen_helper.hpp
Created April 3, 2024 14:15
Fast coefficient lookup / reference for Eigen3 arrays
// Fast coefficient reference for rowmajor array with fixed number of columns
template <class Scalar_, int Rows_, int Cols_, int Flags_, int MaxRows_, int MaxCols_,
std::enable_if_t<(Flags_ & Eigen::RowMajor) && (Cols_ != Eigen::Dynamic), bool> = true>
auto CO(Eigen::Array<Scalar_, Rows_, Cols_, Flags_, MaxRows_, MaxCols_> &arr,
Eigen::Index row, Eigen::Index col) -> Scalar_ & {
return *(arr.data() + Cols_ * row + col);
}
// Fast coefficient const reference for rowmajor array with fixed number of columns
template <class Scalar_, int Rows_, int Cols_, int Flags_, int MaxRows_, int MaxCols_,
@JohanAR
JohanAR / Dockerfile
Created October 15, 2023 14:18
text-generation-webui in docker
FROM nvidia/cuda:11.8.0-devel-ubuntu22.04
# https://developer.nvidia.com/cuda-gpus
# for a rtx 2060: ARG TORCH_CUDA_ARCH_LIST="7.5"
ARG TORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-3.5;5.0;6.0;6.1;7.0;7.5;8.0;8.6+PTX}"
LABEL maintainer="Your Name <your.email@example.com>"
LABEL description="Docker image for GPTQ-for-LLaMa and Text Generation WebUI"
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,rw apt-get update && \
@JohanAR
JohanAR / README.md
Last active September 13, 2023 16:23
Script to automatically download metadata for GGMLv3 files to GGUF

Usage

I've tried to make the script as robust as possible, but use at your own risk, no warranties given, etc.

  1. Set the environment variable LLAMA_CPP_DIR to wherever you've checked out https://github.com/ggerganov/llama.cpp
  2. Make sure it contains the convert-llama-ggml-to-gguf.py script, and that you've installed all necessary requirements to run it.
  3. Locate the original model repo on huggingface.co and copy its URL, i.e. if you downloaded a model quantized by TheBloke, check the model card for the link to the original model (unless it's one of TheBloke's own models.. The important thing is that the repo URL you use contains a config.json with more than one line of text).
  4. Run the script with the GGML files you want to convert as first argument, and the URL as second. If everything is set up right it will create a GGUF file next to the input file.

Example

#!/bin/sh
# Set persistence mode on
nvidia-smi -i 0 -pm 1
# Set 200W power limit
nvidia-smi -i 0 -pl 200
# Limit max clock speed to 1850 MHz
nvidia-smi -i 0 -lgc 210,1850
@JohanAR
JohanAR / mvlc.sh
Created July 10, 2022 13:51
Play multiple files synchronised in VLC
#!/usr/bin/env bash
VLC='/usr/bin/vlc --sout-all --sout #display'
joinargs () {
local IFS="#"
echo "$*"
}
multivlc () {
@JohanAR
JohanAR / conv.py
Last active September 24, 2023 12:42
Convert filmtipset.se exported csv to imdb format (with some fake data)
# Put the exported csv from filmtipset.se next to this script and rename it to film.csv
import re
IMPORT=re.compile(r"(\d{4}-\d{2}-\d{2}),(.+);(\d+);(\d)")
def to_imdb(num):
return 'tt{:07d}'.format(int(num))
def parse(ft):
@JohanAR
JohanAR / sort.py
Created October 10, 2020 14:09
Rename all subtitles to match movie
from collections import namedtuple
import os
import re
FileInfo = namedtuple('FileInfo', ['toname', 'subname'])
def doit():
directory = os.fsencode('.')
matcher = re.compile('.*[sS](\d+)[eE]([0-9\-]+).*')
@JohanAR
JohanAR / PolynomialRegression.h
Last active January 20, 2020 14:46 — forked from chrisengelsma/PolynomialRegression.h
Polynomial regression in c++
#ifndef _POLYNOMIAL_REGRESSION_H
#define _POLYNOMIAL_REGRESSION_H __POLYNOMIAL_REGRESSION_H
/**
* PURPOSE:
*
* Polynomial Regression aims to fit a non-linear relationship to a set of
* points. It approximates this by solving a series of linear equations using
* a least-squares approach.
*
* We can model the expected value y as an nth degree polynomial, yielding
SteamVR System Report created tor jul 27 15:57:31 2017
<Report>
SteamVR Version: 1501109730
SteamVR Date: 2017-07-27
Steam: Public
Steam Branch: beta
Steam AppID: 250820
Tracking: lighthouse
OS: Linux version 4.10.0-28-generic (buildd@lgw01-11) (gcc version 6.3.0 20170406 (Ubuntu 6.3.0-12ubuntu2) ) #32-Ubuntu SMP Fri Jun 30 05:32:18 UTC 2017