Stability-AI / stable-fast-3d

SF3D: Stable Fast 3D Mesh Reconstruction with UV-unwrapping and Illumination Disentanglement
https://stable-fast-3d.github.io
Other
975 stars 86 forks source link

Windows issue: _slangtorch_texture_baker error when starting gradio #13

Closed SoftologyPro closed 2 weeks ago

SoftologyPro commented 1 month ago

When I start gradio_app.py I get this

Traceback (most recent call last):
  File "D:\Tests\StableFast3D\stable-fast-3d\gradio_app.py", line 43, in <module>
    model = SF3D.from_pretrained(
  File "D:\Tests\StableFast3D\stable-fast-3d\sf3d\system.py", line 89, in from_pretrained
    model = cls(cfg)
  File "D:\Tests\StableFast3D\stable-fast-3d\sf3d\models\utils.py", line 29, in __init__
    self.configure(*args, **kwargs)
  File "D:\Tests\StableFast3D\stable-fast-3d\sf3d\system.py", line 139, in configure
    self.baker = TextureBaker()
  File "D:\Tests\StableFast3D\stable-fast-3d\sf3d\texture_baker.py", line 13, in __init__
    self.baker = slangtorch.loadModule(
  File "D:\Tests\StableFast3D\stable-fast-3d\venv\lib\site-packages\slangtorch\slangtorch.py", line 617, in loadModule
    rawModule = _loadModule(fileName, moduleName, buildDir, options, sourceDir=outputFolder, verbose=verbose, includePaths=includePaths, dryRun=False)
  File "D:\Tests\StableFast3D\stable-fast-3d\venv\lib\site-packages\slangtorch\slangtorch.py", line 536, in _loadModule
    slangLib, metadata = compileAndLoadModule(
  File "D:\Tests\StableFast3D\stable-fast-3d\venv\lib\site-packages\slangtorch\slangtorch.py", line 427, in compileAndLoadModule
    slangLib = _compileAndLoadModule(metadata, sources, moduleName, buildDir, slangSourceDir, verbose)
  File "D:\Tests\StableFast3D\stable-fast-3d\venv\lib\site-packages\slangtorch\slangtorch.py", line 466, in _compileAndLoadModule
    return jit_compile(
  File "D:\Tests\StableFast3D\stable-fast-3d\venv\lib\site-packages\slangtorch\util\compile.py", line 93, in jit_compile
    return _import_module_from_library(name, build_directory, is_python_module)
  File "D:\Tests\StableFast3D\stable-fast-3d\venv\lib\site-packages\torch\utils\cpp_extension.py", line 2132, in _import_module_from_library
    module = importlib.util.module_from_spec(spec)
  File "<frozen importlib._bootstrap>", line 571, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1176, in create_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
ImportError: DLL load failed while importing _slangtorch_texture_baker_44136fa355b3678a: The specified module could not be found.

Any ideas?

FishGPT commented 1 month ago

You can try reinstall gradio, before: pip cache purge

945222256 commented 1 month ago

cf same issue

945222256 commented 1 month ago

You can try reinstall gradio, before: pip cache purge

not working.

python run.py demo_files/examples/chair1.png --output-dir output/ get same feedback

ouceduxzk commented 1 month ago

the slangtroch dont have mac version, it has both windows and unix library, but lacks mac verison, that's why it fails on my mac

SoftologyPro commented 1 month ago

I am running this on Windows.

geoffreyvilcot commented 1 month ago

I have the same issue on windows, I fix it by installing the right version of pytorch according to my cuda version.

clearsitedesigns commented 1 month ago

Same issue on a mac 1pro max

jammm commented 1 month ago

There's no mac support yet.

SoftologyPro commented 1 month ago

OK, got it working here. For other Windows users who want to run locally, here is an install.bat that you save and run inside an empty diretcory. The directory cannot contain spaces.

@echo off

echo *** %time% *** Deleting stable-fast-3d directory if it exists
if exist stable-fast-3d\. rd /S /Q stable-fast-3d

echo *** %time% *** Cloning stable-fast-3d repository
git clone https://github.com/Stability-AI/stable-fast-3d
cd stable-fast-3d

echo *** %time% *** Creating venv
python -m venv venv

echo *** %time% *** Activating venv
call venv\scripts\activate.bat

echo *** %time% *** Installing requirments
python -m pip install --upgrade pip
pip install wheel
pip install matplotlib==3.9.0
pip install -r requirements.txt
pip install -r requirements-demo.txt
pip install --upgrade huggingface_hub

echo *** %time% *** Patching xformers
pip uninstall -y xformers
pip install --no-cache-dir --ignore-installed --force-reinstall --no-warn-conflicts xformers==0.0.27.post2 --index-url https://download.pytorch.org/whl/cu121

echo *** %time% *** Installing GPU torch
pip uninstall -y torch
pip uninstall -y torch
pip install --no-cache-dir --ignore-installed --force-reinstall --no-warn-conflicts torch==2.4.0+cu121 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121

call venv\scripts\deactivate.bat
cd ..
echo *** %time% *** Finished stable-fast-3d install
echo.
echo Check the stats for any errors.  Do not assume it worked.
pause

Once installed, save this run.bat in the same directory as install.bat, edit your hugging face read token into line 5, and run it to start the gradio UI.

@echo off
cls
cd stable-fast-3d
call venv\scripts\activate.bat
huggingface-cli login --token <PUT YOUR HUGGINGFACE READ TOKEN HERE>
python  -X utf8 gradio_app.py
call venv\scripts\deactivate.bat
cd..

image

th3redmage commented 1 month ago

adding X utf8 before the gradio for me was key to making this work, thank you

vork commented 2 weeks ago

We've recently replaced the baker from slang to a native CUDA/CPP/Metal one. Please pull the changes and test again.