VAST-AI-Research / TripoSR

MIT License
4.32k stars 496 forks source link

AttributeError: module 'torchmcubes_module' has no attribute 'mcubes_cuda' #7

Open chrisbward opened 6 months ago

chrisbward commented 6 months ago
(.venv) ➜  TripoSR git:(main) python run.py examples/chair.png --output-dir output/
2024-03-05 03:56:32,235 - INFO - Initializing model ...
/media/user/home/Tools/06_MachineLearning/24_3D/TripoSR/.venv/lib/python3.9/site-packages/transformers/utils/generic.py:441: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.
  _torch_pytree._register_pytree_node(
/media/user/home/Tools/06_MachineLearning/24_3D/TripoSR/.venv/lib/python3.9/site-packages/transformers/utils/generic.py:309: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.
  _torch_pytree._register_pytree_node(
2024-03-05 03:56:35,758 - INFO - Initializing model finished in 3523.10ms.
2024-03-05 03:56:35,758 - INFO - Processing images ...
2024-03-05 03:56:36,412 - INFO - Processing images finished in 654.22ms.
2024-03-05 03:56:36,412 - INFO - Running image 1/1 ...
2024-03-05 03:56:36,413 - INFO - Running model ...
2024-03-05 03:56:37,038 - INFO - Running model finished in 625.03ms.
2024-03-05 03:56:37,038 - INFO - Exporting mesh ...
Traceback (most recent call last):
  File "/media/user/home/Tools/06_MachineLearning/24_3D/TripoSR/run.py", line 154, in <module>
    meshes = model.extract_mesh(scene_codes)
  File "/media/user/home/Tools/06_MachineLearning/24_3D/TripoSR/tsr/system.py", line 185, in extract_mesh
    v_pos, t_pos_idx = self.isosurface_helper(-(density - threshold))
  File "/media/user/home/Tools/06_MachineLearning/24_3D/TripoSR/.venv/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/media/user/home/Tools/06_MachineLearning/24_3D/TripoSR/.venv/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
    return forward_call(*args, **kwargs)
  File "/media/user/home/Tools/06_MachineLearning/24_3D/TripoSR/tsr/models/isosurface.py", line 45, in forward
    v_pos, t_pos_idx = self.mc_func(level.detach(), 0.0)
  File "/media/user/home/Tools/06_MachineLearning/24_3D/TripoSR/.venv/lib/python3.9/site-packages/torchmcubes/__init__.py", line 12, in marching_cubes
    return mc.mcubes_cuda(vol, thresh)
AttributeError: module 'torchmcubes_module' has no attribute 'mcubes_cuda'

This is from an virtualenv install for Python 3.9 on Ubuntu 20.04

chrisbward commented 6 months ago

no dice - I tried 3.8, 3.9 and 3.10 virtual environments

pookiefoof commented 6 months ago

Seems the torchmcubes was not properly installed. Could you check the torch version and run pip install git+https://github.com/tatsy/torchmcubes.git and try again?

chrisbward commented 6 months ago
pip install torch==2.2.1 --extra-index-url https://download.pytorch.org/whl/cu118

as per the Dockerfile on HF repo, and also;

pip install torch  --extra-index-url https://download.pytorch.org/whl/cu121

I've given up, will probably need to run this in a Docker container to get it to work

chrisbward commented 6 months ago

https://huggingface.co/spaces/stabilityai/TripoSR/blob/main/Dockerfile

chrisbward commented 6 months ago

Screenshot from 2024-03-05 06-20-55 wrapped it in the dockerfile and shared a couple of the volumes - shame it downloads the model every time I fire up the container - I might pull that out - nice work!

yuhuangyue commented 6 months ago

How to sovle it if I don't want to run in Docker?

mrbid commented 6 months ago
#if torch.cuda.is_available():
#    device = "cuda:0"
#
#else:
device = "cpu"

It will then use the CPU and not complain about CUDA

JasonSongPeng commented 6 months ago
#if torch.cuda.is_available():
#    device = "cuda:0"
#
#else:
device = "cpu"

It will then use the CPU and not complain about CUDA

Could you please inform me that which file shoud I modify?

mrbid commented 6 months ago
#if torch.cuda.is_available():
#    device = "cuda:0"
#
#else:
device = "cpu"

It will then use the CPU and not complain about CUDA

Could you please inform me that which file shoud I modify?

gradio_app.py

jloveric commented 6 months ago

Probably 'WITH_CUDA' is not defined https://github.com/tatsy/torchmcubes/blob/master/cxx/mcubes.cpp#L36

bennyguo commented 6 months ago

Please refer to this answer to fix this problem. Have fun playing with TripoSR!

MachineWei commented 6 months ago

https://huggingface.co/spaces/stabilityai/TripoSR/blob/main/Dockerfile @chrisbward the dockerfile is 404, could you please pull it out, THX