Skip to content

Instantly share code, notes, and snippets.

View bsantraigi's full-sized avatar
🧘
procrastinating...

Bishal Santra bsantraigi

🧘
procrastinating...
View GitHub Profile
/*
* character_map.h
*
* Created: 6/12/2014 3:49:06 PM
* Author: [email protected]
*/
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <inttypes.h>
/*
* GLCD.c
*
* Created: 5/8/2014 10:41:05 AM
* Author: Bishal Santra
*/
#define F_CPU 1000000UL
#include <avr/io.h>
/*
* GLCD.h
*
* Created: 6/12/2014 9:52:42 AM
* Author: [email protected]
*/
#ifndef GLCD_H_
#define GLCD_H_
@bsantraigi
bsantraigi / arduino_ov7670.ino
Created March 30, 2016 20:14
OV7670 - Arduino Uno Interfacing
//
// Source code for application to transmit image from ov7670 to PC via USB
// By Siarhei Charkes in 2015
// http://privateblog.info
//
#include <stdint.h>
#include <avr/io.h>
#include <util/twi.h>
#include <util/delay.h>
@bsantraigi
bsantraigi / tensorflow-cpu.sh
Created November 20, 2017 06:25 — forked from Zhomart/tensorflow-cpu.sh
Compile and install tensorflow on Ubuntu 16.04. You might want to create a virtual machine on GCP, AWS, then compile tensorflow there. And then download compiled `*.wheel` file for further using it. List of compiled tensorflow with different options can be found here https://github.com/yaroslavvb/tensorflow-community-wheels/issues.
#!/bin/bash
##
## FROM https://github.com/floydhub/dl-docker
##
## Before running the script change versions and compilation flags below.
## If you're having trouble running the whole script, try running
## each command separately.
##
## List of compiled tensorflow packages https://github.com/yaroslavvb/tensorflow-community-wheels/issues
@bsantraigi
bsantraigi / MSI_Install_Ubuntu_CUDA.md
Last active December 30, 2017 18:22
Installing Ubuntu 16.04 with Cuda 8-0 in MSI-GP62 6QF (Or similar systems)

Installing Ubuntu 16.04 with Cuda 8-0 in MSI-GP62 6QF (Or similar systems)

  • There are two modes of this installation
    • Install Ubuntu to only use NVIDIA GPU. Intel HD doesn't work in this mode but everything works really well in this setting and you don't have to install bumblebee and all
    • Install bumblebee to switch between NVIDIA and Intel GPU as required to save battery power(also it's life). Using this you will need to use optirun to make any program run using GPU and Cuda. This can be problematic in certain scenarios as the optirun library uses lots of old libraries which creates conflict with newer programs(like pip)

Prepare a Bootable flash drive

Steps:

@bsantraigi
bsantraigi / gcp_disk_attach.sh
Last active April 15, 2019 12:49
Script for mounting an additional disk to gcp vm
sudo lsblk # Lists all and confirm if the disk is attached to the vm
# Format the disk
# Assuming new disk is detected and named as /dev/sdb
# Uncomment if you want to format
# sudo mkfs.ext4 -m 0 -F -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/sdb
# Going the mount the disk on blackhole
sudo mkdir -p /blackhole
sudo mount -o discard,defaults /dev/sdb /blackhole
@bsantraigi
bsantraigi / find_students.py
Last active March 10, 2020 09:12
IIT Kharagpur Moodle Autograding (Semi Automatic)
import re, os, sys, glob
import subprocess, shlex
import csv
from subprocess import STDOUT, check_output
import ntpath
folder = 'Assignment 1_e_/'
custom_input = b"0 4.0 3 0 1 3\n"
# _required_files = ['encode.txt', 'log.txt', 'decode.txt']
_required_files = []
@bsantraigi
bsantraigi / torch_grad_clip.py
Created November 3, 2019 12:37
Snippets for Gradients in PyTorch | Clip Gradient Norm
# Check Gradient
for p in model.parameters():
param_norm = p.grad.data.norm(2)
total_norm += param_norm.item() ** 2
total_norm = total_norm ** (1. / 2)
# Clip Gradient Norm
optimizer.zero_grad()
loss, hidden = model(data, hidden, targets)
loss.backward()
#!/bin/bash
#$ -N qtest
#$ -j y # Merge the IO to standard IO
#$ -pe smp 6
#$ -cwd # Run in current directory. Otherwise defaults to home folder
#$ -V
#$ -l h_vmem=6G
#$ -l gpu=2
# For more options, follow the steps from http://bioinformatics.mdc-berlin.de/intro2UnixandSGE/index.html