You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@mxnet.apache.org by GitBox <gi...@apache.org> on 2020/09/29 01:40:29 UTC
[GitHub] [incubator-mxnet] samskalicky edited a comment on issue #19247: asnumpy() on cpu is 80 times slower than gpu
samskalicky edited a comment on issue #19247:
URL: https://github.com/apache/incubator-mxnet/issues/19247#issuecomment-700373245
Cleaned up the code a bit:
```python
import mxnet as mx
import numpy as np
import gluoncv
import time
# model = self.load_model(best=True)
model = gluoncv.model_zoo.get_model('faster_rcnn_resnet50_v1b_voc',pretrained=True)
img = mx.random.randn(1,3,608,608,ctx = mx.gpu())
model.collect_params().reset_ctx(mx.gpu())
model.hybridize(static_shape=True, static_alloc=True)
#warmup
print('gpu warmup')
for i in range(10):
ids,scores,boxes = model(img)
ids,scores,boxes = ids.asnumpy(),scores.asnumpy(),boxes.asnumpy()
mx.nd.waitall()
#gpu test
for i in range(10):
start_time5 = time.time()
ids,scores,boxes = model(img)
ids,scores,boxes = ids.asnumpy(),scores.asnumpy(),boxes.asnumpy()
mx.nd.waitall()
print('gpu: %4.3f seconds' % (time.time()-start_time5))
model.collect_params().reset_ctx(mx.cpu())
img = img.as_in_context(mx.cpu())
#warmup
print('cpu warmup')
for i in range(10):
ids,scores,boxes = model(img)
ids,scores,boxes = ids.asnumpy(),scores.asnumpy(),boxes.asnumpy()
mx.nd.waitall()
#cpu test
for i in range(10):
start_time5 = time.time()
ids,scores,boxes = model(img)
ids,scores,boxes = ids.asnumpy(),scores.asnumpy(),boxes.asnumpy()
mx.nd.waitall()
print('cpu: %4.3f seconds' % (time.time()-start_time5))
```
Heres the output I get on P3.2xl with mxnet-cu102 (version 1.7.0):
```
gpu warmup
[01:37:43] src/operator/nn/./cudnn/./cudnn_algoreg-inl.h:97: Running performance tests to find the best convolution algorithm, this can take a while... (set the environment variable MXNET_CUDNN_AUTOTUNE_DEFAULT to 0 to disable)
gpu: 0.052 seconds
gpu: 0.052 seconds
gpu: 0.052 seconds
gpu: 0.052 seconds
gpu: 0.052 seconds
gpu: 0.052 seconds
gpu: 0.052 seconds
gpu: 0.052 seconds
gpu: 0.052 seconds
gpu: 0.052 seconds
cpu warmup
cpu: 2.827 seconds
cpu: 2.837 seconds
cpu: 2.829 seconds
cpu: 2.826 seconds
cpu: 2.828 seconds
cpu: 2.830 seconds
cpu: 2.826 seconds
cpu: 2.830 seconds
cpu: 2.832 seconds
cpu: 2.824 seconds
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org
For additional commands, e-mail: issues-help@mxnet.apache.org