mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-04 06:49:13 +08:00
Set up profiler and moved stats tracker to its own class; set up configurables for stats tracker and profiler (#42)
* added skeleton for terminal logger * done skeleton terminal writer logic... todo: actual calls to the write classes * moved lambda to top function * added logic to support timing * prettier printing * prettier printing * lint * separated out timing and other stats variables. printing in dict format * keeping logging history and wiping rest * updated logic to calculate total times instead of average times * made stats tracker configurable * moved stats tracker and profiler to own class file; implemented basic functionality for profiler * lint removing duplicate function
This commit is contained in:
1 parent
2e350c148f
commit
609fcb04f6
7 files changed
+270
-144
No files matched your search
@@ -13,13 +13,14 @@ from omegaconf import DictConfig
|
||||
from torch.nn.parallel import DistributedDataParallel as DDP
|
||||
from torch.utils.data import DataLoader
|
||||
|
||||
from mattport.nerf.dataset.image_dataset import ImageDataset, collate_batch
|
||||
from mattport.nerf.dataset.collate import CollateIterDataset, collate_batch_size_one
|
||||
from mattport.nerf.dataset.image_dataset import ImageDataset, collate_batch
|
||||
from mattport.nerf.dataset.utils import get_dataset_inputs
|
||||
from mattport.nerf.metrics import get_psnr
|
||||
from mattport.nerf.optimizers import Optimizers
|
||||
from mattport.utils import profiler
|
||||
from mattport.utils.decorators import check_main_thread
|
||||
from mattport.utils.io import Stats, StatsTracker
|
||||
from mattport.utils.stats_tracker import Stats, StatsTracker
|
||||
from mattport.utils.writer import TensorboardWriter
|
||||
|
||||
logging.getLogger("PIL").setLevel(logging.WARNING)
|
||||
@@ -48,7 +49,9 @@ class Trainer:
|
||||
local_rank, world_size, save_dir=os.path.join(os.getcwd(), "writer")
|
||||
)
|
||||
self.stats = StatsTracker(config, self.is_main_thread)
|
||||
profiler.PROFILER = profiler.Profiler(config, self.is_main_thread)
|
||||
|
||||
@profiler.time_function
|
||||
def setup_dataset(self):
|
||||
"""_summary_"""
|
||||
dataset_inputs = get_dataset_inputs(**self.config.dataset)
|
||||
@@ -72,6 +75,7 @@ class Trainer:
|
||||
)
|
||||
# TODO(ethan): implement the test dataset
|
||||
|
||||
@profiler.time_function
|
||||
def setup_graph(self):
|
||||
"""_summary_"""
|
||||
dataset_inputs = get_dataset_inputs(**self.config.dataset)
|
||||
@@ -174,8 +178,10 @@ class Trainer:
|
||||
self.stats.print_stats(i / num_iterations)
|
||||
|
||||
self.stats.update_time(Stats.TOTAL_TRAIN_TIME, train_start, time(), step=-1)
|
||||
self.stats.dump_stats()
|
||||
self.stats.print_stats(-1)
|
||||
profiler.PROFILER.print_profile()
|
||||
|
||||
@profiler.time_function
|
||||
def train_iteration(self, batch: dict, step: int):
|
||||
"""Run one iteration with a batch of inputs."""
|
||||
# move batch to correct device
|
||||
@@ -190,6 +196,7 @@ class Trainer:
|
||||
self.optimizers.optimizer_step_all()
|
||||
return loss_dict
|
||||
|
||||
@profiler.time_function
|
||||
def test_image(self, image_idx, step):
|
||||
"""Test a specific image."""
|
||||
image = self.train_image_dataset[image_idx]["image"] # ground truth
|
||||
|
||||
Reference in new issue
Block a user