Genesis icon indicating copy to clipboard operation
Genesis copied to clipboard

No module named 'LuisaRenderPy'

Open Xu-Xuanhui opened this issue 1 year ago • 13 comments

python examples/rendering/demo.py

[Genesis] [23:14:40] [INFO] ╭───────────────────────────────────────────────╮ [Genesis] [23:14:40] [INFO] │┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈ Genesis ┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈│ [Genesis] [23:14:40] [INFO] ╰───────────────────────────────────────────────╯ [Genesis] [23:14:41] [INFO] Running on [NVIDIA GeForce RTX 4070 Laptop GPU] with backend gs.cuda. Device memory: 7.75 GB. [Genesis] [23:14:42] [DEBUG] [Taichi] version 1.7.2, llvm 15.0.4, commit 0131dce9, linux, python 3.10.16 [Genesis] [23:14:42] [DEBUG] [Taichi] Starting on arch=cuda [Genesis] [23:14:42] [INFO] 🚀 Genesis initialized. 🔖 version: 0.2.0, 🌱 seed: 0, 📏 precision: '32', 🐛 debug: False, 🎨 theme: 'dark'. Traceback (most recent call last): File "/home/xxh/anaconda3/envs/genesis/lib/python3.10/site-packages/genesis/vis/raytracer.py", line 17, in import LuisaRenderPy ModuleNotFoundError: No module named 'LuisaRenderPy'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/xxh/Documents/Genesis-main/examples/rendering/demo.py", line 166, in main() File "/home/xxh/Documents/Genesis-main/examples/rendering/demo.py", line 11, in main scene = gs.Scene( File "/home/xxh/anaconda3/envs/genesis/lib/python3.10/site-packages/genesis/utils/misc.py", line 27, in new_init original_init(self, *args, **kwargs) File "/home/xxh/anaconda3/envs/genesis/lib/python3.10/site-packages/genesis/engine/scene.py", line 148, in init self._visualizer = Visualizer( File "/home/xxh/anaconda3/envs/genesis/lib/python3.10/site-packages/genesis/vis/visualizer.py", line 60, in init from .raytracer import Raytracer File "/home/xxh/anaconda3/envs/genesis/lib/python3.10/site-packages/genesis/vis/raytracer.py", line 19, in gs.raise_exception(f"Failed to import LuisaRenderer. {e.class.name}: {e}")

[Genesis] [23:14:44] [ERROR] Failed to import LuisaRenderer. ModuleNotFoundError: No module named 'LuisaRenderPy'

How to fix this?Is LuisaRender not installed properly? Has anyone solved this problem?

Xu-Xuanhui avatar Dec 19 '24 15:12 Xu-Xuanhui

Luisa raytracing rendering requires building as mentioned here. We will update the installation guide soon. Stay tuned.

zswang666 avatar Dec 19 '24 16:12 zswang666

I'm having a similar issue here as well. It seems like python bindings are not being generated at all when luisa-render is compiled and built.

wildthingz avatar Dec 19 '24 18:12 wildthingz

I'm having a similar issue here as well. It seems like python bindings are not being generated at all when luisa-render is compiled and built.

Do you fix it?

Xu-Xuanhui avatar Dec 19 '24 23:12 Xu-Xuanhui

Luisa raytracing rendering requires building as mentioned here. We will update the installation guide soon. Stay tuned.

I built LuisaRender. But it still does't work

Xu-Xuanhui avatar Dec 19 '24 23:12 Xu-Xuanhui

The problem is that the file is generated correctly after build in the folder genesis/Genesis/genesis/ext/LuisaRender/build/bin/LuisaRenderPy.cpython-312-x86_64-linux-gnu.so

However it is not imported correctly in the renderer code. In my system the variable LRP_PATH in file raytracer.py maps to /home/root/src/genesis/lib/python3.12/site-packages/genesis/ which is not where the module is built.

As a temporary fix I have modified the local copy of the file raytracer.py:14 to specify the correct LRP_PATH. Hope this helps.

akashgoswami avatar Dec 20 '24 00:12 akashgoswami

thanks akash. LuisaRenderPy.cpython-312-x86_64-linux-gnu.so is not generated for me for some reason. I also looks through the luisarender's cmake files, I couldn't find any line that instructs the compiler to generate that file.

What version of luisa are you using and how are you building it?

wildthingz avatar Dec 20 '24 00:12 wildthingz

The problem is that the file is generated correctly after build in the folder genesis/Genesis/genesis/ext/LuisaRender/build/bin/LuisaRenderPy.cpython-312-x86_64-linux-gnu.so

However it is not imported correctly in the renderer code. In my system the variable LRP_PATH in file raytracer.py maps to /home/root/src/genesis/lib/python3.12/site-packages/genesis/ which is not where the module is built.

As a temporary fix I have modified the local copy of the file raytracer.py:14 to specify the correct LRP_PATH. Hope this helps.

