mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-18 13:53:44 +08:00
Ability to use vanilla pytorch instead of tcnn for Nerfacto (#1936)
* started a package to easily swap out tcnn for pytorch * trains with pytorch and not tcnn * cleaned up imports * making it easy to install on mac * removed/reverted files * merged main * reverted changes * updating config * starting to add nerfacto to tests * fixxing default value * fixed default implementation * defaults to torch if tcnn and not installed * update log * add comment * resolved pr comments * fix * update default --------- Co-authored-by: Ethan Weber <ethanweber@eecs-128-32-175-250.dhcp.berkeley.edu>
This commit is contained in:
1 parent
400ab5a313
commit
bb6925bac6
19 files changed
+295
-296
No files matched your search
@@ -119,7 +119,9 @@ class Trainer:
|
||||
self.config = config
|
||||
self.local_rank = local_rank
|
||||
self.world_size = world_size
|
||||
self.device: TORCH_DEVICE = "cpu" if world_size == 0 else f"cuda:{local_rank}"
|
||||
self.device: TORCH_DEVICE = config.machine.device_type
|
||||
if self.device == "cuda":
|
||||
self.device += f":{local_rank}"
|
||||
self.mixed_precision: bool = self.config.mixed_precision
|
||||
self.use_grad_scaler: bool = self.mixed_precision or self.config.use_grad_scaler
|
||||
self.training_state: Literal["training", "paused", "completed"] = "training"
|
||||
@@ -459,9 +461,10 @@ class Trainer:
|
||||
"""
|
||||
|
||||
self.optimizers.zero_grad_all()
|
||||
cpu_or_cuda_str: str = self.device.split(":")[0]
|
||||
|
||||
with torch.autocast(device_type=cpu_or_cuda_str, enabled=self.mixed_precision):
|
||||
device_type: str = self.device.split(":")[0] if "cuda" in self.device else "cpu"
|
||||
|
||||
with torch.autocast(device_type=device_type, enabled=self.mixed_precision):
|
||||
_, loss_dict, metrics_dict = self.pipeline.get_train_loss_dict(step=step)
|
||||
loss = functools.reduce(torch.add, loss_dict.values())
|
||||
self.grad_scaler.scale(loss).backward() # type: ignore
|
||||
|
||||
Reference in new issue
Block a user