Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
34 views

How to avoid find_package_handle_standard_args package name warning

In LibTorch 2.0.1 I was able to use the library without installing it (download library and set CMAKE_PREFIX_PATH to allow CMake to find the library). Using LibTorch 2.5.1 and CUDA 12.6 I have to ...
Uriel Herrera's user avatar
0 votes
0 answers
19 views

Simulating a file that includes libtorch with gem5

I successfully built libtorch and generated the binary for the following simple function (torch::rand({2, 3});) to simulate it with gem5 in SE mode. However, the simulation takes a very long time, so ...
Cliff Wu's user avatar
0 votes
0 answers
132 views

Building PyTorch 2.5.1 (libtorch + main PyTorch) with CUDA 12.6.3 and cuDNN 9.5.1

My goal is to build PyTorch from source for use in image generation AI workflows (e.g., ComfyUI). I would like to request guidance on the correct method to build PyTorch 2.5.1 (both libtorch and the ...
user28412398's user avatar
1 vote
0 answers
60 views

std::bad_alloc when loading PyTorch model in C++ using LibTorch

I'm trying to load a traced PyTorch model in C++ using LibTorch but encountering a std::bad_alloc error. I've set up a minimal example to demonstrate the issue. The Problem: When running my C++ ...
works's user avatar
  • 107
1 vote
1 answer
50 views

Use Boost python with libtorch

I am trying to create a python package from C++ code with Boost python. However when including libtorchin the code, the resulting python package shows strange errors such as Boost.Python....
ppeloton's user avatar
0 votes
0 answers
65 views

How do you optimize inference batch size in c++ pytorch libtorch?

I have an inference service using cpu (will migrate to gpu later but right now I am stuck with cpu) that is taking request through thrift and returning inference result Right now its doing inference 1 ...
progr's user avatar
  • 63
1 vote
0 answers
46 views

How does batch inference work in pytorch c++

I am looking for ways to batch inference instead of inference one request at a time in c++ For example, assuming each request in requests is a single prediction containing n feature, each feat for (...
progr's user avatar
  • 63
0 votes
0 answers
84 views

How to set up CMakeLists.txt for Libtorch in a C++ Project?

I have a simple project with use of libtorch. The structure of the project is the following: MyLibtorchProject/ ├── CMakeLists.txt ├── main.cpp ├── libtorch/ └── build/ The content of CMakeLists.txt ...
Luciano Muratore's user avatar
0 votes
1 answer
66 views

How to bundle libtorch with my rust binary?

I am developing an AI chat desktop application targeting Apple M chips. The app utilizes embedding models and reranker models, for which I chose Rust-Bert due to its capability to handle such models ...
GraphicalDot's user avatar
  • 2,811
4 votes
1 answer
105 views

Why is a namespace-qualified name available as a candidate?

Using libtorch, the following snippet causes an error: #include <iostream> #include <torch/torch.h> using namespace torch; int main() { std::cout << zeros({}) << std::endl; ...
Daniel Wagner's user avatar
3 votes
0 answers
70 views

OpenCV and Libtorch conflict

Ubuntu 24 system; CLion IDE. When trying to run code using OpenCV and Libtorch, the following errors occur: main.cpp:34:(.text+0xa28): undefined reference to `cv::putText(cv::_InputOutputArray const&...
Oleg Chaika's user avatar
0 votes
1 answer
180 views

Unable to load DLL 'LibTorchSharp' or one of its dependencies: The specified procedure could not be found

I'm attempting to use ML.NET to build a model for a simple text classification, but using the CPU rather than GPU due to lacking one with CUDA. However, trying to execute my current code results in ...
Thomas Coleman's user avatar
0 votes
1 answer
71 views

PyTorch in C++ - how to get part of tensor for all dimensions?

I have the following tensor operation in Python: A = A[ :, h_offset:h_offset + fineSize, w_offset:w_offset + fineSize ] where *_offset and fineSize are some integers. I am ...
rbaleksandar's user avatar
  • 9,581
0 votes
0 answers
78 views

cmake libtorch build issue

I'm not used with working with cmake. Currently I'm building libtorch with cmake according to this guide here. However during the build an error message appears "CMake Error at C:/lib_sources/...
user19905318's user avatar
3 votes
2 answers
250 views

libtorch can't detect CUDA, while CUDA runtime can

#include <cuda_runtime.h> #include <torch/torch.h> #include <iostream> int main() { std::cout << "CUDA device count: " << torch::cuda::device_count() <&...
yegor's user avatar
  • 51
0 votes
0 answers
49 views

Cannot forward model in Pytorch Lite 1.9.0 in Android native app

I am building a android app with Java, C++, libtorch. My light model is VQA which task 4 args: image_features, input_ids, attention_mask, token_type_ids. Currently, I cannot forward the inputs. It ...
Huy Huynh Hoang's user avatar
-1 votes
1 answer
78 views

Cannot open file: extension.h, but IncludePath is set [duplicate]

Using VS Code launched from Visual Studio 2019 professional developer terminal (windows 11). I am trying to include torch/extension.h by including the path of the conda environment in which I have ...
Erik 's user avatar
0 votes
0 answers
58 views

I get an error when using libtorch in Rust on windows 11

I wanted to create a program in Rust that uses libtorch to read yolo models and identify what is on the screen, but I am stuck at the beginning of the process. I am using windows 11. Below is the ...
Takumi Fukuo's user avatar
0 votes
0 answers
42 views

Which api in `libtorch` corresponding the `ctx.needs_input_grad` in pytorch when to define custom `torch.autograd.Function`?

When I tanslate the following python code to cpp code with libtorch api class _SphericalHarmonics(torch.autograd.Function): """Spherical Harmonics""" @...
Zhiguo Tang's user avatar
0 votes
0 answers
85 views

Error running code using Libtorch C++ Windows (VS2022). Intel MKL FATAL ERROR

After Installing MKL I can't find those dll files. And the error continues. Intel MKL FATAL ERROR: cannot load mkl_vml_avx2.1.dll or mkl_vml_def.1.dll, at runtime. Libtorch Distrib I'm using is: CUDA ...
David Huelves Ramos's user avatar
2 votes
1 answer
105 views

Weird behavior from CUDA (Libtorch) and OpenGL interop [closed]

I am trying to write functions to transform an OpenGL texture to a PyTorch tensor and back in a C++ app. To test that it works I added 128 to the tensor to basically brighten the image, and then ...
asmo_192's user avatar
1 vote
0 answers
332 views

How I can load model and inference using Libtorch (C++)?

I trained simple model for MNIST using it https://github.com/pytorch/examples/blob/main/cpp/mnist/mnist.cpp I added code for saving model like below string model_path = "model.pt"; torch::...
John's user avatar
  • 25
0 votes
0 answers
347 views

Getting started with Libtorch in C++

having some trouble getting a basic nn Module working with libtorch. I’m trying to copy the example found here Using the PyTorch C++ Frontend — PyTorch Tutorials 2.3.0+cu121 documentation #include <...
brando f's user avatar
  • 421
0 votes
0 answers
58 views

Why can inconsistent function names be called correctly in the scenario of calling functions defined by c++in python code?

I saw a project on GitHub that involved Python code to call functions defined in C++. Strangely, the function name defined in C++ is A, but it can be called through the name B in Python, where A and B ...
DEAD SUMMER's user avatar
0 votes
0 answers
126 views

No such file error loading pytorch model on c++

I am working on an AI for an open source game. But when I try to load the pt file (the pytorch model) onto c++ using <torch/script.h> library, the program fails to execute torch::jit::script::...
Alejandro Guerena Gonzalez's user avatar
0 votes
0 answers
76 views

C++ Extension for PyTorch - Missing DLL

I'm writing a C++ extension for PyTorch on Windows in Visual Studio 2022. Everything compiles correctly, but both ways I've tried (via CMake and via a setup.py file) I get the same error when ...
Quaere Verum's user avatar
0 votes
0 answers
42 views

How to trace pytorch flow to CPP

My goal is being able to adjust the backend of distributed functions according to requirements. For example, I wish to be able to change a failed GPU to be substituted with a constant value tensor ...
Hod Badihi's user avatar
0 votes
0 answers
142 views

Loading traced pytorch model to C++

Will be grateful for any help :( I'm having a problem with using pytorch pretrained model in C++ via TorchLib. I've added Torchlib to Cmake and it successfully downloads the model and works until line:...
Pashar's user avatar
  • 1
0 votes
0 answers
34 views

Error when linking Libtorch with OpenFOAM: Two or more data types in declaration error, C++14

I am trying to link a custom library of (type of combustion class) OpenFOAM with Libtorch for a custom class. When I include some libtorch headers (for example: <torch/torch.h> ) I receive a ...
SS93's user avatar
  • 1
0 votes
0 answers
137 views

Can not load scripted model using torch::jit::load

I use torch.jit.script to save model and using C++ to load it: #include <torch/script.h> using namespace std; int main() { std::string model_path = "G:/modelscriptcuda.pt"; ...
闫学习's user avatar
0 votes
0 answers
178 views

Is there a way to use a specific Pytorch model image processor in C++?

I would like to use a pretrained image segmentation AI model developed with Pytorch in my C++ program. For that I have to convert it into TorchScript in order to be able to use it in my said program, ...
Pierre Thomas's user avatar
0 votes
0 answers
51 views

Missing symbols when building UE 5.3.2 based project with libtorch dependency

I have a UE 5.3.2 based project with a libtorch included. I'm using libtorch 2.1.0+cpu. The linker error I have is: 1>------ Building 2 action(s) started ------ 1>[1/2] Link [x64] UnrealEditor-...
Mykola's user avatar
  • 435
0 votes
0 answers
39 views

How to transfer data between Aramdillo matrix and LibTorch tensor?

I am trying to transfer data between Aramdillo matrix and LibTorch tensor. I referenced this project, but the conversion failed in my Linux environment. Then I tried to convert using the from_blob ...
一碗给力嗯's user avatar
1 vote
1 answer
247 views

C program using a wrapper libtorch c++ library not linking

I'm trying to make a libtorch c++ library to use it in a C program, exporting library functions with extern "C". The library seems to compile and link correctly. But the main executable ...
Bertrand125's user avatar
  • 1,002
0 votes
0 answers
380 views

Issues setting up LibTorch on Windows 11

Hello and thanks in advance! When following the official LibTorch installation guide, I ran across a four separate errors when building the project. I have not found solutions to the last two errors ...
Evan Abbott's user avatar
1 vote
1 answer
56 views

Why might the single act of linking against a library drastically degrade the runtime of a C++ program?

I have a reasonably large C++ project, and I would like to add LibTorch as a dependency. I've downloaded the pre-built LibTorch libraries from the website, and updated my CMakeFile as follows: ...
user2667523's user avatar
0 votes
0 answers
160 views

LoadLibrary error while using libtorch with ROS2

I am trying to build and run a ROS2 package which uses libtorch. In CMakeLists.txt I wrote set(Torch_DIR ~/libtorch/share/cmake/Torch/) find_package(Torch) ament_auto_add_library(my_lib SHARED src/...
Ars ML's user avatar
  • 147
0 votes
0 answers
244 views

Allowed data types in torch.jit.trace()

I want to save a segmentation model pipeline to a mobile optimized model that I can run on iOS or call from a C++ program. I am using two pretrained models, whose code I can not change. I am majorly ...
Nitya Patel's user avatar
0 votes
0 answers
43 views

compatibility between nvidia driver and cuda [duplicate]

I have a RTX 4070 and it said nvidia-driver-535 is recommended. and I installed the driver. but when I type nvidia-smi, it said CUDA version: 12.2 but I want to get CUDA 11.8 or 12.1 Question : ...
Hyeonseop Lim's user avatar
0 votes
0 answers
114 views

Crash of the software when forwarding a libtorch model

My software is crashing when I try to forward my libtorch model and I don't understand why. I compiled with Visual Studio 2019 (v142), ISO C++20, libtorch 2.0.0+cu118 Here is the code: struct ...
Laurick's user avatar
0 votes
0 answers
55 views

Memory address are the same after creating new tensor

std::map<std::string, torch::Tensor*> tmpFloatActivations = model.getActivations(); std::map<std::string, torch::Tensor*> floatActivations; floatActivations.insert(tmpFloatActivations....
alryosha's user avatar
  • 743
0 votes
0 answers
56 views

libtorch forward result unexpected

I use a small net. The net converges and the accuracy is 1.0 after 400 iterations. So far, so good. conv1(torch::nn::Conv2dOptions(1, 15, /*kernel_size=*/3)), conv2(torch::nn::Conv2dOptions(15, 30,...
Dirk10000's user avatar
0 votes
0 answers
91 views

How to link torch in leveldb, and use leveldb in YCSB-cpp?

I want use torch (C++ version of pytorch) in leveldb, and link leveldb in YCSB-cpp to benchmark it. I can not install torch and leveldb in system path, because I using public sever. I got some error ...
王听正's user avatar
0 votes
0 answers
72 views

Solving LNK4022 (not a unique symbol "Initialize" found) without changing export.def

I am trying to solve an LNK4022 issue (not a unique symbol "Initialize" found) but I can't modify the export.def file. The release is a DLL which can only be read by the final software if ...
Laurick's user avatar
0 votes
0 answers
104 views

torch.jit.script Error for nn.Module attributes in the __init__: Module has no attribute

I am trying to use torch.jit.script to script the demucs audio separation ML model. Ultimately, I'm trying to make the model compatible with coreml to use it in an iOS app RuntimeError: Module '...
gnadel's user avatar
  • 9
1 vote
0 answers
124 views

best way to create libtorch (tch-rs) tensor from polars dataframe

What would be the most efficient way to create libtorch (tch-rs) tensor from polars dataframe? I can only make it working with as_slice->from_slice like Tensor::from_slice( series.f64()? ....
user656449's user avatar
  • 3,032
0 votes
0 answers
64 views

How to convert at::ScalarType to c++ type?

I have a template class have two typename // key maybe uint32_t or uint64_t, elem can be any interger or float type template <typename KeyType, typename ElemType> class Cache{ // .... }; I ...
shadow's user avatar
  • 105
1 vote
0 answers
73 views

Callgrind for CUDA program, execution time in percentages do not add up to 100%

I have a CNN image classification C++ program that uses LibTorch(Pytorch)/CUDA to improve the inference performance. I try using Callgrind: valgrind --tool=callgrind ./my-bin to profile it and find ...
D.J. Elkind's user avatar
0 votes
1 answer
614 views

Issue building Libtorch Rust Projects

Apologies if this isn't the best place to post this. I'm trying to learn how to do Pytorch in Rust. Have previous experience with Libtorch in C++ and Pytorch in Python. I'm running into issues setting ...
rootware's user avatar
0 votes
0 answers
89 views

Different results PyTorch vs Libtorch

I am trying to calculate a disparity image for the same traced model in python and c++ but I am getting different outputs. I tried and follow the same steps in c++ as in python but it seems I missed ...
anaandreea's user avatar

1
2 3 4 5
7