Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't use cuda in pipnet

See original GitHub issue

I want use cuda in pipnet, so I run the following code:

import torchlm
from import faceboxesv2
from torchlm.models import pipnet
import cv2
image_path = '../rgb/image0/1.png'
image = cv2.imread(image_path)
    pipnet(backbone="resnet18", pretrained=True,
        num_nb=10, num_lms=98, net_stride=32, input_size=256,
        meanface_type="wflw", checkpoint=None, map_location="cuda")

Then I get a error that say:

RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same or input should be a MKLDNN tensor and weight is a dense tensor

I know it due to my image data is still stay in cpu instead of gpu, and I need load my data to gpu. So I add a line code like following:

image = cv2.imread(image_path)
image = torch.tensor(image).cuda()

But now I get another error:

  File "C:\Home\Development\Anaconda\envs\DeepLearning\lib\site-packages\torchlm\tools\", line 305, in apply_detecting
    image_scale = cv2.resize(
cv2.error: OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'resize'
> Overload resolution failed:
>  - src is not a numpy array, neither a scalar
>  - Expected Ptr<cv::UMat> for argument 'src'

It means I need pass a ndarray array instead of a torch tensor. But if I pass a ndarray, its data will stay in cpu, and I will get the first error again.

What shold I do? Hava anyone get the same error?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

DefTruthcommented, May 13, 2022


pip install torchlm>= # or install the latest pypi version `pip install torchlm`
pip install torchlm>= -i # or install from specific pypi mirrors use '-i'
try-agaaaincommented, May 14, 2022


Read more comments on GitHub >

github_iconTop Results From Across the Web

Does CUDA support OpenCL pipe like structures?
I have been using OpenCL 2.0 on AMD GPUs until now. I was using OpenCL 2.0 because i needed to transfer data between...
Read more >
An Overview of the Numerical Approaches to Water Hammer ...
This paper reviews advances in the numerical modelling of transient pressurized flow, highlighting the use of the more recently developed finite volume method...
Read more >
(PDF) GPU Implementation of a Biological Electromagnetic ...
However, CUDA offers greater support tools for debugging and profiling, ... The problem here is that the prices are not stationary, thus we...
Read more >
(PDF) Automatic digital twin data model generation of building ...
Therefore, we use different data sources and standards to generate a ... needed for the detection tasks but can not directly be used...
Read more >
stopped-flow kinetic analysis: Topics by
This approach makes use of inline IR analysis and an automated microreactor ... which cannot be achieved with conventional macro-stopped flow devices.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found