Skip to content

Instantly share code, notes, and snippets.

View bri25yu's full-sized avatar

Brian Yu bri25yu

View GitHub Profile
@bri25yu
bri25yu / run.sh
Last active May 22, 2023 00:34
a18 torch.distributed.barrier hangs
# On a18, not using nccl backend resolves
torchrun --nproc-per-node 8 test_barrier.py
# On a18, using nccl backend hangs
torchrun --nproc-per-node 8 test_barrier.py --use_nccl
# On other nodes, this script never hangs
torchrun --nproc-per-node 8 test_barrier.py
torchrun --nproc-per-node 8 test_barrier.py --use_nccl
@bri25yu
bri25yu / course_surveys_su_fa_22.rb
Last active October 10, 2023 23:32
Utils for uploading course surveys
Instructor.create(first_name: "Michael", last_name: "Psenka", title: "Lecturer")
Instructor.create(first_name: "Gopala", last_name: "Anumanchipalli", title: "Assistant Professor")
Instructor.create(first_name: "Igor", last_name: "Mordatch", title: "Assistant Professor")
Instructor.create(first_name: "Gasper", last_name: "Begus", title: "Assistant Professor")
Instructor.create(first_name: "Venkatesan", last_name: "Guruswami", title: "Assistant Professor")
Instructor.create(first_name: "Joe", last_name: "Hellerstein", title: "Professor")
start_time = DateTime.now - (12 / 24.0) # Past 12 hours
Instructorship.where("created_at >= (?)", start_time).destroy_all
Klass.where("created_at >= (?)", start_time).destroy_all
@bri25yu
bri25yu / add_as_aos.py
Created May 2, 2023 02:13
[WIP] Marking input names as assistant officers
to_add = [
["Bob", "Joe", "Compserv"],
]
for data in to_add do
matched_people = People.where(first_name: data[0], last_name: data[1])
end
@bri25yu
bri25yu / map_csv.py
Created October 7, 2022 03:51
Example script to map a VP Google sheets script to a script usable by dev-hkn account creation
from typing import Dict, List
import csv
in_path = "../../../../Downloads/HKN Candidate RSVP Form (Fa22) (Responses) - Form Responses 1.csv"
out_path = "candidate_info.csv"
with open(in_path) as f:
@bri25yu
bri25yu / vectorize_example.sh
Created September 23, 2022 23:48
CS285 Hw2 Vectorize env testing in colab
# Without vectorization
time python cs285/scripts/run_hw2.py \
--exp_name q1_sb_no_rtg_dsa \
--env_name CartPole-v0 \
-n 10 \
-b 10000 \
--multiprocess_gym_envs 1
# With vectorization
time python cs285/scripts/run_hw2.py \
@bri25yu
bri25yu / clear_cory_slots.rb
Created September 23, 2022 03:43
Example script to clear Cory slots
Slot.where(room: Slot::Room::Cory, hour: 11, wday: 5).first.tutors.clear
Slot.where(room: Slot::Room::Cory, hour: 15, wday: 2).first.tutors.clear
Slot.where(room: Slot::Room::Cory, hour: 15, wday: 4).first.tutors.clear
Slot.where(room: Slot::Room::Cory, hour: 16, wday: 4).first.tutors.clear
@bri25yu
bri25yu / rl_trainer.py
Created September 12, 2022 20:51
Example of logging eval return every 1k steps
from collections import OrderedDict
import numpy as np
import time
from tqdm import trange
import gym
import torch
from cs285.infrastructure import pytorch_util as ptu
from cs285.infrastructure.logger import Logger
@bri25yu
bri25yu / manual_add_courses.rb
Created September 12, 2022 19:46
Example script for manually adding courses on hkn-rails
cs_dept = Department.where(abbr: "COMPSCI").first()
info_dept = Department.create(
name: "Information",
abbr: "INFO",
)
# Create CS 194-26 and CS 294-26
# For course information, see https://inst.eecs.berkeley.edu/~cs194-26/fa22/
for course_number in [194, 294] do
Course.create(