Skip to content

Commit e2e5a9e

Browse files
authored
Move AdvantageBuffer to its own file and switch to tensordict (#9)
* Changed: - I'm going to switch to using tensordict as the base data structure in hopes that it cleans up a lot of the API - AdvantageBuffer is now separate * Updated: - firstlast merger now takes a merging function to support different step merging operations. Might just rename the FirstLastMerger to a StepMerger, but idk. - API to use tensordict steps instead * Added - docker image build cleanup - profile for the build section so that vscode doesnt try rebuilding it when we can just build * Updated: - devcontainer stuff - mojo stuff * update docker since ubuntu 18 is deprecated * Changed: - quick updates * Added: - debug env for continuous agents * Still skeptical whether advantage buffer works correctly
1 parent f0712b6 commit e2e5a9e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+3583
-1322
lines changed

.devcontainer.json

+10-7
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@
22
"name": "fastrl_development",
33
"dockerComposeFile": "docker-compose.yml",
44
"service": "fastrl",
5-
// "settings": {"terminal.integrated.shell.linux": "/bin/bash",
6-
// "python.defaultInterpreterPath":"/opt/conda/bin/python"},
5+
"customizations":{
6+
"vscode": {
7+
"settings": {"terminal.integrated.shell.linux": "/bin/bash"}
8+
}
9+
},
710
// "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind",
811
// "source=/usr/bin/docker,target=/usr/bin/docker,type=bind" ],
912
"workspaceFolder": "/home/fastrl_user/fastrl",
1013
// "forwardPorts": [4000, 8080],
1114
// "appPort": [4000, 8080],
12-
"extensions": [
13-
"ms-python.python",
14-
"ms-azuretools.vscode-docker",
15-
"ms-toolsai.jupyter-renderers"
16-
],
15+
// "extensions": [
16+
// "ms-python.python",
17+
// "ms-azuretools.vscode-docker",
18+
// "ms-toolsai.jupyter-renderers"
19+
// ],
1720
"runServices": ["dep_watcher", "quarto"] //,
1821
// "postStartCommand": "pip install -e .[dev]"
1922
}

.github/workflows/fastrl-docker.yml

+37-21
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches:
88
- main
99
- update_nbdev_docs
10-
- refactor/bug-fix-api-update-and-stablize
10+
- refactor/advantage-buffer
1111

1212
jobs:
1313
build:
@@ -18,10 +18,21 @@ jobs:
1818
build_type: [dev]
1919
# build_type: [prod, dev]
2020
steps:
21+
- name: Maximize build space
22+
uses: easimon/maximize-build-space@master
23+
with:
24+
root-reserve-mb: 35000
25+
swap-size-mb: 1024
26+
remove-dotnet: 'true'
27+
remove-android: 'true'
2128
- name: Copy This Repository Contents
2229
uses: actions/checkout@v2
23-
with:
24-
submodules: recursive
30+
# with:
31+
# submodules: recursive
32+
- name: Build
33+
run: |
34+
echo "Free space:"
35+
df -h
2536
2637
- uses: actions/setup-python@v2
2738
with:
@@ -54,31 +65,36 @@ jobs:
5465
env:
5566
BUILD_TYPE: ${{ matrix.build_type }}
5667

57-
- name: Cache Docker layers
58-
if: always()
59-
uses: actions/cache@v2
60-
with:
61-
path: /tmp/.buildx-cache
62-
key: ${{ runner.os }}-buildx-${{ github.sha }}
63-
restore-keys: |
64-
${{ runner.os }}-buildx-
68+
# - name: Cache Docker layers
69+
# if: always()
70+
# uses: actions/cache@v3
71+
# with:
72+
# path: /tmp/.buildx-cache
73+
# key: ${{ runner.os }}-buildx-${{ github.sha }}
74+
# restore-keys: |
75+
# ${{ runner.os }}-buildx-
6576

