Skip to content

Instantly share code, notes, and snippets.

View sroecker's full-sized avatar

Steffen Röcker sroecker

View GitHub Profile
@sroecker
sroecker / modal-moondream-label_datikz_v2.py
Last active June 13, 2024 13:01
A script to caption datikz graphs with Moondream using Modal
import modal
app = modal.App(name="moondream-label-datikz_v2")
data_dict = modal.Dict.from_name("HF_DATASET", create_if_missing=True)
def download_dataset():
from datasets import load_dataset
data_dict["HF_DATASET"] = "nllg/datikz-v2"
dataset = load_dataset(data_dict["HF_DATASET"])
@sroecker
sroecker / label_datikz_v2.py
Last active June 11, 2024 19:45
A script to caption datikz graphs with Moondream
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
import xxhash
from tqdm import tqdm
# load moondream model
model_id = "vikhyatk/moondream2"
revision = "2024-05-20"
model = AutoModelForCausalLM.from_pretrained(
@sroecker
sroecker / modal_eval_pokemon.py
Last active June 7, 2024 09:44
Modal: Batch eval Moondream with Pokemon dataset
import modal
app = modal.App(name="pokemon-eval")
moondream_image = modal.Image.micromamba(
python_version="3.11"
).apt_install(
"git"
).micromamba_install(
"cudatoolkit",
@sroecker
sroecker / podman_axolotl.sh
Created April 2, 2024 14:57
Run Axolotl fine-tuning with Podman
podman run --rm --device nvidia.com/gpu=all --security-opt=label=disable --mount type=bind,src="${PWD}",target=/workspace/axol
otl -v ${HOME}/.cache/huggingface:/root/.cache/huggingface winglian/axolotl:main-py3.10-cu118-2.0.1 accelerate launch -m axolotl.cli.train examples/openllam
a-3b/lora.yml
@sroecker
sroecker / build_continue_vscode_extension.sh
Last active January 22, 2024 09:11
How To Build the Continue.dev VSCode Extension for Red Hat Dev Spaces
#!/bin/bash
git clone https://github.com/continuedev/continue
npm config set prefix ~/.local
sh continue/install-dependencies.sh
cd continue/extensions/vscode
node scripts/prepackage.js
npm install @vscode/vsce
PATH=$PATH:~/.local/bin/
npm install yarn
node scripts/package.js
@sroecker
sroecker / debug_pytorch_rocm.py
Last active May 15, 2024 19:51
If this is not crashing then PyTorch is most likely running with your AMD graphics card and ROCm, if not see magic variables
import torch
print("pytorch version: " + torch.__version__)
print("CUDA available: " + str(torch.cuda.is_available()))
print("device count: " + str(torch.cuda.device_count()))
print("current device: " + str(torch.cuda.current_device()))
print("device name: " + torch.cuda.get_device_name(torch.cuda.current_device()))
print("backend:")
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
print(device)
@sroecker
sroecker / paxata_client.py
Created December 1, 2021 14:26
Simple Python client for the Paxata REST API
import json
import requests
import collections
class BearerAuth(requests.auth.AuthBase):
def __init__(self, token):
self.token = token
def __call__(self, r):
r.headers['Authorization'] = 'Bearer ' + self.token
return r
@sroecker
sroecker / get_prediction_explanations.py
Created May 31, 2021 08:21
DataRobot Python API Get Prediction Explanations
def upload_dataset_from_catalog(self, dataset):
import json
import time
# client = dr.Client()
res = client.post(client.endpoint + "/projects/{}/predictionDatasets/datasetUploads/".format(self.id), json={"datasetId": dataset.id})
dataset_id = json.loads(res.text)['datasetId']
while dataset_id not in [ds.id for ds in self.get_datasets()]:
time.sleep(1)
return dataset_id
def get_prediction_explanations(self, dataset_id):
@sroecker
sroecker / upload_dataset_from_catalog.py
Created May 31, 2021 07:44
DataRobot Python API Upload Dataset from Catalog
def upload_dataset_from_catalog(self, dataset):
import json
import time
client = dr.Client()
res = client.post(client.endpoint + "/projects/{}/predictionDatasets/datasetUploads/".format(self.id), json={"datasetId": dataset.id})
dataset_id = json.loads(res.text)['datasetId']
while dataset_id not in [ds.id for ds in self.get_datasets()]:
time.sleep(1)
return dataset_id
dr.Project.upload_dataset_from_catalog = upload_dataset_from_catalog
Verifying that +sroecker is my openname (Bitcoin username). https://onename.io/sroecker