-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add PyTorch 1.8 Profiler 5/5 #6618
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
Merged
Merged
Changes from all commits
Commits
Show all changes
153 commits
Select commit
Hold shift + click to select a range
aa89fa1
Refactor profilers
carmocca b66f1f6
Update PassThrough
carmocca d388d80
WIP - This is broken and will change
carmocca 93aa073
Update pytorch_lightning/profiler/pytorch.py
carmocca 0f8b6ef
resolve tests
tchaton d219ae1
Merge branch 'master' into update-pytorch-profiler
tchaton 8a3d3cf
resolve tests
tchaton af865ff
find output
tchaton 6147e6e
try something
tchaton 5053b4f
update
tchaton 3ae2fbf
add support for test and predict
tchaton 1d7ac88
update
tchaton 64f8a58
update
tchaton 655ff46
use getattr
tchaton 3f5c4d6
test
tchaton ced0d66
test
tchaton 662f8de
update
tchaton 753f63b
tests
tchaton e6a6917
update
tchaton a7f7f4c
update
tchaton c221d7d
update
tchaton e39f6d7
update
tchaton e485850
update
tchaton 00d355a
remove file
tchaton 61da390
update
tchaton 002f137
Merge branch 'update-pytorch-profiler' of https://github.com/PyTorchL…
tchaton e565e8a
update
tchaton 6f2258f
update
tchaton 883b242
update
tchaton 9b957bd
update
tchaton 70cc20d
test
tchaton 226e0be
update#
tchaton 27348c7
update
tchaton 853d36c
update tests
tchaton 9004e92
update
tchaton c35e927
add suport for 1.8
tchaton 1f9d2d9
rename records
tchaton 13caa86
add support for 1.8
tchaton 18c48ce
update
tchaton a1c37ad
resolve flake8
tchaton 3750b22
resolve test
tchaton 9a87c52
Merge branch 'master' into update-pytorch-profiler
carmocca fbbb9a2
Refactor basic profilers
carmocca 2a82e05
Fixes
carmocca ff125e2
Unused import
carmocca 01a760e
Introduce setup
carmocca b31831e
Profile on all ranks. Print to stdout on 0
carmocca f8a8772
Introduce dirpath + filename
carmocca aa4b7dd
CHANGELOG
carmocca 8e3034e
Add tests. Address comments
carmocca 96259a4
Merge branch 'update-pytorch-profiler' into update-pytorch-profiler-1.8
tchaton e4e0dd6
add `on_run_stage_setup`
tchaton d0fdbb9
add on_run_stage_setup function
tchaton 1a16bb3
update
tchaton 52fa69b
add test for RegisterRecordFunction
tchaton 63b6988
update lightnng flow direction
tchaton 1cf5a64
move variable to private
tchaton a05acdd
remove trace
tchaton af72dff
Merge branch 'master' into refactor-base-profilers
tchaton 59c941b
Undo code that should be in 3/4
carmocca da0f310
Multi-stage multi-rank
carmocca 59c1b4c
2/5 changes
carmocca dd1dce0
Pass stage in __del__
carmocca 12d014b
Merge branch 'master' into refactor-base-profilers
carmocca 097a426
Remove TODOs
carmocca 4d529fa
Describe on_evaluation_end. Add tests
carmocca 58dcd4e
Typo
carmocca c37162f
Address comments
carmocca 4c5f1f3
deepcopy tests
carmocca 5ed73fb
Advanced teardown
carmocca 897f8e5
Fix teardown test
carmocca e42be2a
Fix tests
carmocca 32c301c
Minor change
carmocca af0c8ad
Update CHANGELOG.md
carmocca 29a73c5
Fix test
carmocca d6ede58
Merge branch 'refactor-base-profilers' into update-pytorch-profiler
carmocca 0dc1e06
Quick fixes
carmocca cb756b8
Fix 6522
carmocca 758b942
resolve ddp tests
tchaton fca4eb2
resolve tests
tchaton 2919a39
resolve some tests
tchaton d7ca5fa
update tests
tchaton 34b7991
Merge branch 'refactor-base-profilers' into update-pytorch-profiler
tchaton b3ffe64
resolve tests
tchaton e0d8308
Merge branch 'master' into update-pytorch-profiler
tchaton ecd1fd2
update
tchaton 3a0d821
Merge branch 'update-pytorch-profiler-1.8' of https://github.com/PyTo…
tchaton c3e52f8
Merge branch 'update-pytorch-profiler' into update-pytorch-profiler-1.8
tchaton 97c87d3
resolve tests
tchaton 172b388
resolve some tests
tchaton ae31f00
Missed fixes from 3/5
carmocca 78970d5
Fixes
carmocca 7e27a8d
resolve some tests
tchaton dbd1c7e
Merge branch 'update-pytorch-profiler-1.8' of https://github.com/PyTo…
tchaton c0107e2
Merge branch 'update-pytorch-profiler' of https://github.com/PyTorchL…
tchaton 87aa09f
resolve test for 1.7.1
tchaton ba067fd
Broken refactor
carmocca f916013
Missed stage
carmocca 9a1b1b6
Minor changes
carmocca 04abd0a
resolve tests
tchaton ab1218e
Merge branch 'update-pytorch-profiler' of https://github.com/PyTorchL…
tchaton 0230330
Update CHANGELOG
carmocca cba643b
resolve bug
tchaton 85bfc7d
Merge branch 'update-pytorch-profiler' of https://github.com/PyTorchL…
tchaton af209f5
remove print
tchaton bb813bb
Typo
carmocca 624a85f
Cleanup
carmocca 1732ece
resolve ddp test
tchaton f0c1675
remove barrier
tchaton fbe50b1
update profiler
tchaton a13664d
Merge branch 'master' into update-pytorch-profiler
tchaton 374f0da
update
tchaton e3c162e
Merge branch 'master' into update-pytorch-profiler-1.8
tchaton 6e948ca
Smaller model
carmocca ad55628
update
tchaton 05f68b4
Merge branch 'update-pytorch-profiler-1.8' of https://github.com/PyTo…
tchaton 88c44d6
Merge branch 'update-pytorch-profiler' into update-pytorch-profiler-1.8
tchaton 2b0f92d
resolve tests
tchaton e46cf1c
update
tchaton 5071947
Merge branch 'master' into update-pytorch-profiler-1.8
tchaton 5b51259
Minor changes. CHANGELOG
carmocca 5aa19ec
Minimize diff
carmocca efdb20b
update to 1.8.1
tchaton ea00c36
Merge branch 'update-pytorch-profiler-1.8' of https://github.com/PyTo…
tchaton 79efcb2
RunIf. Extra code. Check segfault
carmocca 5453bbe
Merge branch 'update-pytorch-profiler-1.8' of https://github.com/PyTo…
carmocca 11e3150
resolve tests
tchaton 2cd2be1
Typo. Bad merge
carmocca 6aab082
Merge branch 'update-pytorch-profiler-1.8' of https://github.com/PyTo…
tchaton 7cff95a
Merge branch 'update-pytorch-profiler-1.8' of https://github.com/PyTo…
tchaton 496efab
Fixing a bad merge
carmocca 9ced644
replace for kineto
tchaton ee85864
Update pytorch_lightning/profiler/pytorch.py
tchaton efaa459
Update pytorch_lightning/profiler/pytorch.py
tchaton e73becc
Minor changes
carmocca 2865c96
Merge branch 'update-pytorch-profiler-1.8' of https://github.com/PyTo…
carmocca 92fa085
Bad merge
carmocca a5093cb
Use lists for flexibility
carmocca 5ccbfd0
Use sets
carmocca d1c0915
predict_step
carmocca 8098aaf
Ananth's suggestion
carmocca 8b9bbf0
update
tchaton a74e835
Docs
carmocca 5af66be
Merge branch 'update-pytorch-profiler-1.8' of https://github.com/PyTo…
carmocca 3605b1a
Update pl_examples/basic_examples/profiler_example.py
tchaton 8e93145
update example
tchaton af5d2ef
update example
tchaton f30fa58
definition
Borda 9b5f90c
yapf
Borda 92eaf7d
move pm
Borda 8a631e0
typo
Borda 8f95814
update
tchaton 175f285
Merge branch 'update-pytorch-profiler-1.8' of https://github.com/PyTo…
tchaton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# Copyright The PyTorch Lightning team. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
""" | ||
This script will generate 2 traces: one for `training_step` and one for `validation_step`. | ||
The traces can be visualized in 2 ways: | ||
* With Chrome: | ||
1. Open Chrome and copy/paste this url: `chrome://tracing/`. | ||
2. Once tracing opens, click on `Load` at the top-right and load one of the generated traces. | ||
* With PyTorch Tensorboard Profiler (Instructions are here: https://github.com/pytorch/kineto/tree/master/tb_plugin) | ||
1. pip install tensorboard torch-tb-profiler | ||
2. tensorboard --logdir={FOLDER} | ||
""" | ||
|
||
import sys | ||
from argparse import ArgumentParser | ||
|
||
import torch | ||
import torchvision | ||
import torchvision.models as models | ||
import torchvision.transforms as T | ||
|
||
from pl_examples import cli_lightning_logo | ||
from pytorch_lightning import LightningDataModule, LightningModule, Trainer | ||
|
||
DEFAULT_CMD_LINE = ( | ||
"--max_epochs", | ||
"1", | ||
"--limit_train_batches", | ||
"15", | ||
"--limit_val_batches", | ||
"15", | ||
"--profiler", | ||
"pytorch", | ||
"--gpus", | ||
f"{int(torch.cuda.is_available())}", | ||
) | ||
|
||
|
||
class ModelToProfile(LightningModule): | ||
|
||
def __init__(self, model): | ||
super().__init__() | ||
self.model = model | ||
self.criterion = torch.nn.CrossEntropyLoss() | ||
|
||
def training_step(self, batch, batch_idx): | ||
inputs, labels = batch | ||
outputs = self.model(inputs) | ||
loss = self.criterion(outputs, labels) | ||
self.log("train_loss", loss) | ||
return loss | ||
|
||
def validation_step(self, batch, batch_idx): | ||
inputs, labels = batch | ||
outputs = self.model(inputs) | ||
loss = self.criterion(outputs, labels) | ||
self.log("val_loss", loss) | ||
|
||
def configure_optimizers(self): | ||
return torch.optim.SGD(self.parameters(), lr=0.001, momentum=0.9) | ||
|
||
|
||
class CIFAR10DataModule(LightningDataModule): | ||
|
||
transform = T.Compose([T.Resize(256), T.CenterCrop(224), T.ToTensor()]) | ||
|
||
def train_dataloader(self, *args, **kwargs): | ||
trainset = torchvision.datasets.CIFAR10(root='./data', train=True, download=True, transform=self.transform) | ||
return torch.utils.data.DataLoader(trainset, batch_size=32, shuffle=True, num_workers=0) | ||
|
||
def val_dataloader(self, *args, **kwargs): | ||
valset = torchvision.datasets.CIFAR10(root='./data', train=False, download=True, transform=self.transform) | ||
return torch.utils.data.DataLoader(valset, batch_size=32, shuffle=True, num_workers=0) | ||
|
||
|
||
def cli_main(): | ||
|
||
parser = ArgumentParser() | ||
parser = Trainer.add_argparse_args(parser) | ||
cmd_line = None if len(sys.argv) != 1 else DEFAULT_CMD_LINE | ||
tchaton marked this conversation as resolved.
Show resolved
Hide resolved
|
||
args = parser.parse_args(args=cmd_line) | ||
|
||
model = ModelToProfile(models.resnet50(pretrained=True)) | ||
datamodule = CIFAR10DataModule() | ||
trainer = Trainer(**vars(args)) | ||
trainer.fit(model, datamodule=datamodule) | ||
|
||
|
||
if __name__ == '__main__': | ||
cli_lightning_logo() | ||
cli_main() |
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.