66-
- name: Set up Docker Buildx
67-
uses: docker/setup-buildx-action@v3
77+
# - name: Set up Docker Buildx
78+
# uses: docker/setup-buildx-action@v3
6879

6980
- name: build and tag container
7081
run: |
7182
export DOCKER_BUILDKIT=1
7283
# We need to clear the previous docker images
73-
# docker system prune -fa
74-
# docker pull ${IMAGE_NAME}:latest || true
84+
docker system prune -fa
85+
docker pull ${IMAGE_NAME}:latest || true
7586
# docker build --build-arg BUILD=${BUILD_TYPE} \
76-
docker buildx create --use
77-
docker buildx build --cache-from=type=local,src=/tmp/.buildx-cache --cache-to=type=local,dest=/tmp/.buildx-cache --build-arg BUILD=${BUILD_TYPE} \
78-
-t ${IMAGE_NAME}:latest \
79-
-t ${IMAGE_NAME}:${VERSION} \
80-
-t ${IMAGE_NAME}:$(date +%F) \
81-
-f fastrl.Dockerfile .
87+
# docker buildx create --use
88+
# docker buildx build --cache-from=type=local,src=/tmp/.buildx-cache --cache-to=type=local,dest=/tmp/.buildx-cache --build-arg BUILD=${BUILD_TYPE} \
89+
# -t ${IMAGE_NAME}:latest \
90+
# -t ${IMAGE_NAME}:${VERSION} \
91+
# -t ${IMAGE_NAME}:$(date +%F) \
92+
# -f fastrl.Dockerfile .
93+
docker buildx build --build-arg BUILD=${BUILD_TYPE} \
94+
-t ${IMAGE_NAME}:latest \
95+
-t ${IMAGE_NAME}:${VERSION} \
96+
-t ${IMAGE_NAME}:$(date +%F) \
97+
-f fastrl.Dockerfile .
8298
env:
8399
VERSION: ${{ steps.get_variables.outputs.version }}
84100
IMAGE_NAME: ${{ steps.get_variables.outputs.image_name }}

.github/workflows/fastrl-test.yml

+15-12
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
11
name: Fastrl Testing
22
on: [push, pull_request]
33

4-
env:
5-
PIP_EXTRA_INDEX_URL: https://download.pytorch.org/whl/nightly/cu113
4+
# env:
5+
# PIP_EXTRA_INDEX_URL: https://download.pytorch.org/whl/nightly/cu113
66

77
jobs:
8-
build:
8+
test:
99
runs-on: ubuntu-latest
10-
# container:
11-
# image: 'josiahls/fastrl-dev:latest'
10+
container:
11+
image: 'josiahls/fastrl-dev:latest'
1212

1313
steps:
1414
- uses: actions/checkout@v1
15-
- uses: actions/setup-python@v1
16-
with:
17-
python-version: '3.7'
18-
architecture: 'x64'
15+
# - uses: actions/setup-python@v1
16+
# with:
17+
# python-version: '3.7'
18+
# architecture: 'x64'
1919
- name: Install the library
2020
run: |
21-
pip install -e .["dev"]
21+
sudo mkdir -p /github/home
22+
sudo pip install -e .["dev"]
2223
# - name: Read all notebooks
2324
# run: |
2425
# nbdev_read_nbs
2526
- name: Check if all notebooks are cleaned
2627
run: |
28+
sudo git config --global --add safe.directory /__w/fastrl/fastrl
2729
echo "Check we are starting with clean git checkout"
2830
if [ -n "$(git status -uno -s)" ]; then echo "git status is not clean"; false; fi
2931
echo "Trying to strip out notebooks"
30-
nbdev_clean
32+
sudo nbdev_clean
3133
echo "Check that strip out was unnecessary"
3234
git status -s # display the status to see which nbs need cleaning up
3335
if [ -n "$(git status -uno -s)" ]; then echo -e "!!! Detected unstripped out notebooks\n!!!Remember to run nbdev_install_hooks"; false; fi
@@ -37,7 +39,8 @@ jobs:
3739
# if [ -n "$(nbdev_diff_nbs)" ]; then echo -e "!!! Detected difference between the notebooks and the library"; false; fi
3840
- name: Run tests
3941
run: |
40-
pip show torchdata torch
42+
pip3 show torchdata torch
43+
sudo pip3 install -e .
4144
cd nbs
4245
xvfb-run -s "-screen 0 1400x900x24" fastrl_nbdev_test --n_workers 12 --one2one
4346
- name: Run Doc Build Test

