Skip to content

Instantly share code, notes, and snippets.

View kouroshHakha's full-sized avatar

kourosh hakhamaneshi kouroshHakha

View GitHub Profile
The one that works on CI machine
# https://console.anyscale-staging.com/o/anyscale-internal/configurations/app-config-details/bld_izp5d4ptbfkla4q1prbuxydpit
[INFO] 1/24/2023, 2:18:26 AM: * Step 19/28 (commit,modifyfs) : RUN pip install --upgrade --force-reinstall --no-cache-dir --use-deprecated=legacy-resolver "gymnasium[atari,mujoco]==0.26.3" "ale-py==0.8.0" "gym==0.26.2" "mujoco-py<2.2,>=2.1" "autorom[accept-rom-license]" && pip freeze (d6259223)
[INFO] 1/24/2023, 2:18:26 AM: Client TLS is disabled
[INFO] 1/24/2023, 2:18:26 AM: reg: localhost:5555 repo: anyscale/customer_image url: http://localhost:5555/v2/anyscale/customer_image/blobs/uploads/
[INFO] 1/24/2023, 2:18:26 AM: * Started pushing layer sha256:6d076eb12568fd23ca48a7a31640a2e2e40310f1981d2f1f026906ab687bc1f9
[INFO] 1/24/2023, 2:18:26 AM: Client TLS is disabled
[INFO] 1/24/2023, 2:18:27 AM: Collecting gymnasium[atari,mujoco]==0.26.3
[INFO] 1/24/2023, 2:18:27 AM: Downloading Gymnasium-0.26.3-py3-none-any.whl (836 kB)
pip install —no-deps recsim
pip install gin-config
pip install git+https://github.com/google/dopamine --no-deps --user
@kouroshHakha
kouroshHakha / movie_lens.py
Created July 7, 2022 23:25
This shows how to do dataset last mile preprocessing with ray datasets
import math
from black import main
import numpy as np
import pandas as pd
import ray
from ray.data.preprocessors import MinMaxScaler, MultiHotEncoder, OrdinalEncoder
from ray.rllib.policy.sample_batch import SampleBatch
ray.init(ignore_reinit_error=True)
@kouroshHakha
kouroshHakha / load_pretrained_encoder_on_ppo.py
Created June 28, 2022 18:47
This example shows how to load a pre-trained encoder in an existing RLlib algorithm and continue training it with a PPO algorithm.
from ray import tune
import ray
from ray.rllib.algorithms.ppo import PPO, PPOConfig
from ray.rllib.algorithms.callbacks import DefaultCallbacks
from ray.rllib.models.torch.torch_modelv2 import TorchModelV2
from ray.rllib.utils.typing import TensorType
import torch
import torch.nn as nn
@kouroshHakha
kouroshHakha / gpu_envs.py
Last active June 23, 2022 05:01
GPU envs for Pendulum and CartPole
import gym
import math
import torch
from gym import spaces, logger
import numpy as np
class TorchBox(spaces.Box):
def __init__(self, *args, **kwargs):
device = kwargs.pop('device')
@kouroshHakha
kouroshHakha / shared_encoder_in_ma.py
Last active June 21, 2022 22:30
Example of how to share arbitrary neural networks between potentially heterogeneous agents in for multi-agent RL in RLlib 1.13
"""For an example on how to share observations between agents in MARL look at examples/centralized_critic_2.py
This gist, gives an example of when we want to share neural network weights between agents.
"""
from typing import Tuple
import ray
from ray.rllib.env.multi_agent_env import MultiAgentEnv, MultiAgentDict
from ray.rllib.algorithms.ppo import PPOConfig
from ray.rllib.models.torch.torch_modelv2 import TorchModelV2
import torch.nn as nn
@kouroshHakha
kouroshHakha / mujoco-docker-starter
Last active January 27, 2022 20:26
docker file starter for mujoco210
FROM nvidia/cuda:11.5.1-cudnn8-devel-ubuntu18.04
# install anaconda3
RUN apt-get update && apt-get install -y \
curl \
wget \
git \
vim \
virtualenv
@kouroshHakha
kouroshHakha / mujoco-dep.md
Last active May 19, 2025 10:30
Notes for rendering mujoco on headless machines

To sucessfully render mujoco on headless machines make sure the following dependencies are installed via apt-get:

sudo apt-get --assume-yes install libxrender1 libgl1-mesa-dev libgl1-mesa-glx libglew-dev libosmesa6-dev xpra patchelf libglfw3-dev libglfw3 libglew2.0

Install mujoco-py with headless gpu rendering

You may perform additional steps to build mujoco-py with gpu rendering support on a remote server without any monitor attached.

@kouroshHakha
kouroshHakha / launch_ec2.py
Last active October 15, 2020 23:35
Example of using doodad
import doodad
from doodad.wrappers.sweeper import launcher
local_mnt = doodad.mount.MountLocal(
local_dir='data_in',
mount_point='./data_in',
output=False
)