-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
694 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Profiling | ||
|
||
on: | ||
push: | ||
branches: | ||
- og-develop | ||
|
||
permissions: | ||
# deployments permission to deploy GitHub pages website | ||
deployments: write | ||
# contents permission to update profiling contents in gh-pages branch | ||
contents: write | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
profiling: | ||
name: Speed Profiling | ||
runs-on: [self-hosted, linux, gpu, dataset-enabled] | ||
|
||
defaults: | ||
run: | ||
shell: micromamba run -n omnigibson /bin/bash -leo pipefail {0} | ||
|
||
steps: | ||
- name: Fix home | ||
run: echo "HOME=/root" >> $GITHUB_ENV | ||
|
||
- name: Checkout source | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install dev requirements | ||
run: pip install -r requirements-dev.txt | ||
|
||
- name: Install | ||
run: pip install -e . | ||
|
||
- name: Run performance benchmark | ||
run: bash scripts/profiling.sh | ||
|
||
- name: Store benchmark result | ||
uses: benchmark-action/github-action-benchmark@v1 | ||
with: | ||
tool: 'customSmallerIsBetter' | ||
output-file-path: output.json | ||
benchmark-data-dir-path: profiling | ||
fail-on-alert: false | ||
alert-threshold: '200%' | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
comment-on-alert: true | ||
auto-push: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import gym | ||
import omnigibson as og | ||
import os | ||
import psutil | ||
from pynvml.smi import nvidia_smi | ||
from time import time | ||
|
||
|
||
class ProfilingEnv(og.Environment): | ||
def step(self, action): | ||
try: | ||
start = time() | ||
# If the action is not a dictionary, convert into a dictionary | ||
if not isinstance(action, dict) and not isinstance(action, gym.spaces.Dict): | ||
action_dict = dict() | ||
idx = 0 | ||
for robot in self.robots: | ||
action_dim = robot.action_dim | ||
action_dict[robot.name] = action[idx: idx + action_dim] | ||
idx += action_dim | ||
else: | ||
# Our inputted action is the action dictionary | ||
action_dict = action | ||
|
||
# Iterate over all robots and apply actions | ||
for robot in self.robots: | ||
robot.apply_action(action_dict[robot.name]) | ||
|
||
# Run simulation step | ||
sim_start = time() | ||
if len(og.sim._objects_to_initialize) > 0: | ||
og.sim.render() | ||
super(type(og.sim), og.sim).step(render=True) | ||
omni_time = (time() - sim_start) * 1e3 | ||
|
||
# Additionally run non physics things | ||
og.sim._non_physics_step() | ||
|
||
# Grab observations | ||
obs = self.get_obs() | ||
|
||
# Step the scene graph builder if necessary | ||
if self._scene_graph_builder is not None: | ||
self._scene_graph_builder.step(self.scene) | ||
|
||
# Grab reward, done, and info, and populate with internal info | ||
reward, done, info = self.task.step(self, action) | ||
self._populate_info(info) | ||
|
||
if done and self._automatic_reset: | ||
# Add lost observation to our information dict, and reset | ||
info["last_observation"] = obs | ||
obs = self.reset() | ||
|
||
# Increment step | ||
self._current_step += 1 | ||
|
||
# collect profiling data | ||
total_frame_time = (time() - start) * 1e3 | ||
og_time = total_frame_time - omni_time | ||
# memory usage in GB | ||
memory_usage = psutil.Process(os.getpid()).memory_info().rss / 1024 ** 3 | ||
# VRAM usage in GB | ||
for gpu in nvidia_smi.getInstance().DeviceQuery()['gpu']: | ||
found = False | ||
for process in gpu['processes']: | ||
if process['pid'] == os.getpid(): | ||
vram_usage = process['used_memory'] / 1024 | ||
found = True | ||
break | ||
if found: | ||
break | ||
|
||
ret = [total_frame_time, omni_time, og_time, memory_usage, vram_usage] | ||
if self._current_step % 100 == 0: | ||
print("total time: {:.3f} ms, Omni time: {:.3f} ms, OG time: {:.3f} ms, memory: {:.3f} GB, vram: {:.3f} GB.".format(*ret)) | ||
|
||
return obs, reward, done, info, ret | ||
except: | ||
raise ValueError(f"Failed to execute environment step {self._current_step} in episode {self._current_episode}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.