Skip to content

Instantly share code, notes, and snippets.

# The library contains bug; do not use
cd $(mktemp -d)
git clone --recursive https://github.com/ROCmSoftwarePlatform/flash-attention.git
export GPU_ARCHS="gfx90a"
cd flash-attention
export PYTHON_SITE_PACKAGES=$(python -c 'import site; print(site.getsitepackages()[0])')
patch "${PYTHON_SITE_PACKAGES}/torch/utils/hipify/hipify_python.py" hipify_patch.patch
pip install .
@donglixp
donglixp / gpu_zombie.py
Created December 6, 2023 11:22
gpu_zombie.py
import torch
ngpus = torch.cuda.device_count()
N, M, K = 1280, 2560, 5120
def matmul():
A = []
B = torch.randn(M, K, device='cuda:0')
for i in range(ngpus):
sudo apt-get install -y wget gpg ; wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
rm -f packages.microsoft.gpg
sudo apt install -y apt-transport-https ; sudo apt update ; sudo apt install -y code ; code tunnel --accept-server-license-terms
@donglixp
donglixp / dispatch_openai_requests.py
Created April 23, 2023 13:12 — forked from neubig/dispatch_openai_requests.py
A simple script to get results from the OpenAI Asynchronous API
import openai
import asyncio
from typing import Any
async def dispatch_openai_requests(
messages_list: list[list[dict[str,Any]]],
model: str,
temperature: float,
max_tokens: int,
top_p: float,
@donglixp
donglixp / radar.ipynb
Created October 21, 2022 12:32
Radar figure in BEiT-3
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#####################
#
# Use this with or without the .gitattributes snippet with this Gist
# create a fixle.sh file, paste this in and run it.
# Why do you want this ? Because Git will see diffs between files shared between Linux and Windows due to differences in line ending handling ( Windows uses CRLF and Unix LF)
# This Gist normalizes handling by forcing everything to use Unix style.
#####################
# Fix Line Endings - Force All Line Endings to LF and Not Windows Default CR or CRLF
sudo apt-get -y install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
@donglixp
donglixp / QG.md
Last active December 17, 2019 11:44
question generation

docker

alias=`whoami | cut -d'.' -f2`; sudo docker run -it --rm --runtime=nvidia --ipc=host --privileged -v /home/${alias}:/home/${alias} -v /mnt/data:/mnt/data pytorch/pytorch:1.1.0-cuda10.0-cudnn7.5-devel bash

docker setup

apt-get update
apt-get install -y vim wget ssh
@donglixp
donglixp / rouge_perl_setup.sh
Last active May 10, 2022 04:39
Setup ROUGE-1.5.5
# install XML::DOM plugin, instructions https://web.archive.org/web/20171107220839/www.summarizerman.com/post/42675198985/figuring-out-rouge
cpan App::cpanminus
cpanm XML::DOM
# test fails with XLM::Parser missing error, install it
sudo apt-get install libexpat1-dev
cpanm XML::Parser
cd /mnt/data/
git clone https://github.com/andersjo/pyrouge.git
luarocks install penlight
luarocks install dpnn
luarocks install json
luarocks install xlua
luarocks install tds
luarocks install threads
luarocks install httpclient
luarocks install sys
luarocks install luafilesystem
luarocks install lua-cjson