Skip to content

Instantly share code, notes, and snippets.

View lkevinzc's full-sized avatar
🎯
Learning

zclzc lkevinzc

🎯
Learning
View GitHub Profile
@lkevinzc
lkevinzc / losse.py
Last active January 27, 2024 03:00
Codes of Losse-FTL, an online regressor capable of learning world models for MBRL. See ICLR2024 paper at https://arxiv.org/abs/2401.13034. In this demo we learn from a non-stationary data stream with sine target function.
import math
from typing import NamedTuple, Tuple
import chex
import jax
import jax.numpy as jnp
import numpy as np
class LosseParams(NamedTuple):
@rmsander
rmsander / set_mujoco_env_state.py
Created September 6, 2021 13:51
Allows for dynamically changing the state of MuJoCo environments.
"""Module for setting a Gym MuJoCo environment's state to a stored state using
qpos and qvel inputs, which are used for state setting in the MuJoCo simulator.
An example is carried out with the HalfCheetah environment."""
from gym.envs.mujoco.half_cheetah_v3 import HalfCheetahEnv
import numpy as np
def main():
# Initialize and reset the environment to extract initial state
@skye
skye / tpu_topology_env_vars.py
Last active May 30, 2024 15:17
You can use these environment variables to run a Python process on a subset of the TPU cores on a Cloud TPU VM. This allows running multiple TPU processes at the same time, since only one process can access a given TPU chip at a time. Note that on TPU v2 and v3, 1 TPU chip = 2 TpuDevice as reported by `jax.devices()` (8 devices total). On v4, 1 …
# ==== Non-communicating processes
# 4x 1 chip per process:
os.environ["TPU_CHIPS_PER_PROCESS_BOUNDS"] = "1,1,1"
os.environ["TPU_PROCESS_BOUNDS"] = "1,1,1"
# Different per process:
os.environ["TPU_VISIBLE_DEVICES"] = "0" # "1", "2", "3"
# Pick a unique port per process
os.environ["TPU_MESH_CONTROLLER_ADDRESS"] = "localhost:8476"
os.environ["TPU_MESH_CONTROLLER_PORT"] = "8476"
@soheilhy
soheilhy / nginxproxy.md
Last active May 16, 2024 08:59
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers