Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ns-train splatfacto fails to run on Apple Silicon, nerfacto works ok #3290

Closed
Itox001 opened this issue Jul 6, 2024 · 3 comments
Closed

Comments

@Itox001
Copy link

Itox001 commented Jul 6, 2024

Describe the bug
I have an M3 and could successfully install nerfstudio, and (albeit slowly) train my first model using nerfacto. The problem is that when I try to use splatfacto, it exceptions out, saying:

File "/Users/user/dev/oss/nerfstudio/nerfstudio/models/splatfacto.py", line 229, in populate_modules
shs = torch.zeros((self.seed_points[1].shape[0], dim_sh, 3)).float().cuda()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniconda/base/envs/nerfstudio/lib/python3.11/site-packages/torch/cuda/init.py", line 289, in _lazy_init
raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled

Naturally my torch does not have CUDA enabled since there is no Nvidia GPU. I tried with --machine.device-type=cpu, with the same result.

Command that works:
ns-train nerfacto --machine.device-type=mps --max-num-iterations 2000 --data /Users/user/dev/oss/nerfstudio/data/nerfstudio/desk

Command that produces the above exception:
ns-train splatfacto --machine.device-type=mps --max-num-iterations 2000 --data /Users/user/dev/oss/nerfstudio/data/nerfstudio/desk

Additional context
nerfstudio 1.1.3
torch 2.1.2
torchvision 0.16.2

Thanks!

@maturk
Copy link
Collaborator

maturk commented Jul 6, 2024

Splatfacto requires CUDA for training right now. If you are very keen and willing to hack away, it is in theory possible to train with cpu torch right now using the _torch_impl from the cuda backend but its not supported out of the box.

@Itox001
Copy link
Author

Itox001 commented Jul 6, 2024

Thanks for the quick response @maturk ! I see, support for MPS across the ecosystem seems to be evolving quickly now, there is a lot of active development, but there is still a lot of ground to cover.

One last question realted to this topic. There are several improvements for MPS on the latest PyTorch versions, but when I tried to upgrade it to latest, I could not longer run ns-train. Do you think it is hard to resolve those conflicts? The error thrown is a bit cryptic:

[1] 27951 segmentation fault PYTORCH_ENABLE_MPS_FALLBACK=1 ns-train nerfacto --machine.device-type=mps

Without the fallback flag:

OMP: Error #179: Function pthread_mutex_init failed:
OMP: System error #22: Invalid argument
[1] 28347 abort ns-train nerfacto --machine.device-type=cpu --max-num-iterations 2000 --data

@Itox001
Copy link
Author

Itox001 commented Jul 22, 2024

Original question answered, no need to keep open.

@Itox001 Itox001 closed this as completed Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants