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

Trace and Lightning view not displayed for Lightning 2.X #753

Open
ptr-br opened this issue Apr 18, 2023 · 0 comments
Open

Trace and Lightning view not displayed for Lightning 2.X #753

ptr-br opened this issue Apr 18, 2023 · 0 comments
Labels
bug Something isn't working plugin PyTorch Profiler TensorBoard Plugin related

Comments

@ptr-br
Copy link

ptr-br commented Apr 18, 2023

Hi,

I have the problem that the trace and the lightning view are not displayed for profiling with Lightning2.X.

I adapted the resnet50_profiler_api.py.py to be a minimum working example:

import torch.profiler
import lightning.pytorch as pl
from lightning.pytorch.profilers import PyTorchProfiler
import torchvision.models as models
import torchvision.transforms as T
import torchvision
import torch.utils.data
import torch.optim
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch



class Model(pl.LightningModule):
   def __init__(self, model, criterion, optimizer) -> None:
       super().__init__()
       self.model = model
       self.criterion = criterion
       self.optimizer = optimizer

   def training_step(self, train_batch: dict, batch_idx: int) -> torch.Tensor:
       inputs, labels = train_batch
       outputs = self.model(inputs)
       return self.criterion(outputs, labels)

   def configure_optimizers(self) -> torch.optim:
       return self.optimizer


cudnn.benchmark = True

transform = T.Compose([T.Resize(256), T.CenterCrop(224), T.ToTensor()])
trainset = torchvision.datasets.CIFAR10(root='./data', train=True,
                                       download=True, transform=transform)
trainloader = torch.utils.data.DataLoader(trainset, batch_size=32,
                                         shuffle=True, num_workers=4)

model = models.resnet50(pretrained=True)
criterion = nn.CrossEntropyLoss().cuda()
optimizer = torch.optim.SGD(model.parameters(), lr=0.001, momentum=0.9)

model = Model(model, criterion, optimizer)

trainer = pl.Trainer(
   num_sanity_val_steps=0,
   devices=1,
   accelerator="gpu",
   profiler=PyTorchProfiler(filename="profiling")

)
trainer.fit(model, train_dataloaders=trainloader)

print("done.")

requirements.txt:

pytorch-lightning==2.0.1.post0
tensorboard ==2.12.2
torchvision==0.15.1
torch-tb-profiler==0.4.1
@aaronenyeshi aaronenyeshi added bug Something isn't working plugin PyTorch Profiler TensorBoard Plugin related labels Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working plugin PyTorch Profiler TensorBoard Plugin related
Projects
None yet
Development

No branches or pull requests

2 participants