Skip to content

Instantly share code, notes, and snippets.

View fpaupier's full-sized avatar
🎲
Focusing

Frαnçois fpaupier

🎲
Focusing
View GitHub Profile
@fpaupier
fpaupier / cloud_init.sh
Created June 9, 2024 12:22
Cloud instance instal utils
#!/bin/bash
# Ensure the script is run as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# Install oh my bash
bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)"
@fpaupier
fpaupier / vllm_init.sh
Created May 15, 2024 14:48
Initializes a GPU machine to start a vLLM server
#!/bin/bash
# This script initializes a GPU machine to start a vLLM server
# Ensure the script is run as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
@fpaupier
fpaupier / matrix_rank.py
Created February 25, 2024 15:49
Generate figures of vector space generated from the columns of two 3-dimensions matrix with rank = 3 and rank = 2
import numpy as np
import matplotlib.pyplot as plt
def main() -> None:
# Define the matrices
W1 = np.eye(3) # Identity matrix
W2 = np.array([[3, -2, 1], [2, -2, 0], [0, 1, 1]]) # Rank-deficient matrix
# Create figure for W1
@fpaupier
fpaupier / gpumeter.sh
Created February 13, 2024 06:32
Measure maximum VRAM consumption of a program on linux for Nvidia devices
#!/bin/bash
# Usage ./gpumeter.sh my-gpu-hungry-script.sh
# Check if the command argument is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <script_to_run>"
exit 1
fi
@fpaupier
fpaupier / get_device.py
Created February 11, 2024 09:40
Get torch device
import torch
import subprocess
def get_device():
# Check for CUDA GPU
if torch.cuda.is_available():
return 'cuda'
# Check for Apple Silicon (M1/M2) using sysctl
try:
@fpaupier
fpaupier / test_config_llamacpp.ipynb
Created February 4, 2024 08:03
test_config_llamacpp.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fpaupier
fpaupier / get_courses.sh
Created December 27, 2023 14:18
Download LLM course 11-667 from Carnegie Mellon University
#!/bin/bash
# URL of the website to download from
URL="https://www.andrew.cmu.edu/course/11-667/lectures/"
# Directory where the files will be saved
DESTINATION_DIR="./cmu_course_lectures"
# Create the destination directory
mkdir -p "$DESTINATION_DIR"
@fpaupier
fpaupier / frame_extractor.py
Created October 12, 2021 13:07
Extract frame from a video using ffmpeg and txt file containing a list of timestamps expressed in seconds. One line is a timestamp.
"""
Generates video screenshot from a text file of timestamps expressed in seconds.
Note: ffmpeg must be installed on your machine.
Tested on python3.7
Example usage:
```
@fpaupier
fpaupier / multiprocessing-server-main.py
Created August 8, 2021 10:40
A non working gRPC server init
def main():
"""
Inspired from https://github.com/grpc/grpc/blob/master/examples/python/multiprocessing/server.py
"""
logger.info(f'Initializing server with {NUM_WORKERS} workers')
with _reserve_port() as port:
bind_address = f"[::]:{port}"
logger.info(f"Binding to {bind_address}")
sys.stdout.flush()
workers = []
@fpaupier
fpaupier / faulty-grpc-init.py
Created August 8, 2021 10:19
A Non working gRPC server initialization
import grpc
from concurrent import futures
server = grpc.server(
futures.ProcessPoolExecutor(max_workers=5), # ← HERE: Would be ideal but does not work.
options=[ # See https://github.com/grpc/grpc/issues/14436
("grpc.max_send_message_length", -1),
("grpc.max_receive_message_length", -1),
]
)