msharmavikram opened a new issue #11286: Similar performance between AlexNet 
and ResNet-50 for training during benchmarking with train_imagenet.py 
URL: https://github.com/apache/incubator-mxnet/issues/11286
 
 
   Note: Providing complete information in the most concise form is the best 
way to get help. This issue template serves as the checklist for essential 
information to most of the technical issues and bug reports. For non-technical 
issues and feature requests, feel free to present the information in what you 
believe is the best form.
   
   For Q & A and discussion, please start a discussion thread at 
https://discuss.mxnet.io 
   
   ## Description
   (Brief description of the problem in no more than 2 sentences.)
   Ideally, ResNet is about 6 times bigger than AlexNet in terms of compute and 
with a power GPU like Volta or Pascal, I anticipated that the performance 
difference between the two models to be about 2-3 times or even more. However, 
I am getting surprisingly low performance for AlexNet while ruinning the 
examples/image-classification/train_imagenet.py example on my Tesla 
V100/TitanXp gpu. I am getting roughly 540 img/sec with a batch size of 64 with 
synthetic data for both the models. When I experimented it with Gluon model 
https://github.com/apache/incubator-mxnet/blob/master/example/gluon/image_classification.py
 I was able to get a difference of about 8times. (AlexNet about 2.1K vs ResNet 
about 256 in TitanXp) However, the benchmark example 
https://github.com/apache/incubator-mxnet/blob/master/example/image-classification/train_imagenet.py
 does not seems to provide such a difference.  Appreciate any thoughts here?  
