question-mark
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 torchlm.tools import faceboxesv2
from torchlm.models import pipnet
import cv2
image_path = '../rgb/image0/1.png'
image = cv2.imread(image_path)
torchlm.runtime.bind(faceboxesv2())
torchlm.runtime.bind(
    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")
)
torchlm.runtime.forward(image)

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\_faceboxesv2.py", 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

1reaction
DefTruthcommented, May 13, 2022

可以安装新版本试试

pip install torchlm>=0.1.6.10 # or install the latest pypi version `pip install torchlm`
pip install torchlm>=0.1.6.10 -i https://pypi.org/simple/ # or install from specific pypi mirrors use '-i'
0reactions
try-agaaaincommented, May 14, 2022

是我的torch安装错误了,安装cuda版的pytorch后可以正常使用。

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 Science.gov
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found