Skip to content

Instantly share code, notes, and snippets.

@sssemil
sssemil / 4090_PCIe_test.md
Created March 5, 2024 16:13
Difference in inference speed for SDXL on a 4090 with 4 vs 16 PCIe 4.0 lanes

Summary

txt2img sdxl 1024x1024

65.417351÷65.623950=0.996851774

img2img sdxl 1024x1024 (input 1024x1024 image)

54.623950÷55.738662=0.980001099

@sssemil
sssemil / depth_cam.py
Created November 15, 2023 11:26
Simple depth from monocular cam demo
import numpy as np
import torch
import cv2
from PIL import Image
from transformers import AutoImageProcessor, AutoModelForDepthEstimation
from transformers import DPTForDepthEstimation, DPTImageProcessor
def depth_estimation(model, feature_extractor, image):
inputs = feature_extractor(images=image, return_tensors="pt").to("cuda")
@sssemil
sssemil / minifier_launcher.py
Created November 14, 2023 06:17
Minified repo
from math import inf
import torch
from torch import tensor, device
import torch.fx as fx
import torch._dynamo
from torch._dynamo.testing import rand_strided
from torch._dynamo.debug_utils import run_fwd_maybe_bwd
import torch._dynamo.config
@sssemil
sssemil / zsh_setup.sh
Last active October 28, 2023 18:03
Basic zsh setup
#!/bin/bash
set -e
# Check if zsh is installed
if ! command -v zsh &> /dev/null; then
echo "zsh is not installed. Please install zsh first."
exit 1
fi
@sssemil
sssemil / deep_cam.py
Created October 22, 2023 17:46
Cam to depth stream
import numpy as np
import torch
import cv2
from PIL import Image
from transformers import DPTForDepthEstimation, DPTImageProcessor
model = DPTForDepthEstimation.from_pretrained("Intel/dpt-hybrid-midas", low_cpu_mem_usage=True).to("cuda")
feature_extractor = DPTImageProcessor.from_pretrained("Intel/dpt-hybrid-midas")
# Start capturing video from the first camera device

How to get this

Edit init.rc as following:

on early-init
    # Prepare early debugfs
    mount debugfs none /sys/kernel/debug
    chmod 0755 /sys/kernel/debug/tracing

    # Enable i2c tracer
@sssemil
sssemil / gitlab-remove-all-artifacts.sh
Created March 15, 2022 15:01
This script helps you with removal of all artifacts in a project.
#!/bin/sh
#<your project id (you can find it with inspect element on the project page)>
PROJECT_ID=36944
#<your access token (can be generated in your profile settings)>
ACCESS_TOKEN=xxxxx-XXXXXXXXXXXXXXXXXXXX
#<your gitlab instance hostname (ex. gitlab.lrz.de)>
GL_SERVER=gitlab.lrz.de
for PAGE in $(seq 1 1000); do
class TrieNode:
def __init__(self):
self.value = "_"
self.children = {}
def insert(self, str):
if not str:
c = ""
self.children[c] = TrieNode()