Skip to content

Instantly share code, notes, and snippets.

View simeneide's full-sized avatar

Simen simeneide

View GitHub Profile
@simeneide
simeneide / gist:80aa37108474aa32b82cb7258778287b
Created August 20, 2023 09:38
Multi-gpu-training with lora and 8bit failed
#%% LOAD MODEL OBJECTS
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-j-6B")
tokenizer.pad_token = tokenizer.eos_token
model = AutoModelForCausalLM.from_pretrained("EleutherAI/gpt-j-6B", load_in_8bit=True)
from peft import LoraConfig, TaskType, get_peft_model, prepare_model_for_kbit_training
peft_config = LoraConfig(task_type=TaskType.CAUSAL_LM, inference_mode=False, r=4, lora_alpha=32, lora_dropout=0.1)
model = prepare_model_for_kbit_training(model)
model = get_peft_model(model, peft_config)
@simeneide
simeneide / gist:44d957fd72757f7441ed90f25ae3734b
Created July 8, 2023 16:05
luftrom_G-to-F-rename.fl.txt
AC C
AN Polaris CTA
AL FL195
AH FL660
DP 70:00:00 N 015:00:00 E
DP 67:15:00 N 009:25:20 E
DP 66:12:39 N 007:42:28 E
DP 65:45:00 N 007:00:00 E
DP 65:37:05 N 006:50:25 E
DP 65:08:00 N 006:15:59 E
@simeneide
simeneide / sg-mcmc.py
Created October 21, 2020 11:36
Two simple implementations of sg-mcmc
from torch.optim.optimizer import Optimizer
class OptimizerSGLD(Optimizer):
def __init__(self, net, alpha=1e-4, sgmcmc=True):
super(OptimizerSGLD, self).__init__(net.parameters(), {})
self.net = net
self.sgmcmc = sgmcmc
self.alpha = alpha
self.noise_std = (2*self.alpha)**0.5
@torch.no_grad()
#%% IMPORTS
import torch
import pytorch_lightning as pl
import matplotlib.pyplot as plt
from pytorch_lightning import Trainer
from torch.nn import functional as F
import pyro
import pyro.distributions as dist
# %%
@simeneide
simeneide / bbox-video-streamlit.py
Created December 29, 2019 17:28
bounding box of videostream. visualized in streamlit
#%%
import time
import numpy as np
import streamlit as st
import pandas as pd
import cv2
video_sources = {
'Rindabotn' : "http://217.17.213.66:8081/mjpg/video.mjpg?overview=0&camera=1&videoframeskipmode=empty&Axis-Orig-Sw=true&resolution=1280x720",
'Hodlekve' : "http://217.17.213.66:8080/mjpg/video.mjpg?overview=0&camera=1&videoframeskipmode=empty&Axis-Orig-Sw=true&resolution=1280x720",
@simeneide
simeneide / gist:f3d33868c8fc36ed3934da4aa71847f0
Created November 15, 2016 09:23
blackjack models - first applying a simple threshold model then using more info
# coding: utf-8
# In[3]:
import gym
import numpy as np
import tensorflow as tf
import keras
# This is a modification of **'s algorithm. (cant find it now)
# Some tuning was done: (cost is now negative, and added cost of ending the game with zero reward so the algorithm would want to go towards the goal)
# Also, training was done not monitored, as it seems like other people have done that.
# Managed to get just as good results with less steps, but the stochasticity of the problem makes it hard to reproduce.
import gym
import numpy as np