Skip to content

Instantly share code, notes, and snippets.

View CiaoHe's full-sized avatar
:octocat:
god bless us

He Cao CiaoHe

:octocat:
god bless us
View GitHub Profile
@CiaoHe
CiaoHe / map_clsloc.txt
Created February 11, 2023 09:37 — forked from aaronpolhamus/map_clsloc.txt
Image net classes + labels
n02119789 1 kit_fox
n02100735 2 English_setter
n02110185 3 Siberian_husky
n02096294 4 Australian_terrier
n02102040 5 English_springer
n02066245 6 grey_whale
n02509815 7 lesser_panda
n02124075 8 Egyptian_cat
n02417914 9 ibex
n02123394 10 Persian_cat
@CiaoHe
CiaoHe / other_way_download_HF_weights.md
Last active February 19, 2023 11:24
[HuggingFace] Other way to download pretrained weights
In [1]: from huggingface_hub import snapshot_download

In [2]: snapshot_download(repo_id="bert-base-chinese", ignore_regex=["*.h5", "*.ot", "*.msgpack"], cache_dir='MODEL WHERE STORE')

ignore_regex:忽略其他非必要文件

@CiaoHe
CiaoHe / AutoClipGradient.py
Created October 4, 2022 00:54
AutoClipGradient tool
import torch as th
import numpy as np
class AutoClipGradient(object):
def __init__(self, max_history=1000, clip_percentile=99.9, max_grad_norm=0.5):
self.max_history = max_history
self.clip_percentile = clip_percentile
self.history = []
self.max_grad_norm = max_grad_norm
def _compute_grad_norms(self, params, grad_scale=1.0):
@CiaoHe
CiaoHe / ddp_notes.md
Created September 15, 2022 02:46 — forked from TengdaHan/ddp_notes.md
Multi-node-training on slurm with PyTorch

Multi-node-training on slurm with PyTorch

What's this?

  • A simple note for how to start multi-node-training on slurm scheduler with PyTorch.
  • Useful especially when scheduler is too busy that you cannot get multiple GPUs allocated, or you need more than 4 GPUs for a single job.
  • Requirement: Have to use PyTorch DistributedDataParallel(DDP) for this purpose.
  • Warning: might need to re-factor your own code.
  • Warning: might be secretly condemned by your colleagues because using too many GPUs.
@CiaoHe
CiaoHe / cluster_jupyter.md
Created September 9, 2022 05:24
connect cluster-gpu to use jupyter
  1. submit sbatch jupyter.sh

example of jupyter.sh

#!/bin/bash

#SBATCH --nodes=1
#SBATCH --job-name=jupyter
#SBATCH --gres=gpu:1
#SBATCH --time=2-00:00:00
@CiaoHe
CiaoHe / vscode.md
Last active November 24, 2023 17:17
[vscode | pylint] add multiple paths to PYTHONPATH
@CiaoHe
CiaoHe / unzip.py
Last active April 20, 2022 03:37
python unzip file [in case 'no unzip installed']
import zipfile
path_to_zip_file = '...'
directory_to_extract_to = './'
with zipfile.ZipFile(path_to_zip_file, 'r') as zip_ref:
zip_ref.extractall(directory_to_extract_to)