Skip to content

Commit f1a3696

Browse files
Mayankm96kellyguo11
authored andcommitted
Fixes isaaclab scripts to deal with Isaac Sim pip installation (isaac-sim#631)
# Description Earlier the script hard-coded with path to Isaac Sim installation as the sym-linked directory "_isaac_sim". However, when doing PIP installation, this workflow doesn't hold. The MR modifies the scripts `isaaclab.sh` and `isaaclab.bat` to now check for PIP package installation and get paths from there if they exist. Fixes isaac-sim#516, isaac-sim#629 ## Type of change - Bug fix (non-breaking change which fixes an issue) ## Checklist - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [x] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there --------- Signed-off-by: Mayank Mittal <12863862+Mayankm96@users.noreply.github.com> Co-authored-by: Kelly Guo <kellyg@nvidia.com>
1 parent 125f59f commit f1a3696

File tree

7 files changed

+366
-184
lines changed

7 files changed

+366
-184
lines changed

.vscode/tools/setup_vscode.py

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
# check if the isaac-sim directory exists
3232
if not os.path.exists(isaacsim_dir):
3333
raise FileNotFoundError(
34-
f"Could not find the isaac-sim directory: {isaacsim_dir}. There are two possible reasons for this:\n"
35-
"\t1. The Isaac Sim directory does not exist as a symlink in the Isaac Lab directory.\n"
36-
"\t2. The script could import the 'isaacsim' package. This could be due to the 'isaacsim' package not being "
34+
f"Could not find the isaac-sim directory: {isaacsim_dir}. There are two possible reasons for this:"
35+
f"\n\t1. The Isaac Sim directory does not exist as a symlink at: {os.path.join(ISAACLAB_DIR, '_isaac_sim')}"
36+
"\n\t2. The script could import the 'isaacsim' package. This could be due to the 'isaacsim' package not being "
3737
"installed in the Python environment.\n"
38-
"Please make sure that the Isaac Sim directory exists or that the 'isaacsim' package is installed."
38+
"\nPlease make sure that the Isaac Sim directory exists or that the 'isaacsim' package is installed."
3939
)
4040

4141
ISAACSIM_DIR = isaacsim_dir
@@ -48,39 +48,49 @@ def overwrite_python_analysis_extra_paths(isaaclab_settings: str) -> str:
4848
The extraPaths are replaced with the path names from the isaac-sim settings file that exists in the
4949
"{ISAACSIM_DIR}/.vscode/settings.json" file.
5050
51+
If the isaac-sim settings file does not exist, the extraPaths are not overwritten.
52+
5153
Args:
5254
isaaclab_settings: The settings string to use as template.
5355
5456
Returns:
5557
The settings string with overwritten python analysis extra paths.
56-
57-
Raises:
58-
FileNotFoundError: If the isaac-sim settings file does not exist.
5958
"""
6059
# isaac-sim settings
6160
isaacsim_vscode_filename = os.path.join(ISAACSIM_DIR, ".vscode", "settings.json")
62-
# make sure the isaac-sim settings file exists
63-
if not os.path.exists(isaacsim_vscode_filename):
64-
raise FileNotFoundError(f"Could not find the isaac-sim settings file: {isaacsim_vscode_filename}")
65-
66-
# read the path names from the isaac-sim settings file
67-
with open(isaacsim_vscode_filename) as f:
68-
vscode_settings = f.read()
69-
# extract the path names
70-
# search for the python.analysis.extraPaths section and extract the contents
71-
settings = re.search(r"\"python.analysis.extraPaths\": \[.*?\]", vscode_settings, flags=re.MULTILINE | re.DOTALL)
72-
settings = settings.group(0)
73-
settings = settings.split('"python.analysis.extraPaths": [')[-1]
74-
settings = settings.split("]")[0]
75-
76-
# read the path names from the isaac-sim settings file
77-
path_names = settings.split(",")
78-
path_names = [path_name.strip().strip('"') for path_name in path_names]
79-
path_names = [path_name for path_name in path_names if len(path_name) > 0]
80-
81-
# change the path names to be relative to the Isaac Lab directory
82-
rel_path = os.path.relpath(ISAACSIM_DIR, ISAACLAB_DIR)
83-
path_names = ['"${workspaceFolder}/' + rel_path + "/" + path_name + '"' for path_name in path_names]
61+
62+
# we use the isaac-sim settings file to get the python.analysis.extraPaths for kit extensions
63+
# if this file does not exist, we will not add any extra paths
64+
if os.path.exists(isaacsim_vscode_filename):
65+
# read the path names from the isaac-sim settings file
66+
with open(isaacsim_vscode_filename) as f:
67+
vscode_settings = f.read()
68+
# extract the path names
69+
# search for the python.analysis.extraPaths section and extract the contents
70+
settings = re.search(
71+
r"\"python.analysis.extraPaths\": \[.*?\]", vscode_settings, flags=re.MULTILINE | re.DOTALL
72+
)
73+
settings = settings.group(0)
74+
settings = settings.split('"python.analysis.extraPaths": [')[-1]
75+
settings = settings.split("]")[0]
76+
77+
# read the path names from the isaac-sim settings file
78+
path_names = settings.split(",")
79+
path_names = [path_name.strip().strip('"') for path_name in path_names]
80+
path_names = [path_name for path_name in path_names if len(path_name) > 0]
81+
82+
# change the path names to be relative to the Isaac Lab directory
83+
rel_path = os.path.relpath(ISAACSIM_DIR, ISAACLAB_DIR)
84+
path_names = ['"${workspaceFolder}/' + rel_path + "/" + path_name + '"' for path_name in path_names]
85+
else:
86+
path_names = []
87+
print(
88+
f"[WARN] Could not find Isaac Sim VSCode settings: {isaacsim_vscode_filename}."
89+
"\n\tThis will result in missing 'python.analysis.extraPaths' in the VSCode"
90+
"\n\tsettings, which limits the functionality of the Python language server."
91+
"\n\tHowever, it does not affect the functionality of the Isaac Lab project."
92+
"\n\tWe are working on a fix for this issue with the Isaac Sim team."
93+
)
8494

8595
# add the path names that are in the Isaac Lab extensions directory
8696
isaaclab_extensions = os.listdir(os.path.join(ISAACLAB_DIR, "source", "extensions"))
@@ -89,9 +99,9 @@ def overwrite_python_analysis_extra_paths(isaaclab_settings: str) -> str:
8999
# combine them into a single string
90100
path_names = ",\n\t\t".expandtabs(4).join(path_names)
91101
# deal with the path separator being different on Windows and Unix
92-
path_names = path_names.replace("/", os.sep)
102+
path_names = path_names.replace("\\", "/")
93103

94-
# replace the path names in the Isaac Lab settings file with the path names from the isaac-sim settings file
104+
# replace the path names in the Isaac Lab settings file with the path names parsed
95105
isaaclab_settings = re.sub(
96106
r"\"python.analysis.extraPaths\": \[.*?\]",
97107
'"python.analysis.extraPaths": [\n\t\t'.expandtabs(4) + path_names + "\n\t]".expandtabs(4),
@@ -116,10 +126,7 @@ def overwrite_default_python_interpreter(isaaclab_settings: str) -> str:
116126
The settings string with overwritten default python interpreter.
117127
"""
118128
# read executable name
119-
python_exe = sys.executable
120-
# if python interpreter is from conda, use that. Otherwise, use the template.
121-
if "conda" not in python_exe:
122-
return isaaclab_settings
129+
python_exe = sys.executable.replace("\\", "/")
123130
# replace the default python interpreter in the Isaac Lab settings file with the path to the
124131
# python interpreter in the Isaac Lab directory
125132
isaaclab_settings = re.sub(
@@ -146,9 +153,9 @@ def main():
146153

147154
# overwrite the python.analysis.extraPaths in the Isaac Lab settings file with the path names
148155
isaaclab_settings = overwrite_python_analysis_extra_paths(isaaclab_template_settings)
149-
# overwrite the default python interpreter in the Isaac Lab settings file
150-
# NOTE: thisis disabled since we don't need it. The default interpreter should always be the one from isaac-sim
151-
# isaaclab_settings = overwrite_default_python_interpreter(isaaclab_settings)
156+
# overwrite the default python interpreter in the Isaac Lab settings file with the path to the
157+
# python interpreter used to call this script
158+
isaaclab_settings = overwrite_default_python_interpreter(isaaclab_settings)
152159

153160
# add template notice to the top of the file
154161
header_message = (

docker/Dockerfile.pip

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Copyright (c) 2022-2024, The Isaac Lab Project Developers.
2+
# All rights reserved.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
6+
# This Dockerfile is used to build a Docker image for the Isaac Lab framework.
7+
#
8+
# It uses the pip package manager to install Isaac Sim and the Isaac Lab framework.
9+
#
10+
# To build the Docker image and run the Docker container, follow the steps below:
11+
#
12+
# 1. Build the Docker image:
13+
# docker build -t isaac-lab:latest -f docker/Dockerfile.pip .
14+
# 2. Run the Docker container:
15+
# docker run -it --gpus all --rm --network=host --name isaac-lab -v $(pwd):/root/isaaclab isaac-lab:latest
16+
17+
# Base image: Ubuntu 22.04
18+
FROM ubuntu:22.04 AS base
19+
20+
# Set default RUN shell to bash
21+
SHELL ["/bin/bash", "-c"]
22+
23+
# Adds labels to the Dockerfile
24+
LABEL version="1.0"
25+
LABEL description="Dockerfile for building and running the Isaac Lab framework in Ubuntu 22.04 container image."
26+
27+
# Arguments
28+
# Path to the Isaac Lab directory
29+
ENV ISAACLAB_PATH=/root/isaaclab
30+
# Home dir of docker user, typically '/root'
31+
ENV DOCKER_USER_HOME=/root
32+
33+
# Set environment variables
34+
ENV LANG=C.UTF-8
35+
ENV DEBIAN_FRONTEND=noninteractive
36+
37+
USER root
38+
39+
# Install dependencies and remove cache
40+
RUN --mount=type=cache,target=/var/cache/apt \
41+
apt-get update && apt-get install -y --no-install-recommends \
42+
build-essential \
43+
cmake \
44+
git \
45+
libglib2.0-0 \
46+
ncurses-term && \
47+
apt -y autoremove && apt clean autoclean && \
48+
rm -rf /var/lib/apt/lists/*
49+
50+
# for singularity usage, have to create the directories that will binded
51+
RUN mkdir -p ${DOCKER_USER_HOME}/.cache/ov && \
52+
mkdir -p ${DOCKER_USER_HOME}/.cache/pip && \
53+
mkdir -p ${DOCKER_USER_HOME}/.cache/nvidia/GLCache && \
54+
mkdir -p ${DOCKER_USER_HOME}/.nv/ComputeCache && \
55+
mkdir -p ${DOCKER_USER_HOME}/.nvidia-omniverse/logs && \
56+
mkdir -p ${DOCKER_USER_HOME}/.local/share/ov/data && \
57+
mkdir -p ${DOCKER_USER_HOME}/Documents
58+
59+
# for singularity usage, create NVIDIA binary placeholders
60+
RUN touch /bin/nvidia-smi && \
61+
touch /bin/nvidia-debugdump && \
62+
touch /bin/nvidia-persistenced && \
63+
touch /bin/nvidia-cuda-mps-control && \
64+
touch /bin/nvidia-cuda-mps-server && \
65+
touch /etc/localtime && \
66+
mkdir -p /var/run/nvidia-persistenced && \
67+
touch /var/run/nvidia-persistenced/socket
68+
69+
# Install python3 and pip
70+
RUN apt-get update && apt-get install -y --no-install-recommends \
71+
python3 \
72+
python3-pip && \
73+
apt -y autoremove && apt clean autoclean && \
74+
rm -rf /var/lib/apt/lists/*
75+
# Maintain python3 as the default python version
76+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
77+
RUN update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
78+
79+
# Install python packages
80+
RUN pip3 install --no-cache-dir --upgrade pip && \
81+
pip install torch==2.2.2 --index-url https://download.pytorch.org/whl/cu118
82+
83+
RUN pip install isaacsim-rl isaacsim-replicator isaacsim-extscache-physics isaacsim-extscache-kit-sdk isaacsim-extscache-kit isaacsim-app --extra-index-url https://pypi.nvidia.com
84+
85+
# Mount the Isaac Lab directory (files to exclude are defined in .dockerignore)
86+
COPY ../ ${ISAACLAB_PATH}
87+
88+
# installing Isaac Lab dependencies
89+
# use pip caching to avoid reinstalling large packages
90+
RUN --mount=type=cache,target=${DOCKER_USER_HOME}/.cache/pip \
91+
${ISAACLAB_PATH}/isaaclab.sh --install
92+
93+
# aliasing isaaclab.sh and python for convenience
94+
RUN echo "export ISAACLAB_PATH=${ISAACLAB_PATH}" >> ${HOME}/.bashrc && \
95+
echo "alias isaaclab=${ISAACLAB_PATH}/isaaclab.sh" >> ${HOME}/.bashrc && \
96+
echo "export TZ=$(date +%Z)" >> ${HOME}/.bashrc
97+
98+
# make working directory as the Isaac Lab directory
99+
# this is the default directory when the container is run
100+
WORKDIR ${ISAACLAB_PATH}

docker/container.sh

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fi
2525

2626
# print the usage description
2727
print_help () {
28-
echo -e "\nusage: $(basename "$0") [-h] [run] [start] [stop] -- Utility for handling docker in Isaac Lab."
28+
echo -e "\nusage: $(basename "$0") [-h] [...] -- Utility for handling Docker in Isaac Lab."
2929
echo -e "\noptional arguments:"
3030
echo -e "\t-h, --help Display the help content."
3131
echo -e "\tstart [profile] Build the docker image and create the container in detached mode."
@@ -36,8 +36,9 @@ print_help () {
3636
echo -e "\tjob [profile] [job_args] Submit a job to the cluster."
3737
echo -e "\tconfig [profile] Parse, resolve and render compose file in canonical format."
3838
echo -e "\n"
39-
echo -e "[profile] is the optional container profile specification and [job_args] optional arguments specific"
40-
echo -e "to the executed script"
39+
echo -e "where: "
40+
echo -e "\t[profile] is the optional container profile specification. Example: 'isaaclab', 'base', 'ros2'."
41+
echo -e "\t[job_args] are optional arguments specific to the executed script."
4142
echo -e "\n" >&2
4243
}
4344

@@ -56,8 +57,8 @@ install_apptainer() {
5657

5758
install_yq() {
5859
# Installing yq to handle file parsing
59-
# Installation procedure from here: https://github.com/mikefarah/yq
60-
read -p "[INFO] Required 'yq' package could not be found. Would you like to install it via wget? (y/N)" yq_answer
60+
# Installation procedure from here: https://github.com/mikefarah/yq?tab=readme-ov-file#linux-via-snap
61+
read -p "[INFO] Required 'yq' package could not be found. Would you like to install it via snap? (y/N)" yq_answer
6162
if [ "$yq_answer" != "${yq_answer#[Yy]}" ]; then
6263
sudo snap install yq
6364
else
@@ -67,17 +68,29 @@ install_yq() {
6768
}
6869

6970
set_statefile_variable() {
71+
# Check if yq is installed
72+
if ! command -v yq &> /dev/null; then
73+
install_yq
74+
fi
7075
# Stores key $1 with value $2 in yaml $STATEFILE
7176
yq -i '.["'"$1"'"] = "'"$2"'"' $STATEFILE
7277
}
7378

7479
load_statefile_variable() {
80+
# Check if yq is installed
81+
if ! command -v yq &> /dev/null; then
82+
install_yq
83+
fi
7584
# Loads key $1 from yaml $STATEFILE as an envvar
7685
# If key does not exist, the loaded var will equal "null"
7786
eval $1="$(yq ".$1" $STATEFILE)"
7887
}
7988

8089
delete_statefile_variable() {
90+
# Check if yq is installed
91+
if ! command -v yq &> /dev/null; then
92+
install_yq
93+
fi
8194
# Deletes key $1 from yaml $STATEFILE
8295
yq -i "del(.$1)" $STATEFILE
8396
}
@@ -270,10 +283,6 @@ if ! command -v docker &> /dev/null; then
270283
exit 1
271284
fi
272285

273-
if ! command -v yq &> /dev/null; then
274-
install_yq
275-
fi
276-
277286
# parse arguments
278287
mode="$1"
279288
profile_arg="$2" # Capture the second argument as the potential profile argument

docs/source/setup/installation/binaries_installation.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
.. _isaacsim-binaries-installation:
2+
3+
14
Installation using Isaac Sim Binaries
25
=====================================
36

docs/source/setup/installation/pip_installation.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1+
.. _isaacsim-pip-installation:
2+
13
Installation using Isaac Sim pip
24
================================
35

46

57
Installing Isaac Sim
68
--------------------
79

8-
.. note::
9-
10-
Installing Isaac Sim from pip is currently an experimental feature.
11-
If errors occur, please report them to the
12-
`Isaac Sim Forums <https://docs.omniverse.nvidia.com/isaacsim/latest/common/feedback.html>`_
13-
and install Isaac Sim from pre-built binaries.
10+
From Isaac Sim 4.0 release, it is possible to install Isaac Sim using pip. This approach is experimental and may have
11+
compatibility issues with some Linux distributions. If you encounter any issues, please report them to the
12+
`Isaac Sim Forums <https://docs.omniverse.nvidia.com/isaacsim/latest/common/feedback.html>`_.
1413

15-
.. note::
14+
.. attention::
1615

1716
Installing Isaac Sim with pip requires GLIBC 2.34+ version compatibility.
1817
To check the GLIBC version on your system, use command ``ldd --version``.
1918

19+
This may pose compatibility issues with some Linux distributions. For instance, Ubuntu 20.04 LTS has GLIBC 2.31
20+
by default. If you encounter compatibility issues, we recommend following the
21+
:ref:`Isaac Sim Binaries Installation <isaacsim-binaries-installation>` approach.
2022

2123
- To use the pip installation approach for Isaac Sim, we recommend first creating a virtual environment.
2224
Ensure that the python version of the virtual environment is **Python 3.10**.

0 commit comments

Comments
 (0)