Skip to content

Instantly share code, notes, and snippets.

@ashok-arjun
ashok-arjun / click_connect_button.js
Created June 6, 2021 08:16 — forked from RodolfoFerro/click_connect_button.js
Stop Colab from disconnecting, 2021.
function ClickConnect() {
console.log('Working')
document
.querySelector('#top-toolbar > colab-connect-button')
.shadowRoot.querySelector('#connect')
.click()
}
intervalTiming = setInterval(ClickConnect, 60000)
@ashok-arjun
ashok-arjun / tin.py
Created September 10, 2021 11:55 — forked from z-a-f/tin.py
Tiny ImageNet Dataset for PyTorch
import imageio
import numpy as np
import os
from collections import defaultdict
from torch.utils.data import Dataset
from tqdm.autonotebook import tqdm
dir_structure_help = r"""
@ashok-arjun
ashok-arjun / accuracy.py
Created December 28, 2021 08:01 — forked from weiaicunzai/accuracy.py
compute top1, top5 error using pytorch
from __future__ import print_function, absolute_import
__all__ = ['accuracy']
def accuracy(output, target, topk=(1,)):
"""Computes the precision@k for the specified values of k"""
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
@ashok-arjun
ashok-arjun / ddp_notes.md
Created February 12, 2022 15:17 — forked from TengdaHan/ddp_notes.md
Multi-node-training on slurm with PyTorch

Multi-node-training on slurm with PyTorch

What's this?

  • A simple note for how to start multi-node-training on slurm scheduler with PyTorch.
  • Useful especially when scheduler is too busy that you cannot get multiple GPUs allocated, or you need more than 4 GPUs for a single job.
  • Requirement: Have to use PyTorch DistributedDataParallel(DDP) for this purpose.
  • Warning: might need to re-factor your own code.
  • Warning: might be secretly condemned by your colleagues because using too many GPUs.
@ashok-arjun
ashok-arjun / convert-netcdf-to-csv.ipynb
Created July 10, 2022 15:39 — forked from copernicusmarinegist/convert-netcdf-to-csv.ipynb
Python Notebook Example on how to convert a netcdf file to csv file
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ashok-arjun
ashok-arjun / example_image_utils.py
Created December 23, 2022 03:42 — forked from pojda/example_image_utils.py
Layer on top of Python Imaging Library (PIL) to write text in images easily
#!/usr/bin/env python
# coding: utf-8
# You need PIL <http://www.pythonware.com/products/pil/> to run this script
# Download unifont.ttf from <http://unifoundry.com/unifont.html> (or use
# any TTF you have)
# Copyright 2011 Álvaro Justen [alvarojusten at gmail dot com]
# License: GPL <http://www.gnu.org/copyleft/gpl.html>
from image_utils import ImageText
@ashok-arjun
ashok-arjun / pytorch_performance_profiling.md
Created February 9, 2023 16:33 — forked from mingfeima/pytorch_performance_profiling.md
How to do performance profiling on PyTorch

(Internal Tranining Material)

Usually the first step in performance optimization is to do profiling, e.g. to identify performance hotspots of a workload. This gist tells basic knowledge of performance profiling on PyTorch, you will get:

  • How to find the bottleneck operator?
  • How to trace source file of a particular operator?
  • How do I indentify threading issues? (oversubscription)
  • How do I tell a specific operator is running efficiently or not?

This tutorial takes one of my recent projects - pssp-transformer as an example to guide you through path of PyTorch CPU peformance optimization. Focus will be on Part 1 & Part 2.