btx0424 / OmniDrones

https://omnidrones.readthedocs.io/
MIT License
147 stars 25 forks source link

not able to set up the conda environment #54

Open viveksahukar opened 6 months ago

viveksahukar commented 6 months ago

I'm trying to set up the conda environment as mentioned at the start of the installation page in the documentation.

after running

# at OmniDrones/
cp -r conda_setup/etc $CONDA_PREFIX
# re-activate the environment
conda activate sim

however, I'm getting the following error /home/vs/.local/share/ov/pkg/isaac_sim-2023.1.1/setup_conda_env.sh:.:20: no such file or directory: /home/vs/Developer/ai-safety-drone/OmniDrones/setup_python_env.sh

I looked into the directory structure and I believe that the setup_python_env.sh has been replaced by 2 env_vars.sh scripts in activate.d and deactivate.d folders. Is this correct, how to resolve the situation? Thanks!

btx0424 commented 6 months ago

Hi there. What shell are you using? Is it bash or other shells?

There should be a setup_python_env.sh in the same folder as setup_conda_env.sh.

Can you add a line to setup_conda_env.sh to check if it has correctly located setup_python_env.sh?

#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
MY_DIR="$(realpath -s "$SCRIPT_DIR")"
# path=$SCRIPT_DIR
# while [[ $path != / ]];
# do

#     if ! find "$path" -maxdepth 1 -mindepth 1 -iname "_build" -exec false {} +
#     then
#         break
#     fi
#     # Note: if you want to ignore symlinks, use "$(realpath -s "$path"/..)"
#     path="$(readlink -f "$path"/..)"

# done
# build_path=$path/_build
export CARB_APP_PATH=$SCRIPT_DIR/kit
export EXP_PATH=$MY_DIR/apps
export ISAAC_PATH=$MY_DIR
echo ${MY_DIR}
. ${MY_DIR}/setup_python_env.sh
jialongzeng commented 6 months ago

Hi there. What shell are you using? Is it bash or other shells?

There should be a setup_python_env.sh in the same folder as setup_conda_env.sh.

Can you add a line to setup_conda_env.sh to check if it has correctly located setup_python_env.sh?

#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
MY_DIR="$(realpath -s "$SCRIPT_DIR")"
# path=$SCRIPT_DIR
# while [[ $path != / ]];
# do

#     if ! find "$path" -maxdepth 1 -mindepth 1 -iname "_build" -exec false {} +
#     then
#         break
#     fi
#     # Note: if you want to ignore symlinks, use "$(realpath -s "$path"/..)"
#     path="$(readlink -f "$path"/..)"

# done
# build_path=$path/_build
export CARB_APP_PATH=$SCRIPT_DIR/kit
export EXP_PATH=$MY_DIR/apps
export ISAAC_PATH=$MY_DIR
echo ${MY_DIR}
. ${MY_DIR}/setup_python_env.sh

I am using zsh and facing the same problem.

I added the line you mentioned and found that ${MY_DIR} is the same as the current directory with the terminal (the same with the output of pwd), which means that I have to cd to the isaac sim directory first before I run conda activate sim.

Is there any solution for that? Anyway, it doesn't matter if I have to cd first every time.

jialongzeng commented 6 months ago

Hi there. What shell are you using? Is it bash or other shells? There should be a setup_python_env.sh in the same folder as setup_conda_env.sh. Can you add a line to setup_conda_env.sh to check if it has correctly located setup_python_env.sh?

#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
MY_DIR="$(realpath -s "$SCRIPT_DIR")"
# path=$SCRIPT_DIR
# while [[ $path != / ]];
# do

#     if ! find "$path" -maxdepth 1 -mindepth 1 -iname "_build" -exec false {} +
#     then
#         break
#     fi
#     # Note: if you want to ignore symlinks, use "$(realpath -s "$path"/..)"
#     path="$(readlink -f "$path"/..)"

# done
# build_path=$path/_build
export CARB_APP_PATH=$SCRIPT_DIR/kit
export EXP_PATH=$MY_DIR/apps
export ISAAC_PATH=$MY_DIR
echo ${MY_DIR}
. ${MY_DIR}/setup_python_env.sh

I am using zsh and facing the same problem.

I added the line you mentioned and found that ${MY_DIR} is the same as the current directory with the terminal (the same with the output of pwd), which means that I have to cd to the isaac sim directory first before I run conda activate sim.

Is there any solution for that? Anyway, it doesn't matter if I have to cd first every time.

There is also another problem that the import torch can only work when my working directory is in Isaac sim and thus I can not use python setup.py develop to install the mentioned two packages because it will cause ModuleNotFoundError: No module named 'torch'.

btx0424 commented 6 months ago

Hello. This is a known issue of zsh, also mentioned in other Isaac Sim projects and the forum. I think the simplest but maybe not the most graceful solution would be modifying the shell scripts to manually set the paths correctly.

viveksahukar commented 6 months ago

Thank you for the quick reply, I switched to bash and set the path for ISAAC_SIM in the .bashrc and the example scripts ran. To verify the installation, as mentioned in the documentation I ran python train.py algo=ppo headless=true wandb.entity=YOUR_WANDB_ENTITY. The results were logged to wandb account, but it says "Failed". I can see all the graphs and loss-curves converging to zero. Is the installation working correctly?

Also, I'm trying to use this Omnidrones repository for my AI Safety course. I want to introduce few obstacles in the custom environment. I then want to make the drone learn to fly through while avoiding obstacles and I will introduce some AI safety constraints. How to make changes to the environment and use other RL algorithms for training?

btx0424 commented 6 months ago

Regarding your questions:

  1. I am not sure what's happening. Can you try other single-agent envs or provide a screenshot or a link to the wandb workspace?
  2. Does the task Forest align with your interest? Adding obstacles of primitive shapes is also possible, see OmniDrones/omni_drones/envs/payload/payload_fly_through.py for the usage of create_obstacle.
  3. Using other RL algorithms is easy. TorchRL's collector does all the data collection and what you need to do is a bit interfacing.
    env = ...
    policy = ... # rollout policy of your algorithm
    collector = SyncDataCollector(
        env,
        policy=policy,
        frames_per_batch=frames_per_batch,
        total_frames=total_frames,
        device=device,
    )
    for data in collector:
        results = your_algorithm.do_something(data) # your training logic
jialongzeng commented 6 months ago

Hello. This is a known issue of zsh, also mentioned in other Isaac Sim projects and the forum. I think the simplest but maybe not the most graceful solution would be modifying the shell scripts to manually set the paths correctly.

Hi there, I found a solution for zshell to work well with conda environment stuff in https://github.com/NVIDIA-Omniverse/orbit/issues/103#issuecomment-1662112177