Skip to content

Instantly share code, notes, and snippets.

View ytxmobile98's full-sized avatar

Tianxing Yang ytxmobile98

  • Guangzhou, China
  • 13:24 (UTC +08:00)
View GitHub Profile
@ytxmobile98
ytxmobile98 / kill_tree.sh
Created April 1, 2025 01:00
Kill a PID and all its descendants
#!/usr/bin/env bash
function kill_tree {
local pid=$1
local children=$(pgrep -P $pid)
for child in $children; do
kill_tree $child
done
@ytxmobile98
ytxmobile98 / find_transformers_num_params.py
Created July 14, 2025 06:06
How to find out the parameter size for a transformers model
from transformers import AutoModel
import torch
model_path = "./my_downloaded_model"
model = AutoModel.from_pretrained(model_path, local_files_only=True)
total_params = sum(p.numel() for p in model.parameters())
trainable_params = sum(p.numel() for p in model.parameters() if p.requires_grad)
print(f"Total parameters: {total_params}")