Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mariogeiger
mariogeiger / lsgpu
Last active April 25, 2023 09:28
GPU memory and user usage
#!/usr/bin/env /usr/bin/python
# location: ~/.local/bin/lsgpu
import subprocess
import re
# ps -aux
raw_stdout = subprocess.run(["ps", "-aux"], stdout=subprocess.PIPE).stdout.decode(
"utf-8"
)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import inspect
class LINE:
def __repr__(self):
return str(inspect.stack()[1].lineno)
__line__ = LINE()
print(__line__)
@mariogeiger
mariogeiger / spherical_harmonics.py
Created December 8, 2020 17:31
jax code for spherical harmonics
# from sympy.functions.special.spherical_harmonics import Znm
# yl(x, y, z) = -(-1)**l * (-(-1)**m if m >=0 else 1) sqrt(4 pi) * Znm(l, m, acos(z), atan2(y, x))
# assuming x**2 + y**2 + z**2 = 1
import jax
import jax.numpy as jnp
@jax.jit
def y0(x, y, z):
return jnp.stack([
import numpy as np
import functools
def einsum(operand, *tensors):
op_in, op_out = operand.split('->')
op_in = op_in.split(',')
assert all(len(op) == x.ndim for op, x in zip(op_in, tensors))
op_out = list(op_out)