fix(splatfacto): replace .cuda() with .to(self.device) for MPS support#3750
Open
ChrisMOxon wants to merge 1 commit intonerfstudio-project:mainfrom
Open
fix(splatfacto): replace .cuda() with .to(self.device) for MPS support#3750ChrisMOxon wants to merge 1 commit intonerfstudio-project:mainfrom
ChrisMOxon wants to merge 1 commit intonerfstudio-project:mainfrom
Conversation
…MPS support
Two lines in splatfacto.py use .cuda() directly instead of the model's
device property, causing crashes on non-CUDA systems (Apple Silicon MPS,
CPU-only machines) with "Torch not compiled with CUDA enabled".
Replace with .to(self.device) which correctly resolves to cuda:N on NVIDIA,
mps:0 on Apple Silicon, or cpu as appropriate.
Tested on M2 Max (MPS) — model initializes and runs forward pass successfully.
CUDA compatibility preserved: .to(self.device) resolves to cuda:N on CUDA systems.
Discovered and benchmarked by an autonomous Claude Code agent ("Ralph")
optimizing a 3D scanning pipeline for Apple Silicon.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.cuda()calls insplatfacto.pywith.to(self.device)AssertionError: Torch not compiled with CUDA enabled.to(self.device)resolves tocuda:Nwhen CUDA is activeChanges
torch.zeros(...).float().cuda()→.float().to(self.device)(SH coefficient init)camera.get_intrinsics_matrices().cuda()→.to(self.device)(camera intrinsics)Testing
.cuda()calls in splatfacto.pyContext
Discovered by an autonomous Claude Code agent ("Ralph") while optimizing a 3D scanning pipeline for Apple Silicon. The agent audited all nerfstudio model code for CUDA-only patterns and identified these two lines as the only hardcoded
.cuda()calls in splatfacto.🤖 Generated with Claude Code