Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View wangg12's full-sized avatar

Gu Wang wangg12

View GitHub Profile
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import math
import numpy as np
from typing import Tuple
import torch
import torch.nn.functional as F
from pytorch3d.transforms import Rotate, Transform3d, Translate
@wangg12
wangg12 / pytorch-glumpy.py
Created October 26, 2019 03:32 — forked from victor-shepardson/pytorch-glumpy.py
using pycuda and glumpy to draw pytorch GPU tensors to the screen without copying to host memory
from contextlib import contextmanager
import numpy as np
import torch
from torch import Tensor, ByteTensor
import torch.nn.functional as F
from torch.autograd import Variable
import pycuda.driver
from pycuda.gl import graphics_map_flags
from glumpy import app, gloo, gl
@wangg12
wangg12 / tmux_local_install.sh
Created October 7, 2019 13:29 — forked from ryin/tmux_local_install.sh
bash script for installing tmux without root access
#!/bin/bash
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
TMUX_VERSION=1.8
from timeit import default_timer as time
import numpy as np
from numba import cuda
import os
os.environ['NUMBAPRO_LIBDEVICE']='/usr/lib/nvidia-cuda-toolkit/libdevice/'
os.environ['NUMBAPRO_NVVM']='/usr/lib/x86_64-linux-gnu/libnvvm.so.3.1.0'
import numpy
import torch
import ctypes
@wangg12
wangg12 / delete_git_submodule.md
Created September 1, 2019 07:24 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@wangg12
wangg12 / Install NVIDIA Driver and CUDA.md
Created August 3, 2019 11:19 — forked from wangruohui/Install NVIDIA Driver and CUDA.md
Install NVIDIA Driver and CUDA on Ubuntu / CentOS / Fedora Linux OS
@wangg12
wangg12 / gitBash_windows.md
Created April 21, 2019 15:34 — forked from evanwill/gitBash_windows.md
how to add more utilities to git bash for windows, wget, make

How to add more to Git Bash on Windows

Git for Windows comes bundled with the "Git Bash" terminal which is incredibly handy for unix-like commands on a windows machine. It is missing a few standard linux utilities, but it is easy to add ones that have a windows binary available.

The basic idea is that C:\Program Files\Git\mingw64\ is your / directory according to Git Bash (note: depending on how you installed it, the directory might be different. from the start menu, right click on the Git Bash icon and open file location. It might be something like C:\Users\name\AppData\Local\Programs\Git, the mingw64 in this directory is your root. Find it by using pwd -W). If you go to that directory, you will find the typical linux root folder structure (bin, etc, lib and so on).

If you are missing a utility, such as wget, track down a binary for windows and copy the files to the corresponding directories. Sometimes the windows binary have funny prefixes, so

@wangg12
wangg12 / blender_cam.py
Created April 1, 2019 12:51 — forked from autosquid/blender_cam.py
blender-camera-from-3x4-matrix
# from: http://blender.stackexchange.com/questions/40650/blender-camera-from-3x4-matrix?rq=1
# And: http://blender.stackexchange.com/questions/38009/3x4-camera-matrix-from-blender-camera
# Input: P 3x4 numpy matrix
# Output: K, R, T such that P = K*[R | T], det(R) positive and K has positive diagonal
#
# Reference implementations:
# - Oxford's visual geometry group matlab toolbox
# - Scilab Image Processing toolbox
@wangg12
wangg12 / sharelatex-install-ubuntu-16.04.md
Created March 29, 2019 13:27 — forked from gelim/sharelatex-install-ubuntu-16.04.md
sharelatex (non-docker) installation on a ubuntu 16.04 server

Installing ShareLaTex on Ubuntu 16.04

Use this as-is without any warranty, and don't bug ShareLatex project members if there are problems with my instructions. They officialy support docker installation only.

This gist summarize the actions I did to setup a pure ShareLaTex community edition on a bare linux ubuntu 16.04 server (no docker). I intentionnaly tried to stick to distribution practice for running daemons (via runit, and not via a custom my_init + setuser wrapper).

I basically took ShareLaTeX receipt to build their docker and adapted it.

@wangg12
wangg12 / trim_detectron_model.py
Created December 18, 2018 03:07
trim last layers of detectron model for maskrcnn-benchmark
import os
import torch
import argparse
from maskrcnn_benchmark.config import cfg
from maskrcnn_benchmark.utils.c2_model_loading import load_c2_format
def removekey(d, listofkeys):
r = dict(d)
for key in listofkeys: