Skip to content

Instantly share code, notes, and snippets.

View AnirudhDagar's full-sized avatar
🎯
Focusing

Anirudh Dagar AnirudhDagar

🎯
Focusing
View GitHub Profile
@AnirudhDagar
AnirudhDagar / rename_tabs.py
Created April 13, 2022 00:20
This adds #@tab mxnet to all the missing code cells so that by default pytorch is picked up when order of tabs is changed in config.ini
from d2lbook import notebook
import nbformat
import os
import glob
import re
import nbconvert
def find_files():
"""
Find all jupyter notebooks from the root dir.
########################################################
## This script tests if the syntax for slides is correct
## after generating the machine translations in d2l.
## Useful to debug errors all in one go like shown below
## Example:
## assert len(start) == len(end), f'some {p} are not enclosed in {text}'
## AssertionError: some ('[**', '**]') are not enclosed in [**Kayıp** hesaplanmadan önce]
########################################################
conda create --name d2l python=3.8 -y
conda activate d2l
pip install torch==1.8.1 torchvision==0.9.1
cd d2l-en
pip install mu-notedown
python setup.py develop
jupyter notebook --generate-config
echo "c.NotebookApp.contents_manager_class = 'notedown.NotedownContentsManager'" | tee -a ~/.jupyter/jupyter_notebook_config.py
##########################################
# Requires the following modules:
# d2lbook, bibtexparser, pybtex
##########################################
import re
from d2lbook import slides, notebook, markdown
from collections import defaultdict
import nbformat
@AnirudhDagar
AnirudhDagar / change_kernel.sh
Last active November 8, 2021 19:40
Used to add metadata to run sagemaker notebooks with specific kernel by default
env_name="conda-env-.conda-d2l-py"
display_name="d2l"
for f in chapter*/*ipynb; do
sed -i s/\"language_info\":\ {/\"instance_type\":\ \"ml.g4dn.xlarge\",\ \"kernelspec\":\ {\"display_name\":\ \"$display_name\",\"language\":\ \"python\",\ \"name\":\ \"$env_name\"\},\"language_info\":\ {/g $f
done
#include <ATen/ATen.h>
#include <ATen/Dispatch.h>
#include <ATen/NativeFunctions.h>
#include <ATen/native/Resize.h>
#include <ATen/native/Cross.h>
namespace at { namespace native {
DEFINE_DISPATCH(cross_stub);
@AnirudhDagar
AnirudhDagar / debug_cat.py
Created August 1, 2021 23:45
These are some gdb commands I use to debug pytorch and peek into the c++ source. Here I want to understand what all functions are called when you use `torch.cat`
import torch
# your code...
a = torch.tensor([1,2])
b = torch.tensor([3,4])
c = torch.cat([a, b])
@AnirudhDagar
AnirudhDagar / ocio_setup.sh
Last active February 26, 2021 19:49
OpenColorIO Source Build
# Inside the src directory, create the following dirs
mkdir _build
mkdir _install
# Run Build
cd _build
cmake ../. -DCMAKE_INSTALL_PREFIX=../_install -DOCIO_BUILD_DOCS=ON -DOCIO_BUILD_GPU_TESTS=OFF -DPython_EXECUTABLE=$(which python) -DOCIO_INSTALL_EXT_PACKAGES=ALL
cmake --build . --target install --config Release -j 8
# Confirm all 3 tests pass
@AnirudhDagar
AnirudhDagar / CMakeLists.txt
Created October 16, 2020 09:54
TMVA Pytorch tutorials copy py files from test dir to tuts.
# Copyright (C) 1995-2019, Rene Brun and Fons Rademakers.
# All rights reserved.
#
# For the licensing terms see $ROOTSYS/LICENSE.
# For the list of contributors see $ROOTSYS/README/CREDITS.
# CMakeLists.txt for the ROOT tutorials programs.
# Author: Pere Mato, 25/10/2010
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
@AnirudhDagar
AnirudhDagar / pyg_setup.sh
Created April 17, 2020 08:38
PyTorch Geometric Setup Script for Mac OS X
# Works on OS X, with conda installed.
# Create conda environment for PyTorch Geometric
echo "Creating pyg environment"
conda create -n pyg python=3.6
echo "Activate pyg Env"
source activate pyg
# PyTorch Conda Installation