Skip to content

Commit

Permalink
Remove wandb dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
hang-yin committed Oct 2, 2024
1 parent d710cc4 commit 4258a92
Show file tree
Hide file tree
Showing 3 changed files with 4,587 additions and 3 deletions.
28 changes: 26 additions & 2 deletions omnigibson/utils/profiling_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,34 @@

import gymnasium as gym
import psutil
from wandb.sdk.internal.system.assets.gpu import gpu_in_use_by_this_process
from wandb.vendor.pynvml import pynvml

import omnigibson as og
import omnigibson.utils.pynvml_utils as pynvml


def gpu_in_use_by_this_process(gpu_handle: "GPUHandle", pid: int) -> bool:
if psutil is None:
return False

try:
base_process = psutil.Process(pid=pid)
except psutil.NoSuchProcess:
# do not report any gpu metrics if the base process cant be found
return False

our_processes = base_process.children(recursive=True)
our_processes.append(base_process)

our_pids = {process.pid for process in our_processes}

compute_pids = {process.pid for process in pynvml.nvmlDeviceGetComputeRunningProcesses(gpu_handle)} # type: ignore
graphics_pids = {
process.pid for process in pynvml.nvmlDeviceGetGraphicsRunningProcesses(gpu_handle) # type: ignore
}

pids_using_device = compute_pids | graphics_pids

return len(pids_using_device & our_pids) > 0


class ProfilingEnv(og.Environment):
Expand Down
Loading

0 comments on commit 4258a92

Please sign in to comment.