In my system the variable LRP_PATH in file raytracer.py maps to 'ext/LuisaRender/build/bin' which seem right. However, 'LuisaRenderPy.cpython-312-x86_64-linux-gnu.so' isn't exist. I can't find 'LuisaRenderPy.cpython-312-x86_64-linux-gnu.so' in my system. It seem the problem of the LuisaRender building. But it doen't report error when I built LuisaRender.

Xu-Xuanhui avatar Dec 20 '24 00:12 Xu-Xuanhui

thanks akash. LuisaRenderPy.cpython-312-x86_64-linux-gnu.so is not generated for me for some reason. I also looks through the luisarender's cmake files, I couldn't find any line that instructs the compiler to generate that file.

What version of luisa are you using and how are you building it?

Same problem!

Xu-Xuanhui avatar Dec 20 '24 00:12 Xu-Xuanhui

The problem is that the file is generated correctly after build in the folder genesis/Genesis/genesis/ext/LuisaRender/build/bin/LuisaRenderPy.cpython-312-x86_64-linux-gnu.so

However it is not imported correctly in the renderer code. In my system the variable LRP_PATH in file raytracer.py maps to /home/root/src/genesis/lib/python3.12/site-packages/genesis/ which is not where the module is built.

As a temporary fix I have modified the local copy of the file raytracer.py:14 to specify the correct LRP_PATH. Hope this helps. thanks akash. Zhang Shaokun replied me that 'Genesis uses a forked version of LuisaRender maintained by their project’s developers.' What version of luisa are you using?

Xu-Xuanhui avatar Dec 20 '24 01:12 Xu-Xuanhui

The problem is that the file is generated correctly after build in the folder genesis/Genesis/genesis/ext/LuisaRender/build/bin/LuisaRenderPy.cpython-312-x86_64-linux-gnu.so

However it is not imported correctly in the renderer code. In my system the variable LRP_PATH in file raytracer.py maps to /home/root/src/genesis/lib/python3.12/site-packages/genesis/ which is not where the module is built.

As a temporary fix I have modified the local copy of the file raytracer.py:14 to specify the correct LRP_PATH. Hope this helps.

Zheng Shaokun replied me that 'Genesis uses a forked version of LuisaRender maintained by their project’s developers. ' What version of luisa are you using?

Xu-Xuanhui avatar Dec 20 '24 01:12 Xu-Xuanhui

It's possible to manually link the LuisaRenderPy.cpython-312-x86_64-linux-gnu.so to the conda python enviroment:

SITE_PACKAGES=$(python -c "import site; print(site.getsitepackages()[0])")
ln -s /full/path/to/build/LuisaRenderPy.cpython-312-x86_64-linux-gnu.so "$SITE_PACKAGES/LuisaRenderPy.cpython-312-x86_64-linux-gnu.so"

Jiaviz avatar Dec 20 '24 03:12 Jiaviz

How do I get LuisaRenderPy? If I compile the code as stated in the installation instructions, it does not compile packages for Python.

Evgeny105 avatar Dec 20 '24 03:12 Evgeny105

How do I get LuisaRenderPy? If I compile the code as stated in the installation instructions, it does not compile packages for Python.

You built the wrong LuisaRender version. The LusiaRender in 'https://github.com/LuisaGroup/LuisaRender.git' can't generate LuisaRenderPy.cpython-312-x86_64-linux-gnu.so.

Alif-01's fork update python interface(https://github.com/Alif-01/LuisaRender.git) . I built it and LuisaRenderPy.cpython-312-x86_64-linux-gnu.so was generated. You need python3.12 to import LuisaRenderPy. (LuisaRenderPy.cpython-312-x86_64-linux-gnu.so should be renamed as LuisaRenderPy.so )

However, I meet the new error. [2024-12-20 12:25:48.553] [console] [warning] Failed to load built-in kernels: the provided PTX was compiled with an unsupported toolchain.. Re-trying with lower compute capability... [/home/xxh/Downloads/LuisaRender/src/compute/src/backends/cuda/cuda_device.cpp:127] [2024-12-20 12:25:48.575] [console] [error] CUDA_ERROR_UNSUPPORTED_PTX_VERSION: the provided PTX was compiled with an unsupported toolchain. [/home/xxh/Downloads/LuisaRender/src/compute/src/backends/cuda/cuda_device.cpp:136]

It seems that I have to reinstall lower version CUDA. ACMLCZH also updated python interface. I am trying to build his fork.

Xu-Xuanhui avatar Dec 20 '24 04:12 Xu-Xuanhui

How do I get LuisaRenderPy? If I compile the code as stated in the installation instructions, it does not compile packages for Python. I have install the LuisaRender Ubuntu 22.04 Nvidia driver 535.183.01,cuda 12.2! I update the cuda! python 3.10 git clone https://github.com/Genesis-Embodied-AI/Genesis.git cd Genesis git submodule update --init --recursive

You should follow the user guider to install the Dependencies.