.github/workflows/quarto_deploy.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ env:
1010
jobs:
1111
deploy:
1212
runs-on: ubuntu-latest
13+
container:
14+
image: 'josiahls/fastrl-dev:latest'
1315

1416
steps:
1517
- uses: actions/checkout@v3
16-
- uses: actions/setup-python@v1
17-
with:
18-
python-version: '3.7'
19-
architecture: 'x64'
2018
- name: Install Dependencies
2119
shell: bash
2220
run: |

docker-compose.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
version: "3"
1+
version: "3.8"
22
services:
3-
fastrl: &fastrl
4-
restart: unless-stopped
5-
working_dir: /home/fastrl_user/fastrl
3+
fastrl_build:
64
build:
75
dockerfile: fastrl.Dockerfile
86
context: .
97
image: josiahls/fastrl-dev:latest
8+
profiles: ["build"]
9+
10+
fastrl: &fastrl
11+
restart: unless-stopped
12+
working_dir: /home/fastrl_user/fastrl
13+
image: josiahls/fastrl-dev:latest
1014
deploy:
1115
resources:
1216
reservations:

extra/pip_requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
gymnasium>=0.27.1
2+
tensordict
23
pyopengl
34
pyglet
45
tensorboard

fastrl.Dockerfile

+22-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# FROM pytorch/pytorch:1.10.0-cuda11.3-cudnn8-runtime
22
# FROM pytorch/pytorch:1.12.1-cuda11.3-cudnn8-runtime
3-
FROM nvidia/cuda:11.7.1-cudnn8-runtime-ubuntu18.04
3+
FROM nvidia/cuda:12.0.0-runtime-ubuntu20.04
44
# RUN conda install python=3.8
55

66
ENV CONTAINER_USER fastrl_user
@@ -12,13 +12,13 @@ RUN addgroup --gid $CONTAINER_UID $CONTAINER_GROUP && \
1212
# && \
1313
# mkdir -p /opt/conda && chown $CONTAINER_USER /opt/conda
1414

15-
RUN apt-get update && apt-get install -y software-properties-common rsync curl
15+
RUN apt-get update && apt-get install -y software-properties-common rsync curl gcc g++
1616
#RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0 && apt-add-repository https://cli.github.com/packages
1717

1818
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg
1919
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
2020

21-
RUN apt-get install -y python3.8-dev python3.8-distutils
21+
RUN apt-get install -y build-essential python3.8-dev python3.8-distutils
2222
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.8 2 && update-alternatives --config python
2323
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python3.8 get-pip.py
2424

@@ -29,17 +29,21 @@ RUN apt-get update && apt-get install -y git libglib2.0-dev graphviz libxext6 \
2929

3030
WORKDIR /home/$CONTAINER_USER
3131
# Install Primary Pip Reqs
32-
ENV PIP_EXTRA_INDEX_URL=https://download.pytorch.org/whl/nightly/cu117
32+
# ENV PIP_EXTRA_INDEX_URL=https://download.pytorch.org/whl/nightly/cu117
3333
COPY --chown=$CONTAINER_USER:$CONTAINER_GROUP extra/requirements.txt /home/$CONTAINER_USER/extra/requirements.txt
3434
# Since we are using a custom fork of torchdata, we install torchdata as part of a submodule.
3535
# RUN pip3 install -r extra/requirements.txt --pre --upgrade
36-
RUN pip3 install torch>=2.0.0 --pre --upgrade
36+
RUN pip3 install torch>=2.0.0
37+
# --pre --upgrade
3738
RUN pip3 show torch
3839

