Skip to main content

Measure neural network device specific metrics (latency, flops, etc.)

Project description

torchprof

Measure neural network device specific metrics.

Each nested module is run individually.

Quickstart

pip install torchprof

import torch
import torchvision
import torchprof

model = torchvision.models.alexnet(pretrained=False).cuda()
x = torch.rand([1, 3, 224, 224]).cuda()
observer = torchprof.LatencyObserver(model, use_cuda=True)

raw_measurements = observer.measure_latency(x)
print(raw_measurements[:3])
# [(['AlexNet'], (3836.7989999999986, 13197.66349029541)), (['AlexNet', 'features'], (3527.07, 14528.191928863525)), (['AlexNet', 'features', '0'], (223.438, 1080.1919765472412))]

print(observer)
Module         |  CPU Time | CUDA Time
---------------|-----------|----------
AlexNet        |   3.837ms |  13.198ms
├── features   |   3.527ms |  14.528ms
│  ├── 0       | 223.438us |   1.080ms
│  ├── 1       |  18.270us |  20.448us
│  ├── 2       |  29.030us |  52.224us
│  ├── 3       |  76.570us |   1.108ms
│  ├── 4       |  17.480us |  17.600us
│  ├── 5       |  28.150us |  51.008us
│  ├── 6       |  83.519us | 475.840us
│  ├── 7       |  17.820us |  18.432us
│  ├── 8       |  83.370us | 541.664us
│  ├── 9       |  17.590us |  18.432us
│  ├── 10      |  82.769us | 425.920us
│  ├── 11      |  17.260us |  18.272us
│  └── 12      |  28.160us |  49.280us
├── avgpool    |  28.130us |  54.272us
└── classifier | 187.109us | 716.000us
   ├── 0       |  29.179us |  52.992us
   ├── 1       |  37.800us | 419.904us
   ├── 2       |  17.319us |  17.536us
   ├── 3       |  28.860us |  52.096us
   ├── 4       |  37.629us | 202.752us
   ├── 5       |  17.270us |  17.408us
   └── 6       |  37.520us |  75.648us

LICENSE

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torchprof-0.0.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

torchprof-0.0.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file torchprof-0.0.1.tar.gz.

File metadata

  • Download URL: torchprof-0.0.1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for torchprof-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c95acb68ffcd5ad2ebd636ed52dca853b828e83091c616805d41b1c5f2b8d7a6
MD5 a4a4cbe385c4bd24d51c7cba2205bb3f
BLAKE2b-256 1e375bb675dbf72b91f9882b85051fc2370f8047b2e79e4f0f2994c1d3390d4b

See more details on using hashes here.

File details

Details for the file torchprof-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: torchprof-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for torchprof-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1e316a0812a873058cf60c1a9f1d506023adf75c9776982e84caea0b20276f9f
MD5 a483f050401f5d29e74e7b8a9bb1b6fa
BLAKE2b-256 e11a149dfb97b8fbae3c1df4e493b52c68e9a052e7cde4d5d579bef6e965b053

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page