Skip to content

Instantly share code, notes, and snippets.

@jpsutton
jpsutton / get-nv-temp.sh
Created September 5, 2023 20:34
Reading an Nvidia GPU temperature value from a libvirt Windows guest
#!/bin/bash
GUEST_NAME=Win10_With_GPU
job_exited="false"
exec_result=$(virsh -c qemu:///system qemu-agent-command "$GUEST_NAME" '{"execute": "guest-exec", "arguments": { "path": "nvidia-smi.exe", "arg": [ "--format=csv,noheader", "--query-gpu=temperature.gpu" ], "capture-output": true }}')
exec_pid=$(echo "$exec_result" | jq ".return.pid")
while [ "$job_exited" == "false" ]; do
exec_job_data=$(virsh -c qemu:///system qemu-agent-command "$GUEST_NAME" '{"execute": "guest-exec-status", "arguments": { "pid": '" ${exec_pid}}}")
@bssrdf
bssrdf / blender_slow.md
Last active August 2, 2023 15:26
A curious case of O(N^2) behavior which should be O(N)

Motivation

Recently I got interested in Blender 3D, partly inspired by infinigen project.

One day I encountered Tellusim. Impressed by the quality of its rendering, I was browsing its blogs and see this. Wow, Tellusim really blowed others out of the water;others including Unreal, Unity, Omniverse and Blender. Wait, Blender is really that slow importing a USD scene?

Since Blender is open-source, why not try to figure out what's going on? Here we go.

First, let's profile it

@jimfrize
jimfrize / fxl
Created May 5, 2023 22:24
fxl - Fuzzy search and xdg launcher tool (dependancies: fzf dex xclip xdg-utils)
#!/bin/bash
if [[ -z $EDITOR ]]
then
EDITOR=nano
fi
if [[ ! -f ~/.config/mimeapps.list ]]
@kiler129
kiler129 / generate_smbios.sh
Created April 12, 2023 07:38
Script to generate real SMBIOS for QEMU
#!/bin/bash
# See https://www.qemu.org/docs/master/system/invocation.html?highlight=smbios#hxtool-4
declare -A smb0
declare -A smb1
declare -A smb2
declare -A smb3
declare -A smb4
declare -A smb11
declare -A smb17
#!/bin/bash
set -e -o errexit -o pipefail -o nounset
###################################
# This script can be used by itself, but it's recommended that you read
# a tutorial on Proxmox forum first: https://forum.proxmox.com/threads/hey-proxmox-community-lets-talk-about-resources-isolation.124256/
###################################
# Do not modify these variables (set by Proxmox when calling the script)
vmId="$1"
@krzys-h
krzys-h / Hyper-V GPU-PV with Linux guest.md
Last active June 26, 2024 21:35
Ubuntu 21.04 VM with GPU acceleration under Hyper-V...?

Ubuntu 21.04 VM with GPU acceleration under Hyper-V...?

Modern versions of Windows support GPU paravirtualization in Hyper-V with normal consumer graphics cards. This is used e.g. for graphics acceleration in Windows Sandbox, as well as WSLg. In some cases, it may be useful to create a normal VM with GPU acceleration using this feature, but this is not officially supported. People already figured out how to do it with Windows guests though, so why not do the same with Linux? It should be easy given that WSLg is open source and reasonably well documented, right?

Well... not quite. I managed to get it to run... but not well.

How to do it?

  1. Verify driver support
@egg82
egg82 / proxmox_nvidia.md
Last active June 25, 2024 08:40
NVidia Proxmox + LXC

Proxmox

Find the proper driver at the NVidia website.

Note: Make sure to select "Linux 64-bit" as your OS

Hit the "Search" button.

@kiler129
kiler129 / prevent-host-driver-in-pci-pass.md
Last active April 13, 2024 02:02
Definitely prevent stubborn devices from being bound by the host driver in PCI passthrough scenario

Scenario

You're running a KVM-based virtualization. You want to do PCI/PCIe passthrough of some device. You don't want it to attach to the host OS at all.

Your device looks like that:

00:1f.2 SATA controller [0106]: Intel Corporation 6 Series/C200 Series Chipset Family SATA AHCI Controller [8086:1c02] (rev 05)
	Subsystem: Hewlett-Packard Company 6 Series/C200 Series Chipset Family 6 port Desktop SATA AHCI Controller [103c:330d]
	Kernel driver in use: ahci
	Kernel modules: ahci
for i in {0..9999}; do paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) | column -s $'\t' -t | sed 's/\(.\)..$/.\1°C/'; printf "\n================================= $i\n\n"; sleep 0.5; done