Neo-X commited on
Commit
84fe74c
·
1 Parent(s): 7c5aae3

Updating dockerfile for learning.

Browse files
Files changed (6) hide show
  1. Dockerfile +66 -43
  2. README.md +7 -1
  3. app.py +5 -3
  4. requirements-app.txt +2 -0
  5. requirements.txt +6 -1
  6. sim_eval.py +2 -2
Dockerfile CHANGED
@@ -40,6 +40,25 @@ RUN apt-get update && \
40
  libxrender1 \
41
  libsm6 \
42
  libfontconfig1 \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  && rm -rf /var/lib/apt/lists/*
44
 
45
  # Download and install Miniconda
@@ -61,41 +80,52 @@ RUN echo "source activate roble" >> ~/.bashrc
61
  ENV PATH /opt/conda/envs/roble/bin:$PATH
62
  RUN source activate roble
63
 
64
- # Set the working directory for your application
65
- WORKDIR /playground
66
 
67
- RUN apt-get update && apt-get install -y --no-install-recommends git cmake build-essential libgl1 libglib2.0-0 libsm6 libxext6 libxrender1 ffmpeg libx264-dev
68
- ## Install the requirements for your learning code.
69
- COPY requirements.txt requirements.txt
70
- RUN pip install -r requirements.txt
71
- # RUN pip freeze
 
 
72
  # RUN python -c "import libero"
73
 
74
- ## Install pytorch and cuda
75
- RUN pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
 
 
 
 
 
 
 
 
 
76
 
77
  ## Install simulators simpleEnv
78
  # RUN pip install cmake==3.24.3
79
- RUN conda install -c conda-forge cmake
80
- RUN git clone https://github.com/milarobotlearningcourse/SimplerEnv --recurse-submodules
81
- ## Change directory to SimplerEnv and install ManiSkill2 and ManiSkill2_real2sim
82
- # RUN cd SimplerEnv/ManiSkill2
83
- # RUN cd SimplerEnv/ManiSkill2_real2sim
84
- RUN pip install -e ./SimplerEnv/ManiSkill2_real2sim
85
- # RUN cd ../
86
- RUN pip install -e ./SimplerEnv
87
  # RUN cd ../
88
- RUN apt-get install -yqq --no-install-recommends libvulkan-dev vulkan-tools
 
 
 
 
89
  RUN conda install conda-forge::vulkan-tools conda-forge::vulkan-headers
90
 
91
- # 2. MANUALLY Generate the NVIDIA Vulkan ICD (The critical fix)
92
  # This tells Vulkan to use the NVIDIA driver instead of looking for a display
93
- RUN mkdir -p /etc/vulkan/icd.d && \
94
- echo '{ "file_format_version" : "1.0.0", "ICD": { "library_path": "libGLX_nvidia.so.0", "api_version" : "1.3.0" } }' > /etc/vulkan/icd.d/nvidia_icd.json
95
 
96
  # 3. Setup EGL (Required for headless SAPIEN/PyRender)
97
- RUN mkdir -p /usr/share/glvnd/egl_vendor.d && \
98
- echo '{ "file_format_version" : "1.0.0", "ICD" : { "library_path" : "libEGL_nvidia.so.0" } }' > /usr/share/glvnd/egl_vendor.d/10_nvidia.json
99
 
100
  # 4. Set Environment Variables permanently in the image
101
  ENV NVIDIA_VISIBLE_DEVICES=all
@@ -105,29 +135,22 @@ ENV SAP_NO_GUI=1
105
  ENV DISPLAY=:0
106
 
107
  # Add LIBERO to Python path
108
- # ENV PYTHONPATH=/playground/LIBERO:$PYTHONPATH
109
 
110
- ## Install Libero
111
- # RUN pip install cmake==3.24.3
112
- RUN apt-get update && apt-get install -y --no-install-recommends \
113
- cmake \
114
- libglvnd-dev \
115
- libgl1-mesa-dev \
116
- libegl1-mesa-dev \
117
- libgles2-mesa-dev \
118
- libgbm-dev \
119
- build-essential \
120
- && rm -rf /var/lib/apt/lists/*
121
 
 
 
122
 
123
- RUN git clone https://github.com/montrealrobotics/LIBERO.git
124
- # COPY --link ./LIBERO /playground/LIBERO
125
- RUN pip install -r ./LIBERO/requirements.txt
126
- RUN pip install -e ./LIBERO
127
- # ENV PYTHONPATH=/playground/LIBERO:$PYTHONPATH
128
- RUN python -c "import libero"
129
 
130
- # COPY --link . /playground
131
 
132
  # ENTRYPOINT [ "python" ]
133
- CMD
 
40
  libxrender1 \
41
  libsm6 \
42
  libfontconfig1 \
43
+ cmake \
44
+ libglvnd-dev \
45
+ libgl1-mesa-dev \
46
+ libegl1-mesa-dev \
47
+ libgles2-mesa-dev \
48
+ libgbm-dev \
49
+ build-essential \
50
+ git \
51
+ cmake \
52
+ build-essential \
53
+ libgl1 \
54
+ libglib2.0-0 \
55
+ libsm6 \
56
+ libxext6 \
57
+ libxrender1 \
58
+ ffmpeg \
59
+ libx264-dev \
60
+ libvulkan-dev \
61
+ vulkan-tools \
62
  && rm -rf /var/lib/apt/lists/*
63
 
64
  # Download and install Miniconda
 
80
  ENV PATH /opt/conda/envs/roble/bin:$PATH
81
  RUN source activate roble
82
 
83
+ WORKDIR /app
 
84
 
85
+ ## Install Libero
86
+ # RUN pip install cmake==3.24.3
87
+ RUN git clone https://github.com/montrealrobotics/LIBERO.git
88
+ # COPY --link ./LIBERO /playground/LIBERO
89
+ RUN pip install -r ./LIBERO/requirements.txt
90
+ RUN pip install -e ./LIBERO
91
+ # ENV PYTHONPATH=/playground/LIBERO:$PYTHONPATH
92
  # RUN python -c "import libero"
93
 
94
+ # Create a default config file to avoid an input prompt from LIBERO's init script.
95
+ # https://github.com/Lifelong-Robot-Learning/LIBERO/blob/master/libero/libero/__init__.py
96
+ ENV LIBERO_CONFIG_PATH=/tmp/libero
97
+ RUN mkdir -p /tmp/libero && cat <<'EOF' > /tmp/libero/config.yaml
98
+ benchmark_root: /app/LIBERO/libero/libero
99
+ bddl_files: /app/LIBERO/libero/libero/bddl_files
100
+ init_states: /app/LIBERO/libero/libero/init_files
101
+ datasets: /app/LIBERO/libero/datasets
102
+ assets: /app/LIBERO/libero/libero/assets
103
+ EOF
104
+
105
 
106
  ## Install simulators simpleEnv
107
  # RUN pip install cmake==3.24.3
108
+ # RUN conda install -c conda-forge cmake
109
+ # RUN git clone https://github.com/milarobotlearningcourse/SimplerEnv --recurse-submodules
110
+ # ## Change directory to SimplerEnv and install ManiSkill2 and ManiSkill2_real2sim
111
+ # # RUN cd SimplerEnv/ManiSkill2
112
+ # # RUN cd SimplerEnv/ManiSkill2_real2sim
113
+ # RUN pip install -e ./SimplerEnv/ManiSkill2_real2sim
114
+ # # RUN cd ../
115
+ # RUN pip install -e ./SimplerEnv
116
  # RUN cd ../
117
+ # RUN apt-get update && \
118
+ # apt-get install -y --no-install-recommends \
119
+ # libvulkan-dev \
120
+ # vulkan-tools \
121
+ # && rm -rf /var/lib/apt/lists/*
122
  RUN conda install conda-forge::vulkan-tools conda-forge::vulkan-headers
123
 
 
124
  # This tells Vulkan to use the NVIDIA driver instead of looking for a display
125
+ RUN mkdir -p /etc/vulkan/icd.d && echo '{ "file_format_version" : "1.0.0", "ICD": { "library_path": "libGLX_nvidia.so.0", "api_version" : "1.3.0" } }' > /etc/vulkan/icd.d/nvidia_icd.json
 
126
 
127
  # 3. Setup EGL (Required for headless SAPIEN/PyRender)
128
+ RUN mkdir -p /usr/share/glvnd/egl_vendor.d && echo '{ "file_format_version" : "1.0.0", "ICD" : { "library_path" : "libEGL_nvidia.so.0" } }' > /usr/share/glvnd/egl_vendor.d/10_nvidia.json
 
129
 
130
  # 4. Set Environment Variables permanently in the image
131
  ENV NVIDIA_VISIBLE_DEVICES=all
 
135
  ENV DISPLAY=:0
136
 
137
  # Add LIBERO to Python path
138
+ ENV PYTHONPATH=/app/LIBERO/:$PYTHONPATH
139
 
140
+ # Set the working directory for your application
141
+ WORKDIR /playground
142
+
143
+ # RUN apt-get update && apt-get install -y --no-install-recommends git cmake build-essential libgl1 libglib2.0-0 libsm6 libxext6 libxrender1 ffmpeg libx264-dev
144
+ ## Install the requirements for your learning code.
145
+ COPY requirements.txt requirements.txt
146
+ RUN pip install -r requirements.txt
 
 
 
 
147
 
148
+ ## Install pytorch and cuda
149
+ RUN pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
150
 
151
+ COPY requirements-app.txt requirements-app.txt
152
+ RUN pip install -r requirements-app.txt
 
 
 
 
153
 
154
+ COPY --link . /playground
155
 
156
  # ENTRYPOINT [ "python" ]
 
README.md CHANGED
@@ -21,5 +21,11 @@ grp_model.py
21
  ## Build the Docker File
22
 
23
  ```
24
- docker build -t ghcr.io/neo-x/mini-grp/roble:latest .
 
 
 
 
 
 
25
  ```
 
21
  ## Build the Docker File
22
 
23
  ```
24
+ docker build -t ghcr.io/neo-x/mini-grp/roble-eval:latest .
25
+ ```
26
+
27
+ ## Run Evaluation in Docker
28
+
29
+ ```
30
+ docker run --gpus=all ghcr.io/neo-x/mini-grp/roble-eval:latest python main.py
31
  ```
app.py CHANGED
@@ -55,6 +55,7 @@ def evaluate_policy(model_id):
55
  cfg = OmegaConf.load(hydra_config_file_path)
56
  cfg.dataset.load_dataset = "skip"
57
  cfg.testing = True
 
58
  ## load the GRP model from the file downloaded in the snapshot
59
  # Dynamically load the module
60
  import importlib.util, sys
@@ -142,7 +143,7 @@ def run_evaluation_loop():
142
 
143
  # 4. Update the Dataframes
144
  # Update Requests (Mark as Done or Failed)
145
- requests_df.loc[row_index, "status"] = "Done" if score is not None else "Failed"
146
 
147
  # Prepare Results Row
148
  if score is not None:
@@ -151,14 +152,15 @@ def run_evaluation_loop():
151
  "mean_reward": score['rewards'],
152
  "run_time": score["time"],
153
  "status": "Success",
154
- "completed_at": time.time()
 
155
  }
156
 
157
  # Load Results Dataset
158
  try:
159
  results_df = pd.read_csv(f"hf://datasets/{RESULTS_DATASET}/results.csv")
160
  except:
161
- results_df = pd.DataFrame(columns=["model_id", "mean_reward", "run_time", "status", "completed_at"])
162
 
163
  # Append new result
164
  results_df = pd.concat([results_df, pd.DataFrame([new_result])], ignore_index=True)
 
55
  cfg = OmegaConf.load(hydra_config_file_path)
56
  cfg.dataset.load_dataset = "skip"
57
  cfg.testing = True
58
+ cfg.sim.task_set = "libero_spatial"
59
  ## load the GRP model from the file downloaded in the snapshot
60
  # Dynamically load the module
61
  import importlib.util, sys
 
143
 
144
  # 4. Update the Dataframes
145
  # Update Requests (Mark as Done or Failed)
146
+ # requests_df.loc[row_index, "status"] = "Done" if score is not None else "Failed"
147
 
148
  # Prepare Results Row
149
  if score is not None:
 
152
  "mean_reward": score['rewards'],
153
  "run_time": score["time"],
154
  "status": "Success",
155
+ "completed_at": time.time(),
156
+ "video_url": score.get("video_url", "") # Optional: if you upload videos to the Hub or elsewhere, include the URL here.
157
  }
158
 
159
  # Load Results Dataset
160
  try:
161
  results_df = pd.read_csv(f"hf://datasets/{RESULTS_DATASET}/results.csv")
162
  except:
163
+ results_df = pd.DataFrame(columns=["model_id", "mean_reward", "run_time", "status", "completed_at", "video_url"])
164
 
165
  # Append new result
166
  results_df = pd.concat([results_df, pd.DataFrame([new_result])], ignore_index=True)
requirements-app.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio==6.2.0
2
+ gradio_client==2.0.2
requirements.txt CHANGED
@@ -40,7 +40,9 @@ google-auth-oauthlib==1.2.2
40
  google-pasta==0.2.0
41
  greenlet==3.2.4
42
  grpcio==1.75.0
43
- gymnasium===0.28.1
 
 
44
  h5py==3.14.0
45
  hf-xet==1.1.10
46
  huggingface==0.0.1
@@ -90,6 +92,7 @@ Pympler==1.1
90
  pyparsing==3.2.4
91
  pyperclip==1.10.0
92
  python-box==7.3.2
 
93
  pytz==2025.2
94
  PyYAML==6.0.2
95
  regex==2025.9.18
@@ -134,3 +137,5 @@ Werkzeug==3.1.3
134
  wrapt==1.14.2
135
  xxhash==3.5.0
136
  yarl==1.20.1
 
 
 
40
  google-pasta==0.2.0
41
  greenlet==3.2.4
42
  grpcio==1.75.0
43
+ gym==0.25.2
44
+ gym-notices==0.1.0
45
+ gymnasium==1.0.0
46
  h5py==3.14.0
47
  hf-xet==1.1.10
48
  huggingface==0.0.1
 
92
  pyparsing==3.2.4
93
  pyperclip==1.10.0
94
  python-box==7.3.2
95
+ python-dotenv==1.2.1
96
  pytz==2025.2
97
  PyYAML==6.0.2
98
  regex==2025.9.18
 
137
  wrapt==1.14.2
138
  xxhash==3.5.0
139
  yarl==1.20.1
140
+ # git+https://github.com/montrealrobotics/LIBERO.git@master#egg=libero
141
+ # libero @ https://github.com/montrealrobotics/LIBERO.git
sim_eval.py CHANGED
@@ -108,6 +108,7 @@ def eval_model_in_sim(cfg, model, device, log_dir, env, env_unwrapped,
108
  path_ = os.path.join(log_dir, f"simple-env-{iter_}.mp4")
109
  import imageio
110
  imageio.mimsave(path_, frames, fps=20)
 
111
 
112
  if not cfg.testing:
113
  try:
@@ -167,8 +168,6 @@ def eval_libero(model, device, cfg, iter_=0, log_dir="./",
167
  from libero.libero.utils import get_libero_path
168
  from gymnasium.wrappers import FrameStackObservation
169
  from einops import rearrange
170
- from collections import deque
171
-
172
 
173
  benchmark_dict = benchmark.get_benchmark_dict()
174
  task_suite_name = cfg.sim.task_set # can also choose libero_spatial, libero_object, etc.
@@ -353,6 +352,7 @@ def eval_libero(model, device, cfg, iter_=0, log_dir="./",
353
  imageio.mimsave(path_, frames, fps=20)
354
  episode_stats = info.get('episode_stats', {})
355
  episode_stats['rewards'] = np.mean(rewards)
 
356
  print(f"avg reward {np.mean(rewards):.8f}")
357
  if not cfg.testing:
358
  wandb.log({"avg reward_"+str(task_id): np.mean(rewards)})
 
108
  path_ = os.path.join(log_dir, f"simple-env-{iter_}.mp4")
109
  import imageio
110
  imageio.mimsave(path_, frames, fps=20)
111
+ episode_stats['video_url'] = path_
112
 
113
  if not cfg.testing:
114
  try:
 
168
  from libero.libero.utils import get_libero_path
169
  from gymnasium.wrappers import FrameStackObservation
170
  from einops import rearrange
 
 
171
 
172
  benchmark_dict = benchmark.get_benchmark_dict()
173
  task_suite_name = cfg.sim.task_set # can also choose libero_spatial, libero_object, etc.
 
352
  imageio.mimsave(path_, frames, fps=20)
353
  episode_stats = info.get('episode_stats', {})
354
  episode_stats['rewards'] = np.mean(rewards)
355
+ episode_stats['video_url'] = path_
356
  print(f"avg reward {np.mean(rewards):.8f}")
357
  if not cfg.testing:
358
  wandb.log({"avg reward_"+str(task_id): np.mean(rewards)})