Skip to content

Instantly share code, notes, and snippets.

View MasterSkepticista's full-sized avatar
🌞

Karan Shah MasterSkepticista

🌞
View GitHub Profile
@MasterSkepticista
MasterSkepticista / convert_torchvision_weights.py
Last active July 5, 2024 09:17
A standalone tool to convert torchvision.resnet50 weights to flax format.
"""Tool to convert torchvision.resnet50 pretrained weights for flax.
This tool loads torchvision weights, unflattens them to a nested PyTree of
np.ndarray, which can be loaded to a ResNet50 flax model (assuming it has
the same tree structure).
A sample ResNet flax implementation which can load these weights is available
here: https://github.com/MasterSkepticista/detr/blob/main/models/resnet.py
Usage:
@MasterSkepticista
MasterSkepticista / reload_nvidia.sh
Created July 16, 2024 09:54
Reload `nvidia-smi` without a reboot.
#!/bin/bash
# Reloads `nvidia-smi` if you have had NVML/Library updates/mismatches,
# and you use a remote server which you cannot reboot for a whole host
# of scary reasons. Ensure nothing is running on the GPU, else this fails.
# Must be run with sudo. Be careful there are no display targets on the
# It is likely safe.
set -Eeuo pipefail
if [[ $UID != 0 ]]; then