Skip to content

Instantly share code, notes, and snippets.

@stolyarchuk
stolyarchuk / vram.rb
Created February 10, 2025 09:35 — forked from jrruethe/vram.rb
Calculate VRAM requirements for LLM models
#!/usr/bin/env ruby
# https://asmirnov.xyz/vram
# https://vram.asmirnov.xyz
require "fileutils"
require "json"
require "open-uri"
# https://huggingface.co/spaces/NyxKrage/LLM-Model-VRAM-Calculator/blob/main/index.html
#!/usr/bin/env bash
function register_gcc_version {
local version=$1
local version_major=
local priority=$2
# shellcheck disable=SC2086
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11 \
--slave /usr/bin/g++ g++ /usr/bin/g++-11 \
function register_clang_version {
local version=$1
local priority=$2
echo ${version} $priority
}
register_clang_version "$1" "$2"
@stolyarchuk
stolyarchuk / Setup GCC and CLANG Toolchains.md
Created July 4, 2024 09:47 — forked from bhaskarvk/Setup GCC and CLANG Toolchains.md
Proper GCC (vers. 5/6/7) & LLVM/CLANG (vers. 4/5) Toolchain Setup on Ubuntu/Linux Mint

This approach uses update-alternatives to manage GCC and LLVM/CLANG C/C++ compiler toolchains. Although tested on Linux Mint 18.3, this approach should work on any Debian based distro or for that matter any Linux distro with update-alternatives support, provided the packages are installed correctly.

There are 3 files

  • gcc-alternatives.sh installs GCC versions 5/6/7 and sets up alternatives for gcc/g++/cpp/gfortran.
  • llvm-clang-alternatives.sh installs LLVM and CLANG versions 4/5 and sets up alternatives for various LLVM and CLANG programs including clang and clang++.
  • cc-alternatives.sh sets up alternatives for the cc, cxx, and the ld commands. This script can be used to change systemwide default compiler/linker combination to either GCC or CLANG.

Once these scripts are run you can change the system GCC/CLANG versions by running sudo update-alternatives --config gcc|clang. To change the default compiler/linker combo used by t

# Repo: someuser/myframework
# Fork: superteam/myframework
# Track:
git clone https://github.com/superteam/myframework.git
cd myframework
git remote add upstream https://github.com/someuser/myframework.git
# Update:
git fetch upstream
#!/usr/bin/env bash
function register_gcc_version {
local version=$1
local version_major=
local priority=$2
# shellcheck disable=SC2086
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12 \
--slave /usr/bin/g++ g++ /usr/bin/g++-12 \
#!/usr/bin/env bash
function register_clang_version {
local version=$1
local priority=$2
update-alternatives \
--install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-"${version}" "${priority}" \
--slave /usr/bin/llvm-ar llvm-ar /usr/bin/llvm-ar-"${version}" \
--slave /usr/bin/llvm-as llvm-as /usr/bin/llvm-as-"${version}" \
#!/bin/bash
echo -e "*** CUDA CHECKS\n"
/usr/bin/nvidia-smi
echo -e "\n*** GSTREAMER CHECKS\n"
gst-inspect-1.0 --plugin nvenc
gst-inspect-1.0 --plugin nvdec
# gst-launch-1.0 videotestsrc num-buffers=1000 ! nvh264enc ! h264parse ! mp4mux ! filesink location=/tmp/videotest.mp4
echo -e "\n*** FFMPEG CHECKS\n"
ffmpeg -codecs | egrep '(264|265|vp8|vp9|mpeg4)'
echo -e "\n*** OPENCV CHECKS\n"