Skip to content

Commit 1b366bc

Browse files
committed
updated deprecated methods
1 parent 5003d0e commit 1b366bc

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

nerfstudio/engine/trainer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ def _load_checkpoint(self) -> None:
429429
load_step = sorted(int(x[x.find("-") + 1 : x.find(".")]) for x in os.listdir(load_dir))[-1]
430430
load_path: Path = load_dir / f"step-{load_step:09d}.ckpt"
431431
assert load_path.exists(), f"Checkpoint {load_path} does not exist"
432-
loaded_state = torch.load(load_path, map_location="cpu")
432+
loaded_state = torch.load(load_path, map_location="cpu", weights_only=False)
433433
self._start_step = loaded_state["step"] + 1
434434
# load the checkpoints for pipeline, optimizers, and gradient scalar
435435
self.pipeline.load_pipeline(loaded_state["pipeline"], loaded_state["step"])
@@ -440,7 +440,7 @@ def _load_checkpoint(self) -> None:
440440
CONSOLE.print(f"Done loading Nerfstudio checkpoint from {load_path}")
441441
elif load_checkpoint is not None:
442442
assert load_checkpoint.exists(), f"Checkpoint {load_checkpoint} does not exist"
443-
loaded_state = torch.load(load_checkpoint, map_location="cpu")
443+
loaded_state = torch.load(load_checkpoint, map_location="cpu", weights_only=False)
444444
self._start_step = loaded_state["step"] + 1
445445
# load the checkpoints for pipeline, optimizers, and gradient scalar
446446
self.pipeline.load_pipeline(loaded_state["pipeline"], loaded_state["step"])

nerfstudio/field_components/activations.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@
2222
from jaxtyping import Float
2323
from torch import Tensor
2424
from torch.autograd import Function
25-
from torch.cuda.amp import custom_bwd, custom_fwd
25+
from torch.amp import custom_bwd, custom_fwd
2626

2727

2828
class _TruncExp(Function):
2929
# Implementation from torch-ngp:
3030
# https://github.com/ashawkey/torch-ngp/blob/93b08a0d4ec1cc6e69d85df7f0acdfb99603b628/activation.py
3131
@staticmethod
32-
@custom_fwd(cast_inputs=torch.float32)
32+
@custom_fwd(cast_inputs=torch.float32, device_type='cuda')
3333
def forward(ctx, x):
3434
ctx.save_for_backward(x)
3535
return torch.exp(x)
3636

3737
@staticmethod
38-
@custom_bwd
38+
@custom_bwd(device_type='cuda')
3939
def backward(ctx, g):
4040
x = ctx.saved_tensors[0]
4141
return g * torch.exp(x.clamp(-15, 15))

nerfstudio/scripts/downloads/download_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ def download(self, save_dir: Path) -> None:
514514
split_filepaths = []
515515
for image_path, new_image_path in copied_images.items():
516516
metadata_path = image_path.parent.parent / "metadata" / f"{image_path.stem}.pt"
517-
metadata = torch.load(metadata_path, map_location="cpu")
517+
metadata = torch.load(metadata_path, map_location="cpu", weights_only=False)
518518
c2w = torch.eye(4)
519519
c2w[:3] = metadata["c2w"]
520520
file_path = str(Path("images") / f"{new_image_path.name}")

nerfstudio/utils/eval_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def eval_load_checkpoint(config: TrainerConfig, pipeline: Pipeline) -> Tuple[Pat
5959
load_step = config.load_step
6060
load_path = config.load_dir / f"step-{load_step:09d}.ckpt"
6161
assert load_path.exists(), f"Checkpoint {load_path} does not exist"
62-
loaded_state = torch.load(load_path, map_location="cpu")
62+
loaded_state = torch.load(load_path, map_location="cpu", weights_only=False)
6363
pipeline.load_pipeline(loaded_state["pipeline"], loaded_state["step"])
6464
CONSOLE.print(f":white_check_mark: Done loading checkpoint from {load_path}")
6565
return load_path, load_step

0 commit comments

Comments
 (0)