Skip to content

Instantly share code, notes, and snippets.

View csarron's full-sized avatar
🎯
Focusing

Qingqing Cao csarron

🎯
Focusing
View GitHub Profile

ZSH CheatSheet

This is a cheat sheet for how to perform various actions to ZSH, which can be tricky to find on the web as the syntax is not intuitive and it is generally not very well-documented.

Strings

Description Syntax
Get the length of a string ${#VARNAME}
Get a single character ${VARNAME[index]}
@csarron
csarron / scrcpy_shortcut.md
Created April 20, 2018 02:08
Scrcpy Shortcuts

Scrcpy Shortcuts

Action Shortcut
switch fullscreen mode Ctrl+f
resize window to 1:1 (pixel-perfect) Ctrl+g
resize window to remove black borders Ctrl+x | Double-click¹
click on HOME Ctrl+h | Middle-click
click on BACK Ctrl+b | Right-click²
click on APP_SWITCH Ctrl+m
import datetime
import json
import re
import string
import unicodedata
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModelForCausalLM
import torch
import time
import fire
@csarron
csarron / optimize_bert.py
Created July 13, 2020 03:31 — forked from icemelon/optimize_bert.py
Optimize the BERT model on CPUs
import time
import argparse
import numpy as np
import mxnet as mx
import gluonnlp as nlp
import tvm
from tvm import relay
import tvm.contrib.graph_runtime as runtime
def timer(thunk, repeat=1, number=10, dryrun=3, min_repeat_ms=1000):

Two main workarounds for mitigating the hyak io issues

  • containerizing job environment, apptainer is recommended by Hyak team for both speeding up python startup time and reproducibility

  • copying frequently used data to /tmp dir on the node, /tmp as described by Hyak team has around 400GB isolated fast SSD storage, and loading/saving data there won't affect others' jobs or slowdown hyak

Build a container image on the gpu node

using alloc to create an interactive session, e.g. salloc -c 8 -p ckpt --time=5-00:00 -n 1 --mem=64G --gpus=a40:1

@csarron
csarron / convert_pyarrow.py
Last active April 6, 2022 09:09
pip install pyarrow fire tqdm
"""
crawl images:
pip install img2dataset==1.11.0
img2dataset --url_list cc3m.tsv\
--output_folder cc3m-img --input_format "tsv"\
--url_col "url" --caption_col "caption"\
--output_format files --resize_mode=no\
--processes_count 10 --thread_count 64 --number_sample_per_shard 2000\
--enable_wandb True --save_metadata False
@csarron
csarron / install_zsh_on_sherlock.sh
Created October 18, 2021 04:26 — forked from mgbckr/install_zsh_on_sherlock.sh
Compiling and installing Zsh without root privileges on Stanford's Sherlock (https://sherlock.stanford.edu) for use in tmux
# # Install Zsh on Sherlock
# Installs Zsh with Oh-My-Zsh without root privileges
# on Stanford's Sherlock (https://sherlock.stanford.edu) for use in tmux
#
# ## Instructions
# 1) bash install_zsh.sh
# 2) edit .zshrc (add the path to your Zsh binary to the PATH variable, etc.)
# 3) add `set-option -g default-shell <path to zsh>/bin/zsh` to `~/.tmux.conf`
# 4) also see comments for potential further notes
#
@csarron
csarron / pylucence_install.md
Last active March 27, 2021 02:51
pylucence build and install on macOS and Ubuntu

install prebuilt eggs:

Ubuntu: may need to export libjvm.so ls -l /etc/alternatives/java will output something like: /etc/alternatives/java -> /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java then do: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/ export JCC_JDK=/usr/lib/jvm/java-8-openjdk-amd64

for macOS: easy_install JCC-3.2-py3.6-macosx-10.13-x86_64.egg lucene-7.5.0-py3.6-macosx-10.13-x86_64.egg

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.