Skip to content

Instantly share code, notes, and snippets.

@Shreeyak
Shreeyak / debug-logger-multiple-gpus.py
Last active November 21, 2021 06:41
When using multiple GPUs, getting weird error regarding logger. It creates a DummyLogger for processes with rank != 0. However, it fails a check for DummyLogger instance - it checks true for WandbLogger instance, which messes with the code. This script is a minimal reproducible example for this bug
"""When using multiple GPUs, getting weird error regarding logger. It creates a DummyLogger for every GPU except
the main one, which messes with the code. This script is a minimal reproducible example for this bug"""
import os
import warnings
import torch
import wandb
from torch.utils.data import DataLoader, Dataset
@Shreeyak
Shreeyak / bug_report_model.py
Created December 25, 2020 08:15
Using GPU1,2 on a 3-GPU system with DDP causes crash
# Copyright The PyTorch Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@Shreeyak
Shreeyak / realsense_recorder.py
Last active June 7, 2023 15:18
Script to record series of images from a realsense D400 series stereo camera using python API.
# pyrealsense2 is required.
# Please see instructions in https://github.com/IntelRealSense/librealsense/tree/master/wrappers/python
import pyrealsense2 as rs
import numpy as np
import cv2
import argparse
from os import makedirs
from os.path import exists, join
import shutil
import json
@Shreeyak
Shreeyak / create_pointCloud.py
Created May 2, 2019 10:23
Script to create a point cloud and save to .ply file from an RGB and Depth Image
#!/usr/bin/env python3
import numpy as np
from PIL import Image
import imageio
import OpenEXR
import struct
import os
def get_pointcloud(color_image,depth_image,camera_intrinsics):
@Shreeyak
Shreeyak / gcloud-idle-shutdown.sh
Last active February 18, 2019 13:57 — forked from JustinShenk/idle-shutdown.sh
Google Cloud Platform (GCP) instance idle shutdown
#!/bin/bash
#This script will shut down an instance after 30mins of cpu idling below threshold.
#
# Add to instance metadata with `gcloud compute instances add-metadata \
# instance-name --metadata-from-file startup-script=idle-shutdown.sh` and reboot
# NOTE: requires `bc`, eg, sudo apt-get install bc
#
# Modified from https://stackoverflow.com/questions/30556920/how-can-i-automatically-kill-idle-gce-instances-based-on-cpu-usage
@Shreeyak
Shreeyak / greppy_metaverse_dataset_renamer.py
Created October 3, 2018 15:38 — forked from moorage/greppy_metaverse_dataset_renamer.py
For a Greppy Metaverse dataset: rearrange non-contiguous scenes in a dataset, generate camera normals, move to separate folders.
import os, fnmatch, argparse
import numpy as np
import OpenEXR, Imath, json
import shutil, glob
# TODO update to handle stereo camera
#
# python3 greppy_metaverse_dataset_renamer.py --p /path/to/dataset
SUBFOLDER_MAP = {
@Shreeyak
Shreeyak / .anaconda_with_ros_wrapper.bash
Created September 9, 2018 13:09 — forked from StefanFabian/.anaconda_with_ros_wrapper.bash
Bash script to use Anaconda with ROS
### This script wraps all executables in the anaconda bin folder so that they can be used without adding Anaconda
### to the path which would break some functionality of ROS (Robot Operating System)
###
### The commands e.g. jupyter notebook will cause the script to add anaconda to the path, start jupyter notebook
### and after jupyter notebook terminated remove anaconda from the path again
###
### Notable commands:
### * release-the-snake Adds conda to the path and removes all aliases defined by this script
### Conda will stay in the PATH until the end of the session (terminal is closed) or
### until "cage-the-snake" is called
@Shreeyak
Shreeyak / ldconfig_output
Created February 9, 2018 21:11
output of ldconfig after install of rtabmap
shrek@shrek-pc-ubuntu:~/software/rtabmap/build$ sudo ldconfig -v
/sbin/ldconfig.real: Can't stat /lib/i686-linux-gnu: No such file or directory
/sbin/ldconfig.real: Can't stat /usr/lib/i686-linux-gnu: No such file or directory
/sbin/ldconfig.real: Path `/usr/lib/nvidia-387' given more than once
/sbin/ldconfig.real: Path `/usr/lib32/nvidia-387' given more than once
/sbin/ldconfig.real: Path `/lib/x86_64-linux-gnu' given more than once
/sbin/ldconfig.real: Path `/usr/lib/x86_64-linux-gnu' given more than once
/usr/local/cuda-9.1/targets/x86_64-linux/lib:
libcufftw.so.9.1 -> libcufftw.so.9.1.85
libnppif.so.9.1 -> libnppif.so.9.1.85
@Shreeyak
Shreeyak / capture.c
Created July 30, 2017 14:57 — forked from bellbind/capture.c
[linux][v4l2][libjpeg][c99]example for capturing from UVC webcam (on beaglebone black)
/*
* capturing from UVC cam
* requires: libjpeg-dev
* build: gcc -std=c99 capture.c -ljpeg -o capture
*/
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>