diff --git a/docs/getting_started/installation.md b/docs/getting_started/installation.md index 5452160f8..e5c233ff5 100644 --- a/docs/getting_started/installation.md +++ b/docs/getting_started/installation.md @@ -21,30 +21,45 @@ Please make sure your system meets the following specs: There are three ways to setup **`OmniGibson`**, all built upon different ways of installing NVIDIA Isaac Sim: -- **๐Ÿ Pip Install (Linux / Windows, Recommended)**: You can clone **`Omnigibson`** and automatically install Isaac Sim through pip for the fastest startup. +- **๐Ÿ Install with pip (Linux / Windows, Recommended)**: You can install **`Omnigibson`** and automatically install Isaac Sim through pip for the fastest startup. - **๐Ÿณ Install with Docker (Linux only)**: You can quickly get **`OmniGibson`** immediately up and running from our pre-built docker image that includes Isaac Sim. - **๐Ÿงช Install with Omniverse Launcher (Linux / Windows)**: You can install Isaac Sim via the Omniverse launcher and hook **`OmniGibson`** up to it. !!! tip "" - === "๐Ÿ Pip Install (Linux / Windows)" + === "๐Ÿ Install with pip (Linux / Windows)"
- 1. Create a conda environment with Python version **`3.10`**: + 1. Create a conda environment with Python version **`3.10`** and numpy and PyTorch: ```shell - conda create -n omnigibson python=3.10 + conda create -n omnigibson python=3.10 pytorch torchvision torchaudio pytorch-cuda=12.1 "numpy<2" -c pytorch -c nvidia conda activate omnigibson ``` - 2. Install OmniGibson with the optional Isaac Sim dependency: + ??? question "What should I do if `conda create` fails?" + + Sometimes, conda will fail to resolve dependencies. In that case, you can create a Python-only conda environment + first, and then install numpy<2 and PyTorch via pip. + + If the default PyTorch version does not work for you due to a CUDA version compatibility issue, follow instructions + on [the PyTorch website](https://pytorch.org/get-started/locally/) to add the correct index option to the pip install + line to get a different pytorch version. + + ```shell + conda create -n omnigibson python=3.10 + conda activate omnigibson + pip install "numpy<2" torch torchvision torchaudio + ``` + + 2. Install OmniGibson:
!!! note "Install from PyPI (source not editable)" ```shell - pip install --no-cache-dir omnigibson[isaac] + pip install omnigibson ``` !!! example "Install from GitHub (source editable)" @@ -52,38 +67,24 @@ There are three ways to setup **`OmniGibson`**, all built upon different ways of ```shell git clone https://github.com/StanfordVL/OmniGibson.git cd OmniGibson - pip install --no-cache-dir -e .[isaac] + pip install -e . ```
- If this step fails, we recommend trying the [source installation](#-install-from-source-linux--windows) method. - - 4. Run Isaac Sim to accept the EULA: + !!! note "Nightly build" - ```shell - isaacsim - ``` + The main branch contains the stable version of **`OmniGibson`**. For our latest developed (yet not fully tested) features and bug fixes, please clone from the `og-develop` branch. - !!! important "EULA Acceptance" - It is necessary to accept the Omniverse License Agreement (EULA) in order to use Isaac Sim. - The first time `isaacsim` is imported, you will be prompted to accept the EULA: + 3. Run the installation script to install Isaac Sim as well as **`OmniGibson`** dataset and assets: - ``` - By installing or using Omniverse Kit, I agree to the terms of NVIDIA OMNIVERSE LICENSE AGREEMENT (EULA) - in https://docs.omniverse.nvidia.com/platform/latest/common/NVIDIA_Omniverse_License_Agreement.html - Do you accept the EULA? (Yes/No) - ``` - - You must respond with 'Yes' to proceed. Once the EULA is accepted, it should not appear on subsequent Isaac Sim calls. If the EULA is not accepted, the execution will be terminated. + ```{.shell .annotate} + python -m omnigibson.install # (1)! + ``` - **You might get some error dialogs that are safe to ignore. After accepting the EULA, you can close Isaac Sim.** + 1. You can apply additional flag `--no-install-datasets` to skip dataset install. - 5. Download **`OmniGibson`** dataset and assets: - - ```shell - python -m omnigibson.download_datasets - ``` + If this step fails, we recommend considering the [source installation](#__tabbed_1_3) method.
@@ -146,87 +147,87 @@ There are three ways to setup **`OmniGibson`**, all built upon different ways of Docker containers are unable to access NFS or AFS drives, so if `run_docker.sh` are located on an NFS / AFS partition, please set `` to an alternative data directory located on a non-NFS / AFS partition. - === "๐Ÿงช Install from source (Linux / Windows)" + === "๐Ÿงช Install with Omniverse Launcher (Linux / Windows)" - Install **`OmniGibson`** from source is supported for both **๐Ÿง Linux (bash)** and **๐Ÿ“ Windows (powershell/cmd)**. - !!! example "" - === "๐Ÿง Linux (bash)" + Install **`OmniGibson`** with Omniverse Launcher is supported for both **๐Ÿง Linux (bash)** and **๐Ÿ“ Windows (powershell/cmd)**. -
- - 1. Install [Conda](https://conda.io/projects/conda/en/latest/user-guide/install/index.html) and NVIDIA's [Omniverse Isaac Sim](https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/install_workstation.html) - - !!! warning "Please make sure you have the latest version of Isaac Sim (2023.1.1) installed." +
- For Ubuntu 22.04, you need to [install FUSE](https://github.com/AppImage/AppImageKit/wiki/FUSE) to run the Omniverse Launcher AppImage. + 1. Install [Conda](https://conda.io/projects/conda/en/latest/user-guide/install/index.html) and NVIDIA's [Omniverse Isaac Sim](https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/install_workstation.html) - 2. Clone [**`OmniGibson`**](https://github.com/StanfordVL/OmniGibson) and move into the directory: + !!! warning "Please make sure you have the currently supported version of Isaac Sim (4.1.0) installed." - ```shell - git clone https://github.com/StanfordVL/OmniGibson.git - cd OmniGibson - ``` - - ??? note "Nightly build" + For Ubuntu 22.04, you need to [install FUSE](https://github.com/AppImage/AppImageKit/wiki/FUSE) to run the Omniverse Launcher AppImage. - The main branch contains the stable version of **`OmniGibson`**. For our latest developed (yet not fully tested) features and bug fixes, please clone from the `og-develop` branch. + 2. Create a conda environment with Python version **`3.10`**: - 3. Setup a virtual conda environment to run **`OmniGibson`**: + ```shell + conda create -n omnigibson python=3.10 pytorch torchvision torchaudio pytorch-cuda=12.1 "numpy<2" -c pytorch -c nvidia + conda activate omnigibson + ``` - ```{.shell .annotate} - ./scripts/setup.sh # (1)! - ``` + ??? question "What should I do if `conda create` fails?" - 1. The script will ask you which Isaac Sim to use. If you installed it in the default location, it should be `~/.local/share/ov/pkg/isaac_sim-2023.1.1` + Sometimes, conda will fail to resolve dependencies. In that case, you can create a Python-only conda environment + first, and then install numpy<2 and PyTorch via pip. + + If the default PyTorch version does not work for you due to a CUDA version compatibility issue, follow instructions + on [the PyTorch website](https://pytorch.org/get-started/locally/) to add the correct index option to the pip install + line to get a different pytorch version. - This will create a conda env with `omnigibson` installed. Simply call `conda activate` to activate it. + ```shell + conda create -n omnigibson python=3.10 + conda activate omnigibson + pip install "numpy<2" torch torchvision torchaudio + ``` - 4. Download **`OmniGibson`** dataset (within the conda env): + 3. Install OmniGibson: - ```shell - python -m omnigibson.download_datasets - ``` +
-
+ !!! note "Install from PyPI (source not editable)" - + ```shell + pip install omnigibson + ``` - === "๐Ÿ“ Windows (powershell/cmd)" + !!! example "Install from GitHub (source editable)" -
+ ```shell + git clone https://github.com/StanfordVL/OmniGibson.git + cd OmniGibson + pip install -e . + ``` - 1. Install [Conda](https://conda.io/projects/conda/en/latest/user-guide/install/index.html) and NVIDIA's [Omniverse Isaac Sim](https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/install_workstation.html) +
- !!! warning "Please make sure you have the latest version of Isaac Sim (2023.1.1) installed." + !!! note "Nightly build" - 2. Clone [**`OmniGibson`**](https://github.com/StanfordVL/OmniGibson) and move into the directory: + The main branch contains the stable version of **`OmniGibson`**. For our latest developed (yet not fully tested) features and bug fixes, please clone from the `og-develop` branch. - ```shell - git clone https://github.com/StanfordVL/OmniGibson.git - cd OmniGibson - ``` + 4. Run the installation script to hook the environment up to Isaac Sim as well as **`OmniGibson`** dataset and assets: - ??? note "Nightly build" + ```{.shell .annotate} + python -m omnigibson.install --launcher-install # (1)! + ``` - The main branch contains the stable version of **`OmniGibson`**. For our latest developed (yet not fully tested) features and bug fixes, please clone from the `og-develop` branch. + 1. You can specify your Isaac Sim install location using the argument `--isaac-sim-path` if it differs from the default. You can also apply additional flag `--no-install-datasets` to skip dataset install. - 3. Setup a virtual conda environment to run **`OmniGibson`**: + !!! note "What does this do?" - ```{.powershell .annotate} - .\scripts\setup.bat # (1)! - ``` + When you install OmniGibson this way, it will modify your conda environment setup to hook it up to the launcher-installed Isaac Sim. - 1. The script will ask you which Isaac Sim to use. If you installed it in the default location, it should be `C:\Users\\AppData\Local\ov\pkg\isaac_sim-2023.1.1` + 5. Deactivate and reactivate the conda environment: - This will create a conda env with `omnigibson` installed. Simply call `conda activate` to activate it. + Because the environment was modified by the installer to hook it up to the launcher-installed Isaac Sim, you need to reactivate it. - 4. Download **`OmniGibson`** dataset (within the conda env): + ```shell + conda deactivate + conda activate omnigibson + ``` - ```powershell - python -m omnigibson.download_datasets - ``` +
-
## ๐ŸŒŽ **Explore `OmniGibson`!** @@ -237,21 +238,24 @@ There are three ways to setup **`OmniGibson`**, all built upon different ways of The process could take up to 5 minutes. This is expected behavior, and should only occur once! -**`OmniGibson`** is now successfully installed! Try exploring some of our new scenes interactively: +**`OmniGibson`** is now successfully installed! You can try teleoperating one of our robots: ```{.shell .annotate} -python -m omnigibson.examples.scenes.scene_selector # (1)! +python -m omnigibson.examples.robots.robot_control_example --quickstart # (1)! ``` -1. This demo lets you choose a scene and interactively move around using your keyboard and mouse. Hold down **`Shift`** and then **`Left-click + Drag`** an object to apply forces! +1. This demo lets you choose a scene, robot, and set of controllers, and then teleoperate the robot using your keyboard. + The `--quickstart` flag will automatically select the scene and robot for you - remove that if you want to change + the scene or robot. + -You can also try teleoperating one of our robots: +You can also try exploring some of our new scenes interactively: ```{.shell .annotate} -python -m omnigibson.examples.robots.robot_control_example # (1)! +python -m omnigibson.examples.scenes.scene_selector # (1)! ``` -1. This demo lets you choose a scene, robot, and set of controllers, and then teleoperate the robot using your keyboard. +1. This demo lets you choose a scene and interactively move around using your keyboard and mouse. Hold down **`Shift`** and then **`Left-click + Drag`** an object to apply forces! *** @@ -266,4 +270,23 @@ python -m omnigibson.examples.robots.robot_control_example # (1)! ??? question "OmniGibson is stuck at `HydraEngine rtx failed creating scene renderer.`" - `OmniGibson` is likely using an unsupported GPU (default is id 0). Run `nvidia-smi` to see the active list of GPUs, and select an NVIDIA-supported GPU and set its corresponding ID when running `OmniGibson` with `export OMNIGIBSON_GPU_ID=`. \ No newline at end of file + `OmniGibson` is likely using an unsupported GPU (default is id 0). Run `nvidia-smi` to see the active list of GPUs, and select an NVIDIA-supported GPU and set its corresponding ID when running `OmniGibson` with `export OMNIGIBSON_GPU_ID=`. + +??? question "I'm getting the error `AttributeError: module 'x509' has no attribute 'Store'`" + + This happens because launcher-based versions of Isaac Sim ship with a faulty copy of the `cryptography` module. You can simply look at the stack trace for the path of your copy of + the cryptography module, e.g. if it shows an error that looks like this: + + ``` + File "c:/users/cem/appdata/local/ov/pkg/isaac-sim-4.1.0/exts/omni.pip.cloud/pip_prebundle/cryptography/hazmat/backends/openssl/__init__.py", line 7, in + from cryptography.hazmat.backends.openssl.backend import backend + File "c:/users/cem/appdata/local/ov/pkg/isaac-sim-4.1.0/exts/omni.pip.cloud/pip_prebundle/cryptography/hazmat/backends/openssl/backend.py", line 12, in + from cryptography import utils, x509 + File "c:/users/cem/appdata/local/ov/pkg/isaac-sim-4.1.0/exts/omni.pip.cloud/pip_prebundle/cryptography/x509/__init__.py", line 7, in + from cryptography.x509 import certificate_transparency, verification + File "c:/users/cem/appdata/local/ov/pkg/isaac-sim-4.1.0/exts/omni.pip.cloud/pip_prebundle/cryptography/x509/verification.py", line 20, in + Store = rust_x509.Store + AttributeError: module 'x509' has no attribute 'Store' + ``` + + You can simply remove the `c:/users/cem/appdata/local/ov/pkg/isaac-sim-4.1.0/exts/omni.pip.cloud/pip_prebundle/cryptography` directory and this issue should be resolved. \ No newline at end of file diff --git a/omnigibson/download_datasets.py b/omnigibson/download_datasets.py index 1e4d73df9..f850e50e7 100644 --- a/omnigibson/download_datasets.py +++ b/omnigibson/download_datasets.py @@ -23,7 +23,7 @@ def main(): print( f"If you want to install data under a different path, please change the DATA_PATH variable in omnigibson/macros.py and rerun omnigibson/download_datasets.py." ) - if click.confirm("Do you want to continue?"): + if click.confirm("Do you want to continue?", default=True): # Only download if the dataset path doesn't exist if not dataset_exists: print("Downloading dataset...") diff --git a/omnigibson/install.py b/omnigibson/install.py new file mode 100644 index 000000000..47da07619 --- /dev/null +++ b/omnigibson/install.py @@ -0,0 +1,396 @@ +import os +import platform +import shutil +import subprocess +import sys +import tempfile +import urllib.request +from importlib.util import find_spec +from pathlib import Path +from typing import List, Optional + +import click +import tqdm + +# List of NVIDIA PyPI packages needed for OmniGibson +ISAAC_SIM_PACKAGES = [ + "omniverse_kit-106.0.1.126909", + "isaacsim_kernel-4.1.0.0", + "isaacsim_app-4.1.0.0", + "isaacsim_core-4.1.0.0", + "isaacsim_gui-4.1.0.0", + "isaacsim_utils-4.1.0.0", + "isaacsim_storage-4.1.0.0", + "isaacsim_asset-4.1.0.0", + "isaacsim_sensor-4.1.0.0", + "isaacsim_robot_motion-4.1.0.0", + "isaacsim_robot-4.1.0.0", + "isaacsim_benchmark-4.1.0.0", + "isaacsim_code_editor-4.1.0.0", + "isaacsim_ros1-4.1.0.0", + "isaacsim_cortex-4.1.0.0", + "isaacsim_example-4.1.0.0", + "isaacsim_replicator-4.1.0.0", + "isaacsim_rl-4.1.0.0", + "isaacsim_robot_setup-4.1.0.0", + "isaacsim_ros2-4.1.0.0", + "isaacsim_template-4.1.0.0", + "isaacsim_test-4.1.0.0", + "isaacsim-4.1.0.0", + "isaacsim_extscache_physics-4.1.0.0", + "isaacsim_extscache_kit-4.1.0.0", + "isaacsim_extscache_kit_sdk-4.1.0.0", +] +BASE_URL = "https://pypi.nvidia.com" + + +def _find_isaac_sim_path(): + """Try to find the path of a launcher-based Isaac Sim installation.""" + if platform.system() == "Windows": + base_path = Path.home() / "AppData" / "Local" / "ov" / "pkg" + else: + base_path = Path.home() / ".local" / "share" / "ov" / "pkg" + + # If the pkg dir is missing, we definitely can't find an Isaac Sim installation + if not base_path.exists(): + return None + + isaac_dirs = list(base_path.glob("isaac*")) + if not isaac_dirs: + return None + + return isaac_dirs[-1] + + +def _get_filename(package: str, temp_dir: Path): + if platform.system() == "Windows": + return temp_dir / f"{package}-cp310-none-win_amd64.whl" + return temp_dir / f"{package}-cp310-none-manylinux_2_34_x86_64.whl" + + +def _download_package(url: str, filename: Path): + try: + urllib.request.urlretrieve(url, filename) + except Exception as e: + raise ValueError(f"Failed to download {url}") from e + + +def _rename_if_necessary(filename: Path): + """ + Rename the file if the system's GLIBC version is older than the one used in the NVIDIA PyPI packages. + + This is permissible because the manylinux wheels are compatible with older GLIBC versions even though + the filename suggests not - so we apply this hacky workaround. This allows pip to try to install them. + """ + if platform.system() == "Linux" and _is_glibc_older(): + return filename.with_name(filename.name.replace("manylinux_2_34", "manylinux_2_31")) + return filename + + +def _is_glibc_older(): + """Check if the system's GLIBC version is older than the one used in the NVIDIA PyPI packages.""" + try: + dist_info = subprocess.check_output(["ldd", "--version"]).decode("utf-8") + if any(version in dist_info for version in ["2.31", "2.32", "2.33"]): + return True + elif any(version in dist_info for version in ["2.34", "2.35", "2.36", "2.37", "2.38", "2.39"]): + return False + else: + raise ValueError("Incompatible GLIBC version") + except subprocess.CalledProcessError: + raise ValueError("Failed to check GLIBC version. `ldd` was not accessible. Try running it yourself to see why.") + + +def _pip_install(filenames: List[Path]): + """Install a package using pip.""" + try: + subprocess.run(["pip", "install"] + [str(x) for x in filenames], check=True) + except subprocess.CalledProcessError: + return False + + return True + + +def _download_isaac_sim_package(package: str, temp_dir: Path): + package_name = package.split("-")[0].replace("_", "-") + filename = _get_filename(package, temp_dir) + url = f"{BASE_URL}/{package_name}/{filename.name}" + + try: + _download_package(url, filename) + except Exception as e: + click.echo(f"Failed to download {package}: {str(e)}") + raise + + return _rename_if_necessary(filename) + + +def _setup_windows_conda_env(isaac_sim_path: Path, conda_prefix: Path): + # Create directories + for dir_name in ["activate.d", "deactivate.d"]: + os.makedirs(conda_prefix / "etc" / "conda" / dir_name, exist_ok=True) + + # Create empty files + for file_name in ["env_vars.bat", "env_vars.ps1"]: + for dir_name in ["activate.d", "deactivate.d"]: + (conda_prefix / "etc" / "conda" / dir_name / file_name).touch() + + # Setup CMD activation script + cmd_act_file = conda_prefix / "etc" / "conda" / "activate.d" / "env_vars.bat" + with cmd_act_file.open("w") as f: + f.write("@echo off\n") + f.write("set PYTHONPATH_OLD=%PYTHONPATH%\n") + f.write(f"set PYTHONPATH=%PYTHONPATH%;{isaac_sim_path}\\site\n") + f.write(f"set CARB_APP_PATH={isaac_sim_path}\\kit\n") + f.write(f"set EXP_PATH={isaac_sim_path}\\apps\n") + f.write(f"set ISAAC_PATH={isaac_sim_path}\n") + + # Setup CMD deactivation script + cmd_deact_file = conda_prefix / "etc" / "conda" / "deactivate.d" / "env_vars.bat" + with cmd_deact_file.open("w") as f: + f.write("@echo off\n") + f.write("set PYTHONPATH=%PYTHONPATH_OLD%\n") + f.write('set PYTHONPATH_OLD=""\n') + + # Setup PowerShell activation script + ps_act_file = conda_prefix / "etc" / "conda" / "activate.d" / "env_vars.ps1" + with ps_act_file.open("w") as f: + f.write('$env:PYTHONPATH_OLD="$env:PYTHONPATH"\n') + f.write(f'$env:PYTHONPATH="$env:PYTHONPATH;{isaac_sim_path}\\site"\n') + f.write(f'$env:CARB_APP_PATH="{isaac_sim_path}\\kit"\n') + f.write(f'$env:EXP_PATH="{isaac_sim_path}\\apps"\n') + f.write(f'$env:ISAAC_PATH="{isaac_sim_path}"\n') + + # Setup PowerShell deactivation script + ps_deact_file = conda_prefix / "etc" / "conda" / "deactivate.d" / "env_vars.ps1" + with ps_deact_file.open("w") as f: + f.write('$env:PYTHONPATH="$env:PYTHONPATH_OLD"\n') + f.write('$env:PYTHONPATH_OLD="$null"\n') + + +def _setup_unix_conda_env(isaac_sim_path: Path, conda_prefix: Path): + # Set up conda environment files + for dir_name in ["activate.d", "deactivate.d"]: + os.makedirs(conda_prefix / "etc" / "conda" / dir_name, exist_ok=True) + + # Create activation script + with open(conda_prefix / "etc" / "conda" / "activate.d" / "env_vars.sh", "w") as f: + f.write("#!/bin/sh\n") + f.write("export LD_LIBRARY_PATH_OLD=$LD_LIBRARY_PATH\n") + f.write("export PYTHONPATH_OLD=$PYTHONPATH\n") + f.write(f"source {isaac_sim_path}/setup_conda_env.sh\n") + + # Create deactivation script + with open(conda_prefix / "etc" / "conda" / "deactivate.d" / "env_vars.sh", "w") as f: + f.write("#!/bin/sh\n") + f.write("export LD_LIBRARY_PATH=$LD_LIBRARY_PATH_OLD\n") + f.write("export PYTHONPATH=$PYTHONPATH_OLD\n") + f.write("unset ISAAC_PATH\n") + f.write("unset CARB_APP_PATH\n") + f.write("unset LD_LIBRARY_PATH_OLD\n") + f.write("unset PYTHONPATH_OLD\n") + + +def _launcher_based_install(isaac_sim_path: Optional[Path]): + # If we are using a launcher-based installation, we need to find the path to the Isaac Sim installation + if isaac_sim_path is None: + isaac_sim_path = _find_isaac_sim_path() + + # If it's not at the provided or default path, remove it + if isaac_sim_path is None or not list(Path(isaac_sim_path).glob("isaac*.*")): + return False + + # Check the version string + version_file_path = isaac_sim_path / "VERSION" + if not version_file_path.exists(): + click.echo(f"Isaac Sim version file not found at {version_file_path}") + return False + + with open(version_file_path, "r") as file: + version_content = file.read().strip() + isaac_version_str = version_content.split("-")[0] + isaac_version_tuple = tuple(map(int, isaac_version_str.split(".")[:3])) + + if isaac_version_tuple not in ((4, 0, 0), (4, 1, 0)): + click.echo(f"Isaac Sim version {isaac_version_str} is not supported by OmniGibson.") + return False + + # Update conda environment files to point to the specified Isaac Sim installation + conda_prefix = Path(os.environ["CONDA_PREFIX"]) + if platform.system() == "Windows": + _setup_windows_conda_env(isaac_sim_path, conda_prefix) + else: + _setup_unix_conda_env(isaac_sim_path, conda_prefix) + + # Temporarily apply the env vars to this script, too + sys.path.append(str(isaac_sim_path / "site")) + os.environ["CARB_APP_PATH"] = str(isaac_sim_path / "kit") + os.environ["EXP_PATH"] = str(isaac_sim_path / "apps") + os.environ["ISAAC_PATH"] = str(isaac_sim_path) + + return True + + +def _pip_based_install(): + try: + # Create a temporary directory to download the packages + with tempfile.TemporaryDirectory() as temp_dir: + temp_dir_path = Path(temp_dir) + + # Download all required packages + package_filenames = [] + for package in tqdm.tqdm(ISAAC_SIM_PACKAGES, desc="Downloading Isaac Sim packages"): + package_filenames.append(_download_isaac_sim_package(package, temp_dir_path)) + + # Install the packages + click.echo("Installing Isaac Sim packages...") + if not _pip_install(package_filenames): + return False + + # Check that it can now be imported + os.environ["OMNI_KIT_ACCEPT_EULA"] = "YES" + import isaacsim + except ImportError: + return False + + return True + + +def attempt_launcher_install(isaac_sim_path: Optional[Path]): + click.echo("Checking for an existing launcher-based Isaac Sim installation...") + success = _launcher_based_install(isaac_sim_path) + if success: + click.echo("Successfully found and attached to launcher-based Isaac Sim installation.") + else: + click.echo("We did not find a compatible Isaac Sim installed via the launcher.") + return success + + +def attempt_pip_install(): + click.echo("Installing Isaac Sim via pip.") + success = _pip_based_install() + if success: + click.echo("Successfully installed Isaac Sim via pip.") + else: + click.echo("Something went wrong during the pip installation.") + return success + + +@click.command() +@click.option( + "--install-datasets", default=True, help="Install the OmniGibson dataset and assets after installing Isaac Sim" +) +@click.option( + "--launcher-install/--pip-install", + default=False, + help="Hook up to a launcher-installed Isaac Sim installation instead of installing via pip", +) +@click.option( + "--isaac-sim-path", + type=click.Path(exists=True, dir_okay=True, file_okay=False, writable=True, readable=True, path_type=Path), + default=None, + help="Path to the existing launcher-based Isaac Sim installation directory, to force the setup script to use it", +) +def setup_omnigibson(install_datasets: bool, launcher_install: bool, isaac_sim_path: Optional[Path]): + # Check that we are in a conda environment + if "CONDA_PREFIX" not in os.environ: + click.echo("Please run this script from within a conda environment.") + click.echo("You can create one by running `conda create -n omnigibson python=3.10`.") + return + + # Check that the current interpreter is Python 3.10 + if sys.version_info[:2] != (3, 10): + click.echo("Please run this script with Python 3.10.") + return + + # Check that we do not have an EXP_PATH, CARB_APP_PATH or ISAAC_PATH set + if any(env_var in os.environ for env_var in ["EXP_PATH", "CARB_APP_PATH", "ISAAC_PATH"]): + click.echo( + "Please unset the EXP_PATH, CARB_APP_PATH and ISAAC_PATH environment variables before running this script." + ) + click.echo("These can stem from a dirty environment from an existing Isaac Sim installation.") + click.echo("We recommend starting a new conda environment and running this script there.") + click.echo("You can do this by running `conda create -n omnigibson python=3.10`.") + return + + # Check if the isaacsim package is already installed + try: + os.environ["OMNI_KIT_ACCEPT_EULA"] = "YES" + import isaacsim + + click.echo("Isaac Sim is already installed via pip in your current env.") + click.echo("If you need to download the datasets, please run omnigibson/download_datasets.py.") + return + except ImportError: + pass + + # Do the actual work + if launcher_install: + if not attempt_launcher_install(isaac_sim_path): + click.echo("Failed to hook environment up to launcher-based Isaac Sim installation.") + click.echo("Please make sure you have installed Isaac Sim correctly before running this setup script.") + return + else: + if not attempt_pip_install(): + click.echo("Failed to install Isaac Sim. Please check the installation requirements and try again.") + return + + # Try to resolve the bug that occurs when `cryptography` is imported from Isaac Sim. + # This is a known issue on Windows and the workaround is removing the copy of cryptography + # shipped with Isaac Sim, usually included in the omni.kit.cloud package. + cryptography_path = Path(os.environ["ISAAC_PATH"]) / "exts/omni.pip.cloud/pip_prebundle/cryptography" + if cryptography_path.exists(): + shutil.rmtree(str(cryptography_path)) + + click.echo("Isaac Sim has been successfully installed.") + + # Now prompt the user to install the dataset and assets + if install_datasets: + click.echo("We will now install the datasets.") + + # We import these now to avoid OmniGibson imports before torch is installed etc. + from omnigibson.macros import gm + from omnigibson.utils.asset_utils import download_assets, download_og_dataset + + # Only execute if the dataset path or asset path does not exist + dataset_exists, assets_exist = os.path.exists(gm.DATASET_PATH), os.path.exists(gm.ASSET_PATH) + if not (dataset_exists and assets_exist): + # Ask user which dataset to install + click.echo(f"OmniGibson will now install data under the following locations:") + click.echo(f" dataset (~25GB): {gm.DATASET_PATH}") + click.echo(f" assets (~2.5GB): {gm.ASSET_PATH}") + click.echo( + f"If you want to install data under a different path, please change the DATA_PATH variable in omnigibson/macros.py and " + f"rerun omnigibson/download_datasets.py." + ) + if click.confirm("Do you want to continue?", default=True): + # Only download if the dataset path doesn't exist + if not dataset_exists: + click.echo("Downloading dataset...") + download_og_dataset() + + # Only download if the asset path doesn't exist + if not assets_exist: + click.echo("Downloading assets...") + download_assets() + else: + click.echo( + "You chose not to install dataset for now. You can install it later by running python omnigibson/download_datasets.py." + ) + + click.echo( + "\nOmniGibson setup completed! You can now run your experiments. " + "Visit https://behavior.stanford.edu/omnigibson/getting_started/examples.html for some examples, " + "and https://behavior.stanford.edu/omnigibson-develop/getting_started/quickstart.html for a quickstart " + "guide for working with OmniGibson APIs." + ) + + # If this is a launcher install, we need to tell the user to deactivate and reactivate + if launcher_install: + click.echo( + "IMPORTANT: Please deactivate and reactivate your conda environment to ensure the Isaac Sim environment variables are set correctly." + ) + + +if __name__ == "__main__": + setup_omnigibson() diff --git a/omnigibson/robots/robot_base.py b/omnigibson/robots/robot_base.py index 30dd2535a..2feb288f6 100644 --- a/omnigibson/robots/robot_base.py +++ b/omnigibson/robots/robot_base.py @@ -1,7 +1,6 @@ from abc import abstractmethod from copy import deepcopy -import matplotlib.pyplot as plt import torch as th import omnigibson.utils.transform_utils as T @@ -416,6 +415,8 @@ def visualize_sensors(self): print(f"Modalities: {remaining_obs_modalities} cannot be visualized, skipping...") # Write all the frames to a plot + import matplotlib.pyplot as plt + for sensor_name, sensor_frames in frames.items(): n_sensor_frames = len(sensor_frames) if n_sensor_frames > 0: diff --git a/omnigibson/scene_graphs/graph_builder.py b/omnigibson/scene_graphs/graph_builder.py index 1f987748c..6f9879001 100644 --- a/omnigibson/scene_graphs/graph_builder.py +++ b/omnigibson/scene_graphs/graph_builder.py @@ -2,7 +2,6 @@ import networkx as nx import torch as th -from matplotlib import pyplot as plt from PIL import Image from omnigibson import object_states @@ -300,6 +299,8 @@ def _draw_graph(): figwidth = imgwidth / figdpi # Draw the graph onto the figure. + import matplotlib.pyplot as plt + fig = plt.figure(figsize=(figwidth, figheight), dpi=figdpi) _draw_graph() fig.canvas.draw() diff --git a/omnigibson/simulator.py b/omnigibson/simulator.py index d1d624e35..c45440844 100644 --- a/omnigibson/simulator.py +++ b/omnigibson/simulator.py @@ -110,6 +110,7 @@ def _launch_app(): # if we are using the pip installed version, all the ISAAC_PATH etc. env vars are set correctly. # On the regular omniverse launcher version this should not have any impact. try: + os.environ["OMNI_KIT_ACCEPT_EULA"] = "YES" import isaacsim # noqa: F401 except ImportError: isaacsim = None diff --git a/omnigibson/systems/macro_particle_system.py b/omnigibson/systems/macro_particle_system.py index 80f866807..a5cb8ef69 100644 --- a/omnigibson/systems/macro_particle_system.py +++ b/omnigibson/systems/macro_particle_system.py @@ -1,6 +1,4 @@ -import os - -import matplotlib.pyplot as plt +import cv2 import torch as th import trimesh @@ -212,7 +210,7 @@ def process_particle_object(self): else: diffuse_texture = self.particle_object.material.diffuse_texture color = ( - plt.imread(diffuse_texture).mean(dim=(0, 1)) + cv2.imread(diffuse_texture).mean() if diffuse_texture else self.particle_object.material.diffuse_color_constant ) diff --git a/scripts/setup.bat b/scripts/setup.bat deleted file mode 100644 index 651ce3887..000000000 --- a/scripts/setup.bat +++ /dev/null @@ -1,92 +0,0 @@ -@echo off -:: Make sure that the ISAAC_SIM_PATH variable is set correctly -dir /b /o:-n %userprofile%\AppData\Local\ov\pkg\isaac_sim* > NUL -if errorlevel 0 ( - for /f "tokens=* usebackq" %%f in (`dir /b /o:n %userprofile%\AppData\Local\ov\pkg\isaac_sim*`) do set ISAAC_SIM_PATH=%userprofile%\AppData\Local\ov\pkg\%%f - setlocal enabledelayedexpansion - echo We found Isaac Sim installed at !ISAAC_SIM_PATH!. OmniGibson will use it by default. - endlocal - set /p ISAAC_SIM_PATH=If you want to use a different one, please type in the path containing isaac-sim.bat here ^(press enter to skip^) ^>^>^> -) else ( - echo We did not find Isaac Sim under %userprofile%\AppData\Local\ov\pkg. - echo If you haven't installed Isaac Sim yet, please do so before running this setup script. - set /p ISAAC_SIM_PATH=If you have already installed it in a custom location, please type in the path containing isaac-sim.bat here ^>^>^> -) -:check_isaac_sim_path -if not exist %ISAAC_SIM_PATH%\isaac*.bat ( - set /p ISAAC_SIM_PATH=isaac*.bat not found in %ISAAC_SIM_PATH%! Make sure you have entered the correct path ^>^>^> - goto :check_isaac_sim_path -) -echo: -echo Using Isaac Sim at %ISAAC_SIM_PATH% -echo: - -:: Choose venv name -set conda_name=omnigibson -echo The new conda environment will be named omnigibson by default. -set /p conda_name=If you want to use a different name, please type in here ^(press enter to skip^) ^>^>^> -echo: -echo Using %conda_name% as the conda environment name -echo: - -:: Get Python version from Isaac Sim -FOR /F "tokens=*" %%g IN ('%ISAAC_SIM_PATH%\python.bat -c "import platform; print(platform.python_version())"') do (SET ISAAC_PYTHON_VERSION=%%g) -echo Using Python version %ISAAC_PYTHON_VERSION% matching your current Isaac Sim version - -:: Create a conda environment with the appropriate python version -call conda create -y -n %conda_name% python=%ISAAC_PYTHON_VERSION% || goto :error -call conda activate %conda_name% || goto :error - -:: We add some preprocessing information so that the Isaac Sim paths are linked to this environment upon startup -:: See https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#macos-and-linux for reference -mkdir %CONDA_PREFIX%\etc\conda\activate.d -mkdir %CONDA_PREFIX%\etc\conda\deactivate.d -type NUL>%CONDA_PREFIX%\etc\conda\activate.d\env_vars.bat -type NUL>%CONDA_PREFIX%\etc\conda\deactivate.d\env_vars.bat -type NUL>%CONDA_PREFIX%\etc\conda\activate.d\env_vars.ps1 -type NUL>%CONDA_PREFIX%\etc\conda\deactivate.d\env_vars.ps1 - -:: Add support for cmd -set CONDA_ACT_FILE_CMD=%CONDA_PREFIX%\etc\conda\activate.d\env_vars.bat -echo @echo off>>%CONDA_ACT_FILE_CMD% -echo set PYTHONPATH_OLD=%%PYTHONPATH%%>>%CONDA_ACT_FILE_CMD% -echo set PYTHONPATH=%%PYTHONPATH%%;%ISAAC_SIM_PATH%\site>>%CONDA_ACT_FILE_CMD% -echo set CARB_APP_PATH=%ISAAC_SIM_PATH%\kit>>%CONDA_ACT_FILE_CMD% -echo set EXP_PATH=%ISAAC_SIM_PATH%\apps>>%CONDA_ACT_FILE_CMD% -echo set ISAAC_PATH=%ISAAC_SIM_PATH%>>%CONDA_ACT_FILE_CMD% - -set CONDA_DEACT_FILE_CMD=%CONDA_PREFIX%\etc\conda\deactivate.d\env_vars.bat -echo @echo off>>%CONDA_DEACT_FILE_CMD% -echo set PYTHONPATH=%%PYTHONPATH_OLD%%>>%CONDA_DEACT_FILE_CMD% -echo set PYTHONPATH_OLD="">>%CONDA_DEACT_FILE_CMD% - -:: Add support for powershell -set CONDA_ACT_FILE_PWSH=%CONDA_PREFIX%\etc\conda\activate.d\env_vars.ps1 -echo $env:PYTHONPATH_OLD="$env:PYTHONPATH">>%CONDA_ACT_FILE_PWSH% -echo $env:PYTHONPATH="$env:PYTHONPATH;%ISAAC_SIM_PATH%\site">>%CONDA_ACT_FILE_PWSH% -echo $env:CARB_APP_PATH="%ISAAC_SIM_PATH%\kit">>%CONDA_ACT_FILE_PWSH% -echo $env:EXP_PATH="%ISAAC_SIM_PATH%\apps">>%CONDA_ACT_FILE_PWSH% -echo $env:ISAAC_PATH="%ISAAC_SIM_PATH%">>%CONDA_ACT_FILE_PWSH% - -set CONDA_DEACT_FILE_PWSH=%CONDA_PREFIX%\etc\conda\deactivate.d\env_vars.ps1 -echo $env:PYTHONPATH="$env:PYTHONPATH_OLD">>%CONDA_DEACT_FILE_PWSH% -echo $env:PYTHONPATH_OLD="$null">>%CONDA_DEACT_FILE_PWSH% - - -:: Install omnigibson! -call pip install -e . || goto :error - -:: Cycle conda environment so that all dependencies are propagated -call conda deactivate || goto :error -goto :end - -:error -echo: -echo An error occurred during installation. Please check the error message above. -echo: -exit /b - -:end -echo: -echo OmniGibson successfully installed! Please run conda activate %conda_name% to activate the environment. -echo: diff --git a/scripts/setup.sh b/scripts/setup.sh deleted file mode 100755 index 4f34e0ea5..000000000 --- a/scripts/setup.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env bash -set -eo &> /dev/null - -# Make sure that the ISAAC_SIM_PATH variable is set correctly -if [[ -d ~/.local/share/ov/pkg ]] && [[ $(ls ~/.local/share/ov/pkg | grep isaac) ]]; -then - FOUND_ISAAC_SIM_PATH=$(ls -d ~/.local/share/ov/pkg/* | grep isaac | tail -n 1) - echo "We found Isaac Sim installed at $FOUND_ISAAC_SIM_PATH. OmniGibson will use it by default." - read -p "If you want to use a different one, please type in the path containing isaac-sim.sh here (press enter to skip) >>> " ISAAC_SIM_PATH - ISAAC_SIM_PATH=${ISAAC_SIM_PATH:-$FOUND_ISAAC_SIM_PATH} -else - echo "We did not find Isaac Sim under ~/.local/share/ov/pkg." - echo "If you haven't installed Isaac Sim yet, please do so before running this setup script." - read -p "If you have already installed it in a custom location, please type in the path containing isaac-sim.sh here >>> " ISAAC_SIM_PATH -fi - -while [[ ! -n $(find "${ISAAC_SIM_PATH}" -maxdepth 1 -name "isaac*.sh" 2>/dev/null) ]]; do - read -p "isaac*.sh not found in $ISAAC_SIM_PATH! Make sure you have entered the correct path >>> " ISAAC_SIM_PATH -done -echo -e "\nUsing Isaac Sim at $ISAAC_SIM_PATH\n" - - -# Choose venv name -echo "The new conda environment will be named omnigibson by default." -read -p "If you want to use a different name, please type in here (press enter to skip) >>> " conda_name -conda_name=${conda_name:-omnigibson} -echo -e "\nUsing $conda_name as the conda environment name\n" - -# Get Python version from Isaac Sim -ISAAC_PYTHON_VERSION=$(${ISAAC_SIM_PATH}/python.sh -c "import platform; print(platform.python_version())") -ISAAC_PYTHON_VERSION="${ISAAC_PYTHON_VERSION##*$'\n'}" # get rid of conda activation warnings -echo Using Python version $ISAAC_PYTHON_VERSION matching your current Isaac Sim version - -# Create a conda environment with the appropriate python version -source $(conda info --base)/etc/profile.d/conda.sh -conda create -y -n $conda_name python=${ISAAC_PYTHON_VERSION} - -# Now activate the omnigibson environment -conda activate $conda_name - -mkdir -p ${CONDA_PREFIX}/etc/conda/activate.d -mkdir -p ${CONDA_PREFIX}/etc/conda/deactivate.d -touch ${CONDA_PREFIX}/etc/conda/activate.d/env_vars.sh -touch ${CONDA_PREFIX}/etc/conda/deactivate.d/env_vars.sh -# We add some preprocessing information so that the Isaac Sim paths are linked to this environment upon startup -# See https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#macos-and-linux for reference -CONDA_ACT_FILE="${CONDA_PREFIX}/etc/conda/activate.d/env_vars.sh" -echo '#!/bin/sh' > ${CONDA_ACT_FILE} -echo "export LD_LIBRARY_PATH_OLD=\$LD_LIBRARY_PATH" >> ${CONDA_ACT_FILE} -echo "export PYTHONPATH_OLD=\$PYTHONPATH" >> ${CONDA_ACT_FILE} -echo "source ${ISAAC_SIM_PATH}/setup_conda_env.sh" >> ${CONDA_ACT_FILE} - -CONDA_DEACT_FILE="${CONDA_PREFIX}/etc/conda/deactivate.d/env_vars.sh" -echo '#!/bin/sh' > ${CONDA_DEACT_FILE} -echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH_OLD" >> ${CONDA_DEACT_FILE} -echo "export PYTHONPATH=\$PYTHONPATH_OLD" >> ${CONDA_DEACT_FILE} -echo "unset ISAAC_PATH" >> ${CONDA_DEACT_FILE} -echo "unset CARB_APP_PATH" >> ${CONDA_DEACT_FILE} -echo "unset LD_LIBRARY_PATH_OLD" >> ${CONDA_DEACT_FILE} -echo "unset PYTHONPATH_OLD" >> ${CONDA_DEACT_FILE} - -# Install omnigibson! -pip install -e . - -# Cycle conda environment so that all dependencies are propagated -conda deactivate - -echo -e "\nOmniGibson successfully installed! Please run conda activate $conda_name to activate the environment.\n" diff --git a/setup.py b/setup.py index cc6ceb882..1df6e7b1a 100644 --- a/setup.py +++ b/setup.py @@ -47,10 +47,9 @@ "rtree~=1.2.0", "graphviz~=0.20", "numba>=0.60.0", + "matplotlib>=3.0.0", ], - extras_require={ - "isaac": ["isaacsim-for-omnigibson>=4.1.0"], - }, + extras_require={}, tests_require=[], python_requires=">=3", include_package_data=True,