Libtorch in c++

if “Copy GpuMat to CUDA Tensor” example is working, you “just” have to pass cuda array to gpumat…

:partying_face:

Hi David
Thanks very much for sharing your Pytorch Top.
I just tried your plug-in :
In 1280x720 - 5 FPS
In 640x360 - 19 FPS
It’s much better than my open cv cuda version !
It’s good news !
I have not much time now but I will try to to see if we can use Cuda array.
May be a functionality that I added in my open CV version is jumping a number of frames with a custom parameter. It’s not very efficient but that increase the FPS.

Hey David,

Awesome to see your progress.
I’m trying to write a TD C++ operator that runs PyTorch on CUDA as well. Lots to learn here.

Any luck on feeding the cudaArray into torch::from_blob? I’ve being trying to convert it into a cv::cuda::GpuMat, to then pass it to PyTorch, but with no success.

I’m thinking about moving to OpenGL, because of the lack of documentation regarding CUDA+PyTorch.

Let me know what you think.
Marco

I haven’t tried again since posting the PyTorchTOP. I figured that since torch::from_blob(topInput->cudaInput ... wasn’t working, it wouldn’t matter even if you converted/copied topInput->cudaInput into a cv::cuda::Gpumat as an intermediate step. I hope someone with more CUDA-TD knowledge can pitch in here…

Hello everyone, I have a similar question:

I tried to import torch (python-package) in touch but return:
ImportError: DLL load failed: The operating system cannot run %1.
However, It imports fine in Anaconda, screenshots attached. (same virtual environment set up in python module path in touch).
I have also uploaded all the dependencies in the conda env as a text file.
Any pointers help after Googling for a whole day.

Thanks,
Shaoyu
www.shaoyusu.com

Hi

In this post we talked about libtorch the c++ library. Your problem comes with pytorch the python library.
I do not use it.

Wich version of pytorch did you install ?
Wich version of td do you use ?
I believe Td 2020 use cuda 10 but if you choosed pytorch with cuda, it is cuda 9.2 or 10.1. That could be the problem…
So you can try the Last version of td 2019 with pytorch cuda 10.1
May be…

Hello Shieman,

Sorry if this is not the most relevant place to put but I haven’t seen any other posts regarding touch+torch.
Thank you for pointing out the cuda version issue. I will try to downgrade to an earlier touch version as I am running on 2020.20625 (torch.version_ 1.4.0)

Will update on progress.

UPDATE: it turned out that this file, “libiomp5md.dll” in the bin folder is preferred over pytorch (and potentially other external module). I just deleted it and import torch works like a charm. FYI
Shaoyu

Hi Shaoyu
I did not want to say it was not the right place.
It is à good news That is working.
Wich versions of TD And pytorch do you use ?
Pytorch cuda version ?
Shieman

Hi Shieman,

I am currently on 2019.37070 and torch 1.4.0, torchvision 0.5, which are all based on cuda 10.1.
I also reinstalled python 3.7.2 to match touch shipped python, not sure if that matters but I did it anyway.
My guess is that deleting libiomp5md.dll is the main trick to get it work.
Best,
Shaoyu