From 2950530ae6bc17f174bd112be877c393a39a34a7 Mon Sep 17 00:00:00 2001 From: Denis Kochetov Date: Thu, 17 Jul 2025 22:10:59 +0000 Subject: [PATCH] fix diso, spconv and mesh_painter installation --- .../compile_mesh_painter.sh | 2 +- _Pre_Builds/_Build_Scripts/auto_build_all.py | 5 -- _Pre_Builds/_Build_Scripts/build_config.yaml | 15 +++- _Pre_Builds/_Build_Scripts/build_utils.py | 87 ++++++------------- install.py | 35 ++------ requirements.txt | 1 - 6 files changed, 45 insertions(+), 100 deletions(-) diff --git a/Gen_3D_Modules/Hunyuan3D_2_1/hy3dpaint/DifferentiableRenderer/compile_mesh_painter.sh b/Gen_3D_Modules/Hunyuan3D_2_1/hy3dpaint/DifferentiableRenderer/compile_mesh_painter.sh index cf24fb3..dcd66be 100755 --- a/Gen_3D_Modules/Hunyuan3D_2_1/hy3dpaint/DifferentiableRenderer/compile_mesh_painter.sh +++ b/Gen_3D_Modules/Hunyuan3D_2_1/hy3dpaint/DifferentiableRenderer/compile_mesh_painter.sh @@ -1 +1 @@ -c++ -O3 -Wall -shared -std=c++11 -fPIC `python -m pybind11 --includes` mesh_inpaint_processor.cpp -o mesh_inpaint_processor`python3-config --extension-suffix` \ No newline at end of file +c++ -O3 -Wall -shared -std=c++11 -fPIC `python -m pybind11 --includes` mesh_inpaint_processor.cpp -o mesh_inpaint_processor`python -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))"` \ No newline at end of file diff --git a/_Pre_Builds/_Build_Scripts/auto_build_all.py b/_Pre_Builds/_Build_Scripts/auto_build_all.py index 69500ce..a4dd4f6 100644 --- a/_Pre_Builds/_Build_Scripts/auto_build_all.py +++ b/_Pre_Builds/_Build_Scripts/auto_build_all.py @@ -52,11 +52,6 @@ def setup_build_env(): install_remote_packages(build_config.build_base_packages) install_platform_packages() - - # Install spconv with correct CUDA version - from build_utils import install_spconv - if not install_spconv(): - raise RuntimeError("Failed to install spconv") def clone_or_update_read_dependency(dependency_url, dependency_dir): if os.path.exists(dependency_dir): diff --git a/_Pre_Builds/_Build_Scripts/build_config.yaml b/_Pre_Builds/_Build_Scripts/build_config.yaml index a7294fb..ebdca8f 100644 --- a/_Pre_Builds/_Build_Scripts/build_config.yaml +++ b/_Pre_Builds/_Build_Scripts/build_config.yaml @@ -13,7 +13,10 @@ libs_dir_name: "_Libs" # Folder used to store built wheels wheels_dir_name: "_Build_Wheels" -build_base_packages: ["torch", "torchvision", "xformers"] +build_base_packages: ["torch", "torchvision", "torchaudio", "xformers"] + +# Packages requiring special install flags (like --no-build-isolation) +isolated_packages: ["diso"] # Platform-specific packages platform_packages: @@ -40,10 +43,18 @@ remote_packages: version: "0.22.0" url: "https://download.pytorch.org/whl/${cuda_version}" + torchaudio: + version: "2.7.0" + url: "https://download.pytorch.org/whl/${cuda_version}" + xformers: version: "0.0.30" url: "https://download.pytorch.org/whl/${cuda_version}" torch-scatter: url_option: "--find-links" - url: "https://data.pyg.org/whl/torch-${remote_packages.torch.version}+${cuda_version}.html" \ No newline at end of file + url: "https://data.pyg.org/whl/torch-${remote_packages.torch.version}+${cuda_version}.html" + + diso: + url: "git+https://github.com/SarahWeiii/diso.git#egg=diso" + install_flags: ["--no-build-isolation"] \ No newline at end of file diff --git a/_Pre_Builds/_Build_Scripts/build_utils.py b/_Pre_Builds/_Build_Scripts/build_utils.py index 4e756c4..213bb9b 100644 --- a/_Pre_Builds/_Build_Scripts/build_utils.py +++ b/_Pre_Builds/_Build_Scripts/build_utils.py @@ -250,68 +250,31 @@ def install_platform_packages(): print(f"Installing platform package {package}...") subprocess.run([PYTHON_PATH, "-s", "-m", "pip", "install", package]) -def install_spconv(): - """Simple spconv installation with correct CUDA version""" - # Check if spconv is already installed and working - try: - import spconv.core_cc - print("spconv is already installed and working") - return True - except ImportError: - pass - - # Get CUDA version mapping - if not hasattr(build_config, 'spconv_cuda_mapping'): - print("No spconv_cuda_mapping in config, skipping spconv installation") - return True - - # Fix CUDA version parsing: cu128 -> 12.8, cu121 -> 12.1, cu118 -> 11.8 - if len(CUDA_VERSION) >= 5: # e.g., cu128, cu121 - major = CUDA_VERSION[2:-1] # cu128 -> 12, cu121 -> 12, cu118 -> 11 - minor = CUDA_VERSION[-1] # cu128 -> 8, cu121 -> 1, cu118 -> 8 - cuda_version_for_lookup = f"{major}.{minor}" - else: - print(f"Invalid CUDA_VERSION format: {CUDA_VERSION}") - return False - - print(f"Detected CUDA version: {cuda_version_for_lookup}") - - cuda_suffix = build_config.spconv_cuda_mapping.get(cuda_version_for_lookup) - - if not cuda_suffix: - print(f"No spconv mapping for CUDA {cuda_version_for_lookup}, skipping") - return True - - spconv_package = f"spconv-{cuda_suffix}" - print(f"Installing {spconv_package}...") - - result = subprocess.run( - [PYTHON_PATH, "-m", "pip", "install", spconv_package], - text=True, capture_output=True - ) - - if result.returncode != 0: - print(f"Failed to install {spconv_package}: {result.stderr}") - return False - - # Verify installation - try: - import spconv.core_cc - print(f"Successfully installed and verified {spconv_package}") - return True - except ImportError as e: - print(f"spconv installed but verification failed: {e}") - return False - -def check_spconv_after_wheels(): - """Check if spconv works after wheels installation""" - try: - import spconv.core_cc - print("spconv is working after wheels installation") - return True - except ImportError: - print("spconv not working, will install from mapping") - return False +def install_isolated_packages(package_names): + """Install packages with special flags like --no-build-isolation""" + for package_name in package_names: + if package_name in build_config.remote_packages: + package_attr = build_config.remote_packages[package_name] + + # Check if package is already installed + if is_package_installed(package_name): + print(f"Package {package_name} is already installed, skipping...") + continue + + print(f"Installing isolated package {package_name}...") + + if hasattr(package_attr, "url"): + # Build command with install flags + cmd = [PYTHON_PATH, "-s", "-m", "pip", "install"] + if hasattr(package_attr, "install_flags"): + cmd.extend(package_attr.install_flags) + cmd.append(package_attr.url) + + subprocess.run(cmd) + else: + print(f"No URL found for isolated package {package_name}") + else: + print(f"Isolated package {package_name} not found in config") def wheels_dir_exists_and_not_empty(builds_dir): if not os.path.exists(builds_dir): diff --git a/install.py b/install.py index 96fe516..4001332 100644 --- a/install.py +++ b/install.py @@ -22,8 +22,7 @@ try: git_folder_parallel, install_remote_packages, install_platform_packages, - install_spconv, - check_spconv_after_wheels, + install_isolated_packages, wheels_dir_exists_and_not_empty, build_config, PYTHON_PATH, @@ -112,6 +111,10 @@ try: install_remote_packages(build_config.build_base_packages) install_platform_packages() + # Install packages requiring special flags (like --no-build-isolation) + if hasattr(build_config, 'isolated_packages'): + install_isolated_packages(build_config.isolated_packages) + # Check and install build tools if needed cstr("Checking build tools...").msg.print() build_tools = ["ninja", "cmake", "setuptools", "wheel"] @@ -130,7 +133,6 @@ try: raise RuntimeError(f"Failed to install {tool}") # Main installation logic - spconv_success = False wheels_success = False # Get the target remote pre-built wheels directory name and path @@ -143,41 +145,16 @@ try: # Step 1: Try wheels first wheels_success = try_wheels_first_approach() - # Step 2: Check if spconv works after wheels, install if needed - if wheels_success and check_spconv_after_wheels(): - spconv_success = True - else: - # Install spconv using CUDA mapping - spconv_success = install_spconv() - - # Step 3: If wheels failed, try building + # Step 2: If wheels failed, try building if not wheels_success: cstr("Wheels installation failed, trying to build from source...").warning.print() if try_auto_build_all(builds_dir): install_local_wheels(builds_dir) wheels_success = True cstr("Successfully built and installed wheels").msg.print() - # Check spconv again after building - if not check_spconv_after_wheels(): - spconv_success = install_spconv() - else: - spconv_success = True else: cstr("Building wheels also failed").error.print() - # Final verification - if not install_spconv(): - raise RuntimeError("spconv failed final verification. Please check the installation.") - - if spconv_success: - cstr("Successfully installed spconv").msg.print() - if wheels_success: - cstr("Successfully installed all available wheels").msg.print() - else: - cstr("Note: Some wheels could not be installed, but this is not critical").warning.print() - else: - raise RuntimeError("Failed to install spconv") - # Download python cpp source files for current python environment remote_pycpp_dir_name = f"_Python_Source_cpp/{PYTHON_VERSION}" python_root_dir = dirname(PYTHON_PATH) diff --git a/requirements.txt b/requirements.txt index a5aad40..8b7a762 100644 --- a/requirements.txt +++ b/requirements.txt @@ -56,7 +56,6 @@ libigl pyvista pymeshfix igraph -git+https://github.com/SarahWeiii/diso.git#egg=diso open3d # configs & extra