cd genesis/ext/LuisaRender cmake -S . -B build -D CMAKE_BUILD_TYPE=Release -D PYTHON_VERSIONS=3.10 -D LUISA_COMPUTE_DOWNLOAD_NVCOMP=ON -D LUISA_COMPUTE_ENABLE_GUI=OFF cmake --build build -j $(nproc)

Finall I copy the etx folder to my conda envs. It works!

Xu-Xuanhui avatar Dec 20 '24 14:12 Xu-Xuanhui

Perfect! thanks @Xu-Xuanhui

wildthingz avatar Dec 20 '24 17:12 wildthingz

In my case need some extra tweaks))

1. Install Required Dependencies

Install GCC and G++ for Linux

Ensure you have the necessary compilers installed in your environment. Use conda to install them:

conda install -c conda-forge gcc_linux-64 gxx_linux-64

Install NVIDIA CUDA Toolkit

Install the CUDA toolkit on your system using your package manager. For example, on Ubuntu:

sudo apt install nvidia-cuda-toolkit

2. Recompile LuisaRenderer with CUDA Support

If the LuisaRenderer library was not compiled with CUDA support, you need to recompile it.

Steps to Recompile

  1. Navigate to the LuisaRenderer source directory:

    cd /path/to/LuisaRenderer
    
  2. Clean the previous build (if any):

    rm -rf build
    
  3. Configure the build with CUDA support (LUISA_COMPUTE_ENABLE_CUDA=ON):

    cmake -S . -B build -D CMAKE_BUILD_TYPE=Release -D PYTHON_VERSIONS=3.9 -D LUISA_COMPUTE_DOWNLOAD_NVCOMP=ON -D LUISA_COMPUTE_ENABLE_GUI=OFF -D LUISA_COMPUTE_ENABLE_CUDA=ON
    
  4. Build the project:

    cmake --build build -j $(nproc)
    

Check CUDA Version

Run the following command to check the installed CUDA version:

nvcc --version

Verify CUDA Libraries

Check if the CUDA libraries are available:

find /usr -name "libcudart.so" 2>/dev/null

If the output shows the path to libcudart.so, CUDA is installed correctly.

Evgeny105 avatar Dec 20 '24 17:12 Evgeny105

Thanks @Xu-Xuanhui and @Evgeny105

We updated the doc here

zswang666 avatar Dec 20 '24 18:12 zswang666

After troubleshooting, I found the root cause of the issue I encountered:

  • First, I installed the official release package using the command pip install genesis-world.
  • Then, I downloaded the Genesis code via git clone to a local directory and used cmake to compile the related files for LuisaRenderPy.
  • When attempting to run demo.py, the genesis code being imported was located in the library path of the pip-installed environment (e.g., /home/user/venv/torch/lib/python3.10/site-packages/genesis/), which is not in the same directory as the parent directory where LuisaRenderPy is located.
  • When genesis called the code in raytracer.py (specifically, miscu.get_src_dir), it naturally referred to the pip-installed library path, and therefore, it couldn't find the locally compiled LuisaRenderPy files in the other directory.

There are two potential solutions:

  • Copy the related files to pip-installed library path
  • Instead of installing the official release package, download the code manually, compile the LuisaRenderPy files, repackage it (ensuring the compiled LuisaRenderPy files are included), and then install the newly packaged version.

Vesnica avatar Dec 20 '24 19:12 Vesnica

Here’s a concise solution:

Problem: The command cmake --build build -j $(nproc) installs the LuisaRenderPy dynamic libraries (e.g., LuisaRenderPy.cpython-39-x86_64-linux-gnu.so) by default to the genesis/ext/LuisaRender/build/bin directory, rather than to the Python environment. Solution: To resolve this, create a symbolic link to the LuisaRender folder in your Python environment:

# inside Genesis/
SITE_PACKAGES=$(python -c "import site; print(site.getsitepackages()[0])")
ln -s genesis/ext/LuisaRender "$SITE_PACKAGES/genesis/ext/LuisaRender"

Li-Yuetao avatar Dec 23 '24 07:12 Li-Yuetao

How do I get LuisaRenderPy? If I compile the code as stated in the installation instructions, it does not compile packages for Python. I have install the LuisaRender Ubuntu 22.04 Nvidia driver 535.183.01,cuda 12.2! I update the cuda! python 3.10 git clone https://github.com/Genesis-Embodied-AI/Genesis.git cd Genesis git submodule update --init --recursive

You should follow the user guider to install the Dependencies.

cd genesis/ext/LuisaRender cmake -S . -B build -D CMAKE_BUILD_TYPE=Release -D PYTHON_VERSIONS=3.10 -D LUISA_COMPUTE_DOWNLOAD_NVCOMP=ON -D LUISA_COMPUTE_ENABLE_GUI=OFF cmake --build build -j $(nproc)

Finall I copy the etx folder to my conda envs. It works!

I copied genesis/ext/LuisaRender/build/bin/* to root\miniconda3\envs\torch\lib\python3.9\site-packages\genesis\ext\LuisaRender,But also get error No module named 'LuisaRenderPy',Why?

zhangiser avatar Dec 29 '24 13:12 zhangiser