314 questions
0
votes
1
answer
59
views
Linking matplot++ and Libtorch together in a program causes memory corruption problem
I made a minimal example that crashes. For the crash it is required that the torch libraries are linked. I made sure that GLIBCXX_USE_CXX11_ABI=0 for all 3 components. Setup is Ubuntu, g++, C++17.
Any ...
0
votes
1
answer
11k
views
CUDA error: no kernel image is available for execution on the device
Im using the latest LibTorch with CUDA 12.6 installed on Windows 10
Libtorch is showing CUDA is available, however, I get this error when I try to use
device = torch::Device(torch::kCUDA, 0);
...
3
votes
0
answers
71
views
Efficiency of torch matrix operations on CPU
I am currently working on optimizing PyTorch code running on CPU. On CUDA, you can write fused multiple operators into specialized kernels to reduce memory transfers, avoid intermediate data ...
1
vote
0
answers
107
views
Error loading model using Torch TensorRT in Libtorch on Windows
Environment
Libtorch 2.5.0.dev (latest nightly) (built with CUDA 12.4)
CUDA 12.4
TensorRT 10.1.0.27
PyTorch 2.4.0+cu124
Torch-TensorRT 2.4.0
Python 3.12.8
Windows 10
Compile Torch-TensorRT with ...
0
votes
0
answers
40
views
How do I initialize a model with known weights in torch / luz?
The problem I am faced with is to be able to fit a series of models starting with progressively different inputs.
I am using the R interface to torch for this, which is based on pytorch. I have to use ...
1
vote
0
answers
43
views
Segmentation fault when trying to copy memory from Gst buffer to torch tensor using torch::from_blob::clone()
I'm getting a segmentation fault when I'm trying to copy memory from gst buffer to torch tensor. Here is code. I'll mark where the segfault originates from:
static GstPadProbeReturn on_probe(
...
2
votes
1
answer
159
views
Can a PyTorch Model Built in Debug Mode Be Used in Release Mode? TorchScript Model Load Error in Release Mode but Works in Debug Mode
I'm encountering an issue when trying to load a TorchScript model in my C++ application using LibTorch. The model loads and works fine in debug mode, but I get an exception when switching to release ...
0
votes
0
answers
40
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 ...
1
vote
0
answers
163
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++ ...
1
vote
0
answers
58
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 (...
1
vote
1
answer
159
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 ...
4
votes
0
answers
85
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&...
0
votes
1
answer
323
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 ...
-1
votes
1
answer
149
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 ...
0
votes
0
answers
103
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 ...
1
vote
1
answer
1k
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::...
0
votes
0
answers
46
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 ...
0
votes
0
answers
668
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 ...
0
votes
0
answers
50
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 :
...
0
votes
0
answers
80
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,...
2
votes
1
answer
234
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()?
....
0
votes
1
answer
922
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 ...
1
vote
0
answers
96
views
Torchlib shared library segfaults
I'm trying to run example of object detection using YOLO and libtorch. Here is the source code:
//main.cpp
#include <ATen/core/stack.h>
#include <opencv2/core.hpp>
#include <opencv2/...
1
vote
0
answers
54
views
Is it possible to build pytorch to dlopen from a separate libtorch installation?
I'd like to reuse my Linux libtorch installation in Pytorch as well. The benefits would be:
reducing unpacked Python package size by ~600MB of shared objects
certainty that I'm using the same backend ...
1
vote
0
answers
491
views
How to control GPU memory in libtorch/CUDA on Windows
My problem is not related to the code, it is related to the "GPU memory" listed in the Windows task manager.
Briefly about the problem: I have an RTX4090 video card with 24GB of video memory....