Category: gluoncv

gluoncv is based on mxnet, it’s very flexible and easy to use for object detection.

Since mxnet is almost ready on rocm platform, gluoncv would be possiblely available to be used on rocm.

This post is to track to building of gluoncv on rocm.

1. git clone

git clone --recurse-submodules -b downstream_27Mar2018

there are 3rd party components so –recurse-submodules is needed.

2. hipfft has been replaced by rocfft, so change hipfft to rocfft in mxnet/Makefile.

3. mxnet requested version is 1.3.0, but the downstream branch is 1.2.0. So changed this version in gluon-cv/gluoncv/

4. met an error when running:

from gluoncv import model_zoo, data, utils

net = model_zoo.get_model('ssd_512_resnet50_v1_voc', pretrained=True)

mxnet.gluon.Block has no attribute ‘load_parameters’. The current supported function is ‘load_params’. So changed it in gluon-cv/gluoncv/model_zoo/ssd/

5. slice_like is missing in mxnet/symbol/

Similar issue is reported here:

seems need to update mxnet. (need to check newer version of rocm based mxnet)

hacked gluoncv/model_zoo/ssd/

def hybrid_forward(self, F, x, anchors):
    #a = F.slice_like(anchors, x * 0, axes=(2, 3))
    #------- rocky 20181022: ---------------
    a = F.slice(anchors, begin=tuple([0]*len(anchors.shape)), end=(None,None, x.shape[2], x.shape[3], None))

temp solved this issue.

6. mxnet.base.MXNetError: Cannot find argument ‘valid_thresh’

There is no ‘valid_thresh’ parameter in def box_nms in:


So remove this param from  gluoncv/model_zoo/ssd/

        if self.nms_thresh > 0 and self.nms_thresh < 1:

            #------- rockyli, mxnet 1.2.0 has no valid_thresh param for contrib.box_nms)
            print "debug before F.contrib.box_nms"
            print result
            result = F.contrib.box_nms(
                #result, overlap_thresh=self.nms_thresh, topk=self.nms_topk, valid_thresh=0.01,
                result, overlap_thresh=self.nms_thresh, topk=self.nms_topk,
                id_index=0, score_index=1, coord_start=2, force_suppress=False)

This can temp solve above issue.

Now the object detection is Ok using a pre trained ssd VOC model with a sample image.