VAST-AI-Research / TripoSR

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pip install git+https://github.com/tatsy/torchmcubes.git --> error

mirinaeman opened this issue · comments

Building wheels for collected packages: torchmcubes
Building wheel for torchmcubes (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [20 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-cpython-312
creating build\lib.win-amd64-cpython-312\torchmcubes
copying torchmcubes_init_.py -> build\lib.win-amd64-cpython-312\torchmcubes
running build_ext
C:\Users\TF_USER\AppData\Local\Programs\Python\Python312\Lib\site-packages\torch\utils\cpp_extension.py:381: UserWarning: Error checking compiler version for cl: [WinError 2] 지정된 파일을 찾을 수 없습니다
warnings.warn(f'Error checking compiler version for {compiler}: {error}')
building 'torchmcubes_module' extension
CUDA environment was not successfully loaded!
Build only CPU module!
running bdist_wheel
running build
running build_py
copying torchmcubes_init_.py -> build\lib.win-amd64-cpython-312\torchmcubes
running build_ext
building 'torchmcubes_module' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for torchmcubes
Running setup.py clean for torchmcubes
Failed to build torchmcubes
ERROR: Could not build wheels for torchmcubes, which is required to install pyproject.toml-based projects

pls. solve the problem

If you're on Windows, you need some build tools to install torchmcubes. Install here: https://visualstudio.microsoft.com/visual-cpp-build-tools/

commented

HI i have the same error but its on mac how do u think i can solve it??

@jannathshaik123 Hi are you sure the error message is the same? Theoretically, mac wouldn't require "Microsoft Visual C++". Could you please provide the exact error message?

HI i have the same error but its on mac how do u think i can solve it??

On Mac you probably need xcode-select --install to install Xcode command line tools to build torchmcubes. https://mac.install.guide/commandlinetools/4

If you're on Windows, you need some build tools to install torchmcubes. Install here: https://visualstudio.microsoft.com/visual-cpp-build-tools/

I have the same issue on Linux server, can I solve it by this method?

If you're on Windows, you need some build tools to install torchmcubes. Install here: https://visualstudio.microsoft.com/visual-cpp-build-tools/

I have the same issue on Linux server, can I solve it by this method?

Could you provide your error message on Linux? On Linux it needs different toolchains.

commented

i made a new python environment and this the error i got
Screenshot 2024-03-14 at 9 20 52 AM

commented

File "", line 2, in
ModuleNotFoundError: No module named 'torch'
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

i have already install torch and its shown in my pip list but however this is still not running.

commented

HI i have the same error but its on mac how do u think i can solve it??

On Mac you probably need xcode-select --install to install Xcode command line tools to build torchmcubes. https://mac.install.guide/commandlinetools/4

i already have xcode preinstalled

@jannathshaik123 same issue on mac - xcode installed, torch installed - I get the same as #48 (comment)

How I resolved this on mac

git clone https://github.com/VAST-AI-Research/TripoSR.git .

go to the directory

cd ./TripoSR

start virtual env - i use pyenv

pyenv virtualenv triposr

activate

pyenv activate triposr

install torch

pip3 install torch torchvision torchaudio

setuptools

pip install --upgrade setuptools

requirements

 pip install -r requirements.txt

python run.py examples/chair.png --output-dir output/ should now work

Windows here, modified steps from @raverydavis to:
Open the folder you want to use for the repo
Type "cmd" into the address bar (opens command prompt in current location)

clone repo

git clone https://github.com/VAST-AI-Research/TripoSR.git

change dir

cd TripoSR

make python virtual environment

python -m venv venv

activate venv

venv\Scripts\activate.bat

install torch

pip install torch torchvision torchaudio

setuptools

pip install --upgrade setuptools

requirements

pip install -r requirements.txt

launch gui (downloads model on first run, 1.68GB)

python gradio_app.py

You can then open your browser to http://127.0.0.1:7860 to use the app. Launch with "--port" to use a different port, such as 7865: python gradio_app.py --port 7865

I resolve it on windows by cloning locally https://github.com/tatsy/torchmcubes and running the
python setup.py build_ext -i
After that I added the compiled module, i.e the torchmcubes_module.****.pyd file into the %PYTHONPATH%

The modified the tsr/models/isosurface.py by adding the following lines
instead of from torchmcubes import marching_cubes

import torchmcubes_module as mc


def marching_cubes(vol, thresh):
    """
    vol: 3D torch tensor
    thresh: threshold
    """

    if vol.is_cuda:
        return mc.mcubes_cuda(vol, thresh)
    else:
        return mc.mcubes_cpu(vol, thresh)


def grid_interp(vol, points):
    """
    Interpolate volume data at given points

    Inputs:
        vol: 4D torch tensor (C, Nz, Ny, Nx)
        points: point locations (Np, 3)
    Outputs:
        output: interpolated data (Np, C)    
    """

    if vol.is_cuda:
        return mc.grid_interp_cuda(vol, points)
    else:
        return mc.grid_interp_cpu(vol, points)

the lines are from the https://github.com/tatsy/torchmcubes/blob/master/torchmcubes/init.py because those module are not exported when the repository is build.

(note: I am novice at python)

I resolve it on windows by cloning locally https://github.com/tatsy/torchmcubes and running the python setup.py build_ext -i After that I added the compiled module, i.e the torchmcubes_module.****.pyd file into the %PYTHONPATH%

The modified the tsr/models/isosurface.py by adding the following lines instead of from torchmcubes import marching_cubes

import torchmcubes_module as mc


def marching_cubes(vol, thresh):
    """
    vol: 3D torch tensor
    thresh: threshold
    """

    if vol.is_cuda:
        return mc.mcubes_cuda(vol, thresh)
    else:
        return mc.mcubes_cpu(vol, thresh)


def grid_interp(vol, points):
    """
    Interpolate volume data at given points

    Inputs:
        vol: 4D torch tensor (C, Nz, Ny, Nx)
        points: point locations (Np, 3)
    Outputs:
        output: interpolated data (Np, C)    
    """

    if vol.is_cuda:
        return mc.grid_interp_cuda(vol, points)
    else:
        return mc.grid_interp_cpu(vol, points)

the lines are from the https://github.com/tatsy/torchmcubes/blob/master/torchmcubes/init.py because those module are not exported when the repository is build.

(note: I am novice at python)

it works ! Thanks

스크린샷 2024-06-19 160556
how can i fix this in linux?