(I have added data of my V100 machine.)
   
   
   ## Environment info (Required)
   
   ```
   ----------Python Info----------
   Version      : 3.5.2
   Compiler     : GCC 5.4.0 20160609
   Build        : ('default', 'Nov 23 2017 16:37:01')
   Arch         : ('64bit', 'ELF')
   ------------Pip Info-----------
   Version      : 10.0.1
   Directory    : /usr/local/lib/python3.5/dist-packages/pip
   ----------MXNet Info-----------
   Version      : 1.3.0
   Directory    : /usr/local/lib/python3.5/dist-packages/mxnet
   Commit Hash   : b434b8ec18f774c99b0830bd3ca66859212b4911
   ----------System Info----------
   Platform     : Linux-4.13.0-45-generic-x86_64-with-Ubuntu-16.04-xenial
   system       : Linux
   node         : css-host-8
   release      : 4.13.0-45-generic
   version      : #50~16.04.1-Ubuntu SMP Wed May 30 11:18:27 UTC 2018
   ----------Hardware Info----------
   machine      : x86_64
   processor    : x86_64
   Architecture:          x86_64
   CPU op-mode(s):        32-bit, 64-bit
   Byte Order:            Little Endian
   CPU(s):                40
   On-line CPU(s) list:   0-39
   Thread(s) per core:    2
   Core(s) per socket:    10
   Socket(s):             2
   NUMA node(s):          2
   Vendor ID:             GenuineIntel
   CPU family:            6
   Model:                 79
   Model name:            Intel(R) Xeon(R) CPU E5-2640 v4 @ 2.40GHz
   Stepping:              1
   CPU MHz:               1200.189
   CPU max MHz:           3400.0000
   CPU min MHz:           1200.0000
   BogoMIPS:              4799.72
   Virtualization:        VT-x
   L1d cache:             32K
   L1i cache:             32K
   L2 cache:              256K
   L3 cache:              25600K
   NUMA node0 CPU(s):     0-9,20-29
   NUMA node1 CPU(s):     10-19,30-39
   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 arch_perfmon pebs bts rep_good nopl xtopology 
nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est 
tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt 
tsc_deadline_timer xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault 
epb cat_l3 cdp_l3 invpcid_single pti retpoline intel_ppin intel_pt spec_ctrl 
tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep 
bmi2 erms invpcid rtm cqm rdt_a rdseed adx smap xsaveopt cqm_llc cqm_occup_llc 
cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts
   ----------Network Test----------
   Setting timeout: 10
   Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.0255 sec, 
LOAD: 0.1334 sec.
   Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0100 
sec, LOAD: 0.5690 sec.
   Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 0.3449 sec, LOAD: 
1.6452 sec.
   Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0099 sec, LOAD: 
0.3464 sec.
   Timing for FashionMNIST: 
https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz,
 DNS: 0.2326 sec, LOAD: 0.6122 sec.
   Timing for Gluon Tutorial(cn): https://zh.gluon.ai, DNS: 0.3419 sec, LOAD: 
2.3122 sec.
   ```
   
   Package used (Python/R/Scala/Julia): 
   I'm using Python3 - MXNET-CU91
   
   For Scala user, please provide: NA
   1. Java version: (`java -version`)
   2. Maven version: (`mvn -version`)
   3. Scala runtime if applicable: (`scala -version`)
   
   For R user, please provide R `sessionInfo()`:NA
   
   ## Build info (Required if built from source) NA
   
   Compiler (gcc/clang/mingw/visual studio): NA
   
   MXNet commit hash:b434b8ec18f774c99b0830bd3ca66859212b4911
   (Paste the output of `git rev-parse HEAD` here.)
   
   Build config: Python3 -mxnet-cu91
   (Paste the content of config.mk, or the build command.)
   
   ## Error Message: There is no error. Performance invariance is reported. 
   (Paste the complete error message, including stack trace.)
   **Alexnet:**
   ```
   INFO:root:start with arguments Namespace(batch_size=64, benchmark=1, 
data_nthreads=40, data_train=None, data_train_idx='', data_val=None, 
data_val_idx='', disp_batches=20, dtype='float16', gc_threshold=0.5, 
gc_type='none', gpus='2', image_shape='3,224,224', initializer='default', 
kv_store='device', load_epoch=None, loss='', lr=0.1, lr_factor=0.1, 
lr_step_epochs='30,60', macrobatch_size=0, max_random_aspect_ratio=0.25, 
max_random_h=36, max_random_l=50, max_random_rotate_angle=10, max_random_s=50, 
max_random_scale=1, max_random_shear_ratio=0.1, min_random_scale=1, 
model_prefix='alexnet', mom=0.9, monitor=0, network='resnet', num_classes=1000, 
num_epochs=80, num_examples=1281167, num_layers=50, optimizer='sgd', 
pad_size=0, random_crop=1, random_mirror=1, rgb_mean='123.68,116.779,103.939', 
save_period=1, test_io=0, top_k=0, warmup_epochs=5, warmup_strategy='linear', 
wd=0.0001)
   [11:08:27] src/operator/nn/./cudnn/./cudnn_algoreg-inl.h:107: Running 
performance tests to find the best convolution algorithm, this can take a 
while... (setting env variable MXNET_CUDNN_AUTOTUNE_DEFAULT to 0 to disable)
   INFO:root:Epoch[0] Batch [20]        Speed: 535.12 samples/sec       
accuracy=0.455357
   INFO:root:Epoch[0] Batch [40]        Speed: 551.94 samples/sec       
accuracy=1.000000
   INFO:root:Epoch[0] Batch [60]        Speed: 554.26 samples/sec       
accuracy=1.000000
   INFO:root:Epoch[0] Batch [80]        Speed: 549.69 samples/sec       
accuracy=1.000000
   INFO:root:Epoch[0] Batch [100]       Speed: 548.01 samples/sec       
accuracy=1.000000
   ```
   **Resnet 50:**
   ```
   INFO:root:start with arguments Namespace(batch_size=64, benchmark=1, 
data_nthreads=40, data_train=None, data_train_idx='', data_val=None, 
data_val_idx='', disp_batches=20, dtype='float16', gc_threshold=0.5, 
gc_type='none', gpus='2', image_shape='3,224,224', initializer='default', 
kv_store='device', load_epoch=None, loss='', lr=0.1, lr_factor=0.1, 
lr_step_epochs='30,60', macrobatch_size=0, max_random_aspect_ratio=0.25, 
max_random_h=36, max_random_l=50, max_random_rotate_angle=10, max_random_s=50, 
max_random_scale=1, max_random_shear_ratio=0.1, min_random_scale=1, 
model_prefix='resnet', mom=0.9, monitor=0, network='resnet', num_classes=1000, 
num_epochs=80, num_examples=1281167, num_layers=50, optimizer='sgd', 
pad_size=0, random_crop=1, random_mirror=1, rgb_mean='123.68,116.779,103.939', 
save_period=1, test_io=0, top_k=0, warmup_epochs=5, warmup_strategy='linear', 
wd=0.0001)
   [11:07:24] src/operator/nn/./cudnn/./cudnn_algoreg-inl.h:107: Running 
performance tests to find the best convolution algorithm, this can take a 
while... (setting env variable MXNET_CUDNN_AUTOTUNE_DEFAULT to 0 to disable)
   INFO:root:Epoch[0] Batch [20]        Speed: 528.37 samples/sec       
accuracy=0.433036
   INFO:root:Epoch[0] Batch [40]        Speed: 540.25 samples/sec       
accuracy=1.000000
   INFO:root:Epoch[0] Batch [60]        Speed: 539.98 samples/sec       
accuracy=1.000000
   INFO:root:Epoch[0] Batch [80]        Speed: 546.55 samples/sec       
accuracy=1.000000
   INFO:root:Epoch[0] Batch [100]       Speed: 550.18 samples/sec       
accuracy=1.000000
   INFO:root:Epoch[0] Batch [120]       Speed: 543.24 samples/sec       
accuracy=1.000000
   
   ```
   
   
   ## Minimum reproducible example
   (If you are using your own code, please provide a short script that 
reproduces the error. Otherwise, please provide link to the existing example.)
   
   ## Steps to reproduce
   (Paste the commands you ran that produced the error.)
   
   `cd 
https://github.com/apache/incubator-mxnet/blob/master/example/image-classification/
 and run below commands. 
   `
   Run below synthetic data commands - 
   ```
   1. python3 train_imagenet.py --gpus 0 --model alexnet   --test-io 0 
--data-nthreads 40  --benchmark 1  --batch-size 64 --dtype float16
   2. python3 train_imagenet.py --gpus 0 --model resnet --num-layers 50   
--test-io 0 --data-nthreads 40  --benchmark 1  --batch-size 64 --dtype float16
   
   ```
   ## What have you tried to solve it?
   
   1. I have tried various batch sizes and this is the highest throughput I can 
get.
   2. I have tried turning off data augmentation but still no effect
   3. I have tried gluon and when I give it --dtype float16 the throughput 
seems to be much better but I think the support for flaot16 isn't complete as 
it causes an error. I have added another request for this at 
https://github.com/apache/incubator-mxnet/issues/11285

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to