@@ -448,6 +448,24 @@ def install_pytorch_with_cuda(self):
448448
449449 self .run_pip_command (pytorch_cmd_25 , f"Installing PyTorch 2.5+ ({ cuda_version } support)" )
450450
451+ def verify_python_import (self , module_name : str ) -> bool :
452+ """Verify a module imports in the target Python environment."""
453+ try :
454+ result = subprocess .run (
455+ [sys .executable , "-c" , f"import { module_name } " ],
456+ capture_output = True ,
457+ text = True ,
458+ timeout = 30 ,
459+ )
460+ if result .returncode == 0 :
461+ return True
462+ error_text = (result .stderr or result .stdout or "unknown import failure" ).strip ()
463+ self .log (f"Python import check failed for { module_name } : { error_text } " , "WARNING" )
464+ return False
465+ except Exception as e :
466+ self .log (f"Python import check failed for { module_name } : { e } " , "WARNING" )
467+ return False
468+
451469 def check_package_installed (self , package_spec ):
452470 """Check if a package meets the version requirement"""
453471 try :
@@ -721,12 +739,22 @@ def install_rvc_dependencies(self):
721739
722740 # Try GPU installation first with --no-deps to prevent numpy downgrade
723741 self .run_pip_command (["install" , "--no-deps" , faiss_gpu_package ], f"Installing { faiss_gpu_package } for GPU acceleration (--no-deps)" )
724- self .log ("faiss-gpu installed with --no-deps - RVC will use GPU acceleration without downgrading numpy" , "SUCCESS" )
742+ if self .verify_python_import ("faiss" ):
743+ self .log ("faiss-gpu import test passed" , "SUCCESS" )
744+ else :
745+ self .log ("faiss-gpu package installed but import failed - falling back to CPU version" , "WARNING" )
746+ faiss_gpu_name = faiss_gpu_package .split (">=" )[0 ]
747+ self .run_pip_command (["uninstall" , "-y" , faiss_gpu_name ], f"Removing broken { faiss_gpu_name } " , ignore_errors = True )
748+ self .run_pip_command (["install" , "--no-deps" , "faiss-cpu>=1.7.4" ], "Installing faiss-cpu (fallback, --no-deps)" )
749+ if not self .verify_python_import ("faiss" ):
750+ self .log ("faiss-cpu installed but faiss import still failed" , "WARNING" )
725751
726752 except subprocess .CalledProcessError :
727753 # GPU installation failed - fallback to CPU
728754 self .log ("faiss-gpu installation failed - falling back to CPU version" , "WARNING" )
729755 self .run_pip_command (["install" , "--no-deps" , "faiss-cpu>=1.7.4" ], "Installing faiss-cpu (fallback, --no-deps)" )
756+ if not self .verify_python_import ("faiss" ):
757+ self .log ("faiss-cpu installed but faiss import still failed" , "WARNING" )
730758 else :
731759 # Windows or no CUDA - use reliable CPU version
732760 if self .is_windows and cuda_version != "cpu" :
@@ -739,6 +767,9 @@ def install_rvc_dependencies(self):
739767 else :
740768 self .run_pip_command (["install" , "--no-deps" , "faiss-cpu>=1.7.4" ], "Installing faiss-cpu for RVC voice matching (--no-deps)" )
741769
770+ if not self .verify_python_import ("faiss" ):
771+ self .log ("faiss-cpu is installed but faiss import still failed" , "WARNING" )
772+
742773 def install_numpy_with_constraints (self ):
743774 """Install numpy with version constraints for compatibility"""
744775 self .log ("Checking numpy compatibility" , "INFO" )
0 commit comments