This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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: | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | |
] | |
) |
NewerOlder