Negative performance improvement by torch.complie. · Issue #97509 · pytorch/pytorch · GitHub

您所在的位置:网站首页 torchsum Negative performance improvement by torch.complie. · Issue #97509 · pytorch/pytorch · GitHub

Negative performance improvement by torch.complie. · Issue #97509 · pytorch/pytorch · GitHub

#Negative performance improvement by torch.complie. · Issue #97509 · pytorch/pytorch · GitHub| 来源: 网络整理| 查看: 265

🐛 Describe the bug

I want to compare the performance of a code snippet with and without torch.compile

import torch import torchvision.models as models import time import sys device = torch.device("cuda" if torch.cuda.is_available() else "cpu") print(device) model = models.resnet18().to(device) optimizer = torch.optim.SGD(model.parameters(), lr=0.01) if len(sys.argv) > 1: print('compile the model') compiled_model = torch.compile(model) else: compiled_model = model x = torch.randn(64, 3, 224, 224).to(device) for i in range(1): optimizer.zero_grad() out = compiled_model(x) out.sum().backward() optimizer.step() torch.cuda.synchronize(0) start = time.time() for i in range(10): x = torch.randn(64, 3, 224, 224).to(device) optimizer.zero_grad() out = compiled_model(x) out.sum().backward() optimizer.step() torch.cuda.synchronize(0) print(f'time cost is {time.time() - start}') Error logs

The result for command python -u demo.py is time cost is 0.8468308448791504. The result for command python -u demo.py is compile the model time cost is 0.9513726234436035 This is my first time to try torch 2.0; If I want to know what leads to the negative performance optimization. Any suggestions to me?

Minified repro

No response

Versions

Collecting environment information... PyTorch version: 2.0.0 Is debug build: False CUDA used to build PyTorch: 11.7 ROCM used to build PyTorch: N/A

OS: CentOS Linux 7 (Core) (x86_64) GCC version: (GCC) 5.3.0 Clang version: Could not collect CMake version: version 3.25.2 Libc version: glibc-2.17

Python version: 3.10.10 (main, Mar 21 2023, 18:45:11) [GCC 11.2.0] (64-bit runtime) Python platform: Linux-3.10.0-693.el7.x86_64-x86_64-with-glibc2.17 Is CUDA available: True CUDA runtime version: 11.7.64 CUDA_MODULE_LOADING set to: LAZY GPU models and configuration: GPU 0: Tesla V100-SXM2-32GB GPU 1: Tesla V100-SXM2-32GB GPU 2: Tesla V100-SXM2-32GB GPU 3: Tesla V100-SXM2-32GB GPU 4: Tesla V100-SXM2-32GB GPU 5: Tesla V100-SXM2-32GB GPU 6: Tesla V100-SXM2-32GB GPU 7: Tesla V100-SXM2-32GB

Nvidia driver version: 525.60.11 cuDNN version: Could not collect HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True

CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 48 On-line CPU(s) list: 0-47 Thread(s) per core: 2 Core(s) per socket: 12 Socket(s): 2 NUMA node(s): 2 Vendor ID: GenuineIntel CPU family: 6 Model: 85 Model name: Intel(R) Xeon(R) Gold 6146 CPU @ 3.20GHz Stepping: 4 CPU MHz: 3201.000 CPU max MHz: 3201.0000 CPU min MHz: 1200.0000 BogoMIPS: 6400.00 Virtualization: VT-x L1d cache: 32K L1i cache: 32K L2 cache: 1024K L3 cache: 25344K NUMA node0 CPU(s): 0-11,24-35 NUMA node1 CPU(s): 12-23,36-47 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 ds_cpl vmx smx est tm2 ssse3 fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb cat_l3 cdp_l3 intel_pt tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts

Versions of relevant libraries: [pip3] numpy==1.24.2 [pip3] torch==2.0.0 [pip3] torchaudio==2.0.0 [pip3] torchdata==0.6.0 [pip3] torchvision==0.15.0 [conda] blas 1.0 mkl [conda] ffmpeg 4.3 hf484d3e_0 pytorch [conda] mkl 2021.4.0 h06a4308_640 [conda] mkl-service 2.4.0 py310h7f8727e_0 [conda] mkl_fft 1.3.1 py310hd6ae3a3_0 [conda] mkl_random 1.2.2 py310h00e6091_0 [conda] numpy 1.24.2 pypi_0 pypi [conda] numpy-base 1.23.5 py310h8e6c178_0 [conda] pytorch 2.0.0 py3.10_cuda11.7_cudnn8.5.0_0 pytorch [conda] pytorch-cuda 11.7 h778d358_3 pytorch [conda] pytorch-mutex 1.0 cuda pytorch [conda] torchaudio 2.0.0 py310_cu117 pytorch [conda] torchdata 0.6.0 pypi_0 pypi [conda] torchtriton 2.0.0 py310 pytorch [conda] torchvision 0.15.0 py310_cu117 pytorch

cc @ezyang @soumith @msaroufim @wconstab @ngimel @bdhirsh



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3