FaceMaskDetection
FaceMaskDetection copied to clipboard
How to run mxnet python on GPU?
Hi ,
How to run mxnet python on GPU ?
The code running on the cpu
Hi, here is the toturials. https://beta.mxnet.io/guide/crash-course/6-use_gpus.html Just set the context to GPU instead of CPU.
I put gpu(0) on :
def load_mxnet_model(weight_path): ssd = SSD() ssd.load_parameters(weight_path , cox = gpu(0)) return ssd İt gives :
RuntimeError: Parameter 'conv2d_0weight' was not initialized on context cpu(0). It was only initiali| zed on [gpu(0)]. |
ERROR.
Where should I put the CTX = GPU(0) . Not so familiar to the gluon
PS: are you planning to port c++ ? We would love to use it in our hospital entrance
On 6 Apr 2020, at 08:27, AIZOOTech [email protected] wrote:
Hi, here is the toturials. https://beta.mxnet.io/guide/crash-course/6-use_gpus.html https://beta.mxnet.io/guide/crash-course/6-use_gpus.html Just set the context to GPU instead of CPU.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AIZOOTech/FaceMaskDetection/issues/26#issuecomment-609572629, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEFRZHYSJO7UTAKBB63ONIDRLFR4FANCNFSM4L7LAYZQ.
Found..
extra need to add default ctx to gpu
Best
@MyraBaba how did you solve RuntimeError: Parameter 'conv2d_0bias' was not initialized on context cpu(0). It was only initialized on [gpu(0)].
error
need to set defult ctx in mxnet. It was my other GPU laptop. When I on it let you know.
@MyraBaba any update sorry to bother you. How did you add extra default ctx to gpu.
@MyraBaba i have the same issue , please need your help
Guys, I figured! Two changes need to be applied:
In 'mxnet_loader.py', edit the function 'load_mxnet_model' to be like this:
def load_mxnet_model(weight_path, ctx=mx.gpu(0)): ssd = SSD() ssd.load_parameters(weight_path, ctx=ctx) ssd.collect_params().reset_ctx(ctx) return ssd
And in the same .py file, edit another function 'mxnet_inference' to be like:
def mxnet_inference(model, img_arr, ctx=mx.gpu(0)): y_scores, y_bboxes = model.forward(nd.array(img_arr).as_in_context(ctx)) return y_bboxes.asnumpy(), y_scores.asnumpy()
This should solve your problem.