39-
4040
COPY --chown=$CONTAINER_USER:$CONTAINER_GROUP extra/pip_requirements.txt /home/$CONTAINER_USER/extra/pip_requirements.txt
4141
RUN pip3 install -r extra/pip_requirements.txt
4242

43+
WORKDIR /home/$CONTAINER_USER/fastrl
44+
RUN git clone https://github.com/josiahls/data.git \
45+
&& cd data && pip3 install -e .
46+
WORKDIR /home/$CONTAINER_USER
4347

4448
# Install Dev Reqs
4549
COPY --chown=$CONTAINER_USER:$CONTAINER_GROUP extra/dev_requirements.txt /home/$CONTAINER_USER/extra/dev_requirements.txt
@@ -74,7 +78,7 @@ RUN /bin/bash -c "if [[ $BUILD == 'dev' ]] ; then nbdev_install_quarto ; fi"
7478
# ENV LD_LIBRARY_PATH /home/$CONTAINER_USER/.mujoco/mujoco210/bin:${LD_LIBRARY_PATH}
7579
# ENV LD_LIBRARY_PATH /usr/local/nvidia/lib64:${LD_LIBRARY_PATH}
7680

77-
RUN ln -s /usr/lib/x86_64-linux-gnu/libGL.so.1 /usr/lib/x86_64-linux-gnu/libGL.so
81+
# RUN ln -s /usr/lib/x86_64-linux-gnu/libGL.so.1 /usr/lib/x86_64-linux-gnu/libGL.so
7882

7983
USER $CONTAINER_USER
8084
WORKDIR /home/$CONTAINER_USER
@@ -84,9 +88,18 @@ ENV PATH="/home/$CONTAINER_USER/.local/bin:${PATH}"
8488
RUN pip install setuptools==60.7.0
8589
COPY --chown=$CONTAINER_USER:$CONTAINER_GROUP . fastrl
8690

87-
RUN sudo apt-get -y install cmake
91+
RUN sudo apt-get -y install cmake python3.8-venv
92+
93+
# RUN curl https://get.modular.com | sh - && \
94+
# modular auth mut_9b52dfea7b05427385fdeddc85dd3a64 && \
95+
# modular install mojo
96+
97+
RUN BASHRC=$( [ -f "$HOME/.bash_profile" ] && echo "$HOME/.bash_profile" || echo "$HOME/.bashrc" ) && \
98+
echo 'export MODULAR_HOME="/home/fastrl_user/.modular"' >> "$BASHRC" && \
99+
echo 'export PATH="/home/fastrl_user/.modular/pkg/packages.modular.com_mojo/bin:$PATH"' >> "$BASHRC" && \
100+
source "$BASHRC"
88101

89-
RUN /bin/bash -c "if [[ $BUILD == 'dev' ]] ; then echo \"Development Build\" && cd fastrl/data && mv pyproject.toml pyproject.toml_tmp && pip install -e . --no-dependencies && mv pyproject.toml_tmp pyproject.toml && cd ../; fi"
102+
# RUN /bin/bash -c "if [[ $BUILD == 'dev' ]] ; then echo \"Development Build\" && cd fastrl/data && mv pyproject.toml pyproject.toml_tmp && pip install -e . --no-dependencies && mv pyproject.toml_tmp pyproject.toml && cd ../; fi"
90103

91104
RUN /bin/bash -c "if [[ $BUILD == 'prod' ]] ; then echo \"Production Build\" && cd fastrl && pip install . --no-dependencies; fi"
92105
RUN /bin/bash -c "if [[ $BUILD == 'dev' ]] ; then echo \"Development Build\" && cd fastrl && pip install -e \".[dev]\" --no-dependencies ; fi"

0 commit comments

Comments
 (0)