-
Notifications
You must be signed in to change notification settings - Fork 3.5k
add settings to make training results deterministic #5449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
8fbf294
b83b7ee
2491117
bef85ea
980591d
5beb625
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,171 @@ | ||
| ## | ||
| # Adapted from: https://github.com/NVIDIA-Omniverse/OmniIsaacGymEnvs/blob/main/apps/omni.isaac.sim.python.gym.camera.kit | ||
| # | ||
| # This app file designed specifically towards vision-based RL tasks. It provides necessary settings to enable | ||
| # multiple cameras to be rendered each frame. Additional settings are also applied to increase performance when | ||
| # rendering cameras across multiple environments. | ||
| ## | ||
|
|
||
| [package] | ||
| title = "Isaac Lab Python Headless Deterministic Rendering" | ||
| description = "An app for running Isaac Lab headlessly with rendering enabled and deterministic settings" | ||
| version = "3.0.0" | ||
|
|
||
| # That makes it browsable in UI with "experience" filter | ||
| keywords = ["experience", "app", "isaaclab", "python", "camera", "minimal"] | ||
|
|
||
| [dependencies] | ||
| # Isaac Lab minimal app | ||
| "isaaclab.python.headless" = {} | ||
| "omni.replicator.core" = {} | ||
|
|
||
| # Rendering | ||
| "omni.kit.material.library" = {} | ||
| "omni.kit.viewport.rtx" = {} | ||
| "omni.kit.hydra_texture" = {} # required for headless rendering and rtx instantiation | ||
|
|
||
|
|
||
| [settings.isaaclab] | ||
| # This is used to check that this experience file is loaded when using cameras | ||
| cameras_enabled = true | ||
|
|
||
| [settings] | ||
| # Note: This path was adapted to be respective to the kit-exe file location | ||
| app.versionFile = "${exe-path}/VERSION" | ||
| app.folder = "${exe-path}/" | ||
| app.name = "IsaacLab" | ||
| app.version = "3.0.0" | ||
|
|
||
| ### FSD | ||
| app.useFabricSceneDelegate = true | ||
| # Temporary, should be enabled by default in Kit soon | ||
| rtx.hydra.readTransformsFromFabricInRenderDelegate = true | ||
|
|
||
| # Disable print outs on extension startup information | ||
| # this only disables the app print_and_log function | ||
| app.enableStdoutOutput = false | ||
|
|
||
| # set the default ros bridge to disable on startup | ||
| isaac.startup.ros_bridge_extension = "" | ||
|
|
||
| # Flags for better rendering performance | ||
| # Disabling these settings reduces renderer VRAM usage and improves rendering performance, but at some quality cost | ||
| rtx.translucency.enabled = false | ||
| rtx.reflections.enabled = false | ||
| rtx.indirectDiffuse.enabled = false | ||
| rtx-transient.dlssg.enabled = false | ||
| rtx.directLighting.sampledLighting.enabled = true | ||
| rtx.directLighting.sampledLighting.samplesPerPixel = 1 | ||
| rtx.sceneDb.ambientLightIntensity = 1.0 | ||
| # rtx.shadows.enabled = false | ||
|
|
||
| # Avoids replicator warning | ||
| rtx.pathtracing.maxSamplesPerLaunch = 1000000 | ||
| # Avoids silent trimming of tiles | ||
| rtx.viewTile.limit = 1000000 | ||
|
|
||
| # Disable present thread to improve performance | ||
| exts."omni.renderer.core".present.enabled=false | ||
|
|
||
| # Disabling these settings reduces renderer VRAM usage and improves rendering performance, but at some quality cost | ||
| rtx.raytracing.cached.enabled = false | ||
| rtx.ambientOcclusion.enabled = false | ||
|
|
||
| # Set the DLSS model | ||
| rtx.post.dlss.execMode = 0 # can be 0 (Performance), 1 (Balanced), 2 (Quality), or 3 (Auto) | ||
|
|
||
| # Avoids unnecessary GPU context initialization | ||
| renderer.multiGpu.maxGpuCount=1 | ||
|
|
||
| # Force synchronous rendering to improve training results | ||
| omni.replicator.asyncRendering = false | ||
|
|
||
| # Avoids frame offset issue | ||
| app.updateOrder.checkForHydraRenderComplete = 1000 | ||
| app.renderer.waitIdle=true | ||
| app.hydraEngine.waitIdle=true | ||
|
|
||
| # NuRec | ||
| omni.rtx.nre.compositing.rendererHints = 3 | ||
|
|
||
| # Forces serial processing for omni graph to avoid NCCL timeout hangs in distributed training | ||
| app.execution.debug.forceSerial = true | ||
|
|
||
| app.audio.enabled = false | ||
|
|
||
| # Enable Vulkan - avoids torch+cu12 error on windows | ||
| app.vulkan = true | ||
|
|
||
| # Set profiler backend to NVTX by default | ||
| app.profilerBackend = "nvtx" | ||
|
|
||
| # Disables rate limit in runloop | ||
| app.runLoops.main.rateLimitEnabled=false | ||
|
|
||
| # disable replicator orchestrator for better runtime perf | ||
| exts."omni.replicator.core".Orchestrator.enabled = false | ||
|
|
||
| # disable the metrics assembler change listener, we don't want to do any runtime changes | ||
| metricsAssembler.changeListenerEnabled = false | ||
|
|
||
| # explicitly disable omni.kit.pip_archive to prevent conflicting dependencies | ||
| app.extensions.excluded = ["omni.kit.pip_archive", "omni.isaac.ml_archive", "isaacsim.pip.newton", "omni.warp.core"] | ||
|
|
||
| [settings.app.python] | ||
| # These disable the kit app from also printing out python output, which gets confusing | ||
| interceptSysStdOutput = false | ||
| logSysStdOutput = false | ||
|
|
||
| [settings.app.renderer] | ||
| skipWhileMinimized = false | ||
| sleepMsOnFocus = 0 | ||
| sleepMsOutOfFocus = 0 | ||
|
|
||
| [settings.physics] | ||
| updateToUsd = false | ||
| updateParticlesToUsd = false | ||
| updateVelocitiesToUsd = false | ||
| updateForceSensorsToUsd = false | ||
| outputVelocitiesLocalSpace = false | ||
| useFastCache = false | ||
| visualizationDisplayJoints = false | ||
| fabricUpdateTransformations = false | ||
| fabricUpdateVelocities = false | ||
| fabricUpdateForceSensors = false | ||
| fabricUpdateJointStates = false | ||
| ### When Direct GPU mode is enabled (suppressReadback=true) use direct interop between PhysX GPU and Fabric | ||
| fabricUseGPUInterop = true | ||
|
|
||
| # Register extension folder from this repo in kit | ||
| [settings.app.exts] | ||
| folders = [ | ||
| "${exe-path}/exts", # kit extensions | ||
| "${exe-path}/extscore", # kit core extensions | ||
| "${exe-path}/../exts", # isaac extensions | ||
| "${exe-path}/../extscache", # isaac cache extensions | ||
| "${exe-path}/../extsPhysics", # isaac physics extensions | ||
| "${exe-path}/../isaacsim/exts", # isaac extensions for pip | ||
| "${exe-path}/../isaacsim/extscache", # isaac cache extensions for pip | ||
| "${exe-path}/../isaacsim/extsPhysics", # isaac physics extensions for pip | ||
| "${app}", # needed to find other app files | ||
| "${app}/../source", # needed to find extensions in Isaac Lab | ||
| ] | ||
|
|
||
| [settings.persistent] | ||
| UJITSO.geometry = true | ||
| UJITSO.enabled = true | ||
|
|
||
| # Asset path | ||
| # set the S3 directory manually to the latest published S3 | ||
| # note: this is done to ensure prior versions of Isaac Sim still use the latest assets | ||
| [settings] | ||
| persistent.isaac.asset_root.default = "https://omniverse-content-staging.s3-us-west-2.amazonaws.com/Assets/Isaac/6.0" | ||
| persistent.isaac.asset_root.cloud = "https://omniverse-content-staging.s3-us-west-2.amazonaws.com/Assets/Isaac/6.0" | ||
| persistent.isaac.asset_root.nvidia = "https://omniverse-content-staging.s3-us-west-2.amazonaws.com/Assets/Isaac/6.0" | ||
|
|
||
| rtx.rendermode = "RealTimePathTracing" | ||
| # Determinism: disable RTPT caches so each run recomputes lighting from the same | ||
| # explicit inputs. Warm/cold cache history can otherwise change accumulation paths | ||
| # and produce frame-to-frame drift across repeated experiments. | ||
| rtx.rtpt.cached.enabled = false | ||
| rtx.rtpt.lightcache.cached.enabled = false | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,33 @@ simulation results are reproducible across different runs. The seed is set into | |
| parameters :attr:`isaaclab.envs.ManagerBasedEnvCfg.seed` or :attr:`isaaclab.envs.DirectRLEnvCfg.seed` | ||
| depending on the manager-based or direct environment implementation respectively. | ||
|
|
||
| .. note:: | ||
|
|
||
| **Strict PyTorch determinism is only wired into the RL-Games training script.** | ||
|
|
||
| The optional ``--deterministic`` flag (which calls :meth:`~isaaclab.utils.seed.configure_seed` with | ||
| ``torch_deterministic=True``, enabling ``torch.use_deterministic_algorithms(True)`` and related CUDNN | ||
| settings) exists only on ``scripts/reinforcement_learning/rl_games/train.py``. | ||
|
|
||
| The RSL-RL, Stable-Baselines3, SKRL, and RLinf training scripts under | ||
| ``scripts/reinforcement_learning/`` still honor ``--seed`` / agent configuration for the Isaac Lab | ||
| environment and learning stack, but they do **not** expose an equivalent opt-in for strict PyTorch-wide | ||
| deterministic algorithms. If you need that behavior with another framework, call | ||
| :meth:`~isaaclab.utils.seed.configure_seed` with ``torch_deterministic=True`` from your own training | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's the reason this can't be added to the other training scripts? |
||
| entry point, keeping in mind that some CUDA operations may error when no deterministic implementation | ||
| exists. | ||
|
|
||
| To enable deterministic rendering/app settings, launch workflows with the deterministic experience file: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| ./isaaclab.sh -p scripts/reinforcement_learning/rl_games/train.py \ | ||
| --task Isaac-Cartpole-v0 \ | ||
| --experience isaaclab.python.headless.determinism.kit | ||
|
|
||
| For RL-Games, combine this with ``--deterministic`` if you also want strict PyTorch deterministic | ||
| algorithms in addition to deterministic app/render settings. | ||
|
|
||
| For results on our determinacy testing for RL training, please check the GitHub Pull Request `#940`_. | ||
|
|
||
| .. tip:: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
| from isaaclab.utils.assets import retrieve_file_path | ||
| from isaaclab.utils.dict import print_dict | ||
| from isaaclab.utils.io import dump_yaml | ||
| from isaaclab.utils.seed import configure_seed | ||
|
|
||
| from isaaclab_rl.rl_games import MultiObserver, PbtAlgoObserver, RlGamesGpuEnv, RlGamesVecEnvWrapper | ||
|
|
||
|
|
@@ -48,6 +49,15 @@ | |
| "--agent", type=str, default="rl_games_cfg_entry_point", help="Name of the RL agent configuration entry point." | ||
| ) | ||
| parser.add_argument("--seed", type=int, default=None, help="Seed used for the environment") | ||
| parser.add_argument( | ||
| "--deterministic", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can this flag be added to AppLauncher instead so that we can switch to using the reproducible .kit file automatically? |
||
| action="store_true", | ||
| default=False, | ||
| help=( | ||
| "Enable strict PyTorch determinism (torch.use_deterministic_algorithms(True), cudnn deterministic, " | ||
| "etc.). Opt-in: some CUDA ops may error if no deterministic implementation exists." | ||
| ), | ||
| ) | ||
| parser.add_argument( | ||
| "--distributed", action="store_true", default=False, help="Run training with multiple GPUs or nodes." | ||
| ) | ||
|
|
@@ -203,6 +213,8 @@ def main(): | |
| else: | ||
| runner = Runner(IsaacAlgoObserver()) | ||
|
|
||
| configure_seed(env_cfg.seed, args_cli.deterministic) | ||
|
|
||
| runner.load(agent_cfg) | ||
| runner.reset() | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably better to depend on the headless rendering app? and then we can avoid the additional dependencies below