akankshakshurai/cuda-error-resolution-analysis huggingface dataset:
NaN coming after the first iteration during training

username: C11en
cooked: <p>The loss function is L1 loss.<br>
Now I will make some assumptions to make my question better understood.<br>
My model is f(x) like and the x is the input of my model, there will be nothing wrong when I training f(x) individually, but when I try to make multiplication ( x * f(x) ) in my model, the NaN will occur after one iteration.<br>
And I also tried to use torch.autograd.set_detect_anomaly(True), I found all my data become NaN in my model.</p>
<p>Thanks in advance.</p>

username: JuanFMontesinos
cooked: <p>The most likely case is<br>
A) You have training data with NaN’s (due to issues in preprocessing)<br>
B) You have some operation that produces a NaN during inference.</p>

username: Preston_Brubaker
cooked: <p>Decrease your learning rate significantly at least to start. After some training, you should be able to increase it a bit. NaN usually happens when there are very large gradients, causing unstable training.</p>

username: lilamonroe
cooked: <p>Hello,<br>
Can you please explain this in more.</p>
Torch.matmul launch different CUDA kernel from cublas

username: sleepwalker2017
cooked: <p>Does torch.matmul always call the fastest cuda kernel ?</p>
<p>I tested torch.matmul and cublas matmul, I find there are some difference between the kernels and performance.</p>
<p>I thought they would call the same kernel, and thus always get the same performance, but seems they call different cuda kernels.</p>
<p>Why is that?</p>
<p>Does torch.matmul always have the same performance with cublas?</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/2/5/2542f57d710a5c6c80c9e4980952da40ec0b17f8.png" data-download-href="https://discuss.pytorch.org/uploads/default/2542f57d710a5c6c80c9e4980952da40ec0b17f8" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/2/5/2542f57d710a5c6c80c9e4980952da40ec0b17f8_2_690x94.png" alt="image" data-base62-sha1="5jD7LB0LsPa3bIxaTOhaziEnwWA" width="690" height="94" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/2/5/2542f57d710a5c6c80c9e4980952da40ec0b17f8_2_690x94.png, https://discuss.pytorch.org/uploads/default/original/3X/2/5/2542f57d710a5c6c80c9e4980952da40ec0b17f8.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/2/5/2542f57d710a5c6c80c9e4980952da40ec0b17f8.png 2x" data-dominant-color="F4F4F5"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1025×141 29.3 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>Thank you!</p>
<p>The code I’m using</p>
<pre data-code-wrap="c++"><code class="lang-c++">void cublasTensorOp(half *A, half *B, half *C, size_t M, size_t N, size_t K) {
    static cublasHandle_t handle = getCublasTensorOpHandle();
    static half alpha = 1.0;
    static half beta = 0.0;

    HGEMM_CHECK_CUBLAS_ERROR(cublasGemmEx(handle, CUBLAS_OP_T, CUBLAS_OP_N, N, M, K, 
                                          &amp;alpha, B, CUDA_R_16F, K, A,
                                          CUDA_R_16F, K, &amp;beta, C, CUDA_R_16F, N, 
                                          CUBLAS_COMPUTE_32F,
                                          CUBLAS_GEMM_DEFAULT_TENSOR_OP));
}
</code></pre>
<pre data-code-wrap="python"><code class="lang-python">import torch
a = torch.ones((4096, 5120), dtype=torch.float16).cuda()
b = torch.ones((5120, 2*27648), dtype=torch.float16).cuda()

c = torch.ones((4096, 2*27648), dtype=torch.float16).cuda()

torch.matmul(a, b, out = c)

cnt = 1000
torch.cuda.synchronize()
import time
start = time.time()
for i in range(cnt):
    torch.matmul(a, b, out = c)

torch.cuda.synchronize()
end = time.time()

print((end - start)*1000/cnt)
</code></pre>

username: ptrblck
cooked: <p>Did you compare your cublas implementation against the one used in PyTorch?</p>

username: sleepwalker2017
cooked: <p>you mean performance? or the source C++ code inside pytorch matmul?</p>
<p>I didn’t trace into pytorch to see the invocation.</p>
Install CUDA in a Laptop with RTX 3050 but version 12.1

username: Shagy
cooked: <p>Okay I had the a lot of problems installing CUDA cause I did not understand how, here are some suggestions for whoever have the problem:<br>
Windows 11<br>
GPU: RTX 3050 (portable/Laptop)<br>
Python: 3.12.4</p>
<ol>
<li>
<p>Download Visual Stdio Community 2019 (V. 16.11), download ALL then install.</p>
</li>
<li>
<p>I am using anaconda envs, so these is the command that worked for me:<br>
conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia</p>
</li>
</ol>
<p>3)From Cuda ToolkitArchive, the version 12.1.0 (February 2023), link here: <a href="https://developer.nvidia.com/cuda-toolkit-archive" class="inline-onebox" rel="noopener nofollow ugc">CUDA Toolkit Archive | NVIDIA Developer</a></p>
<ol start="4">
<li>From CUDNN, selected the versio v8.9.7 for CUDA 12.x (december,5th,2023): <a href="https://developer.nvidia.com/rdp/cudnn-archive" class="inline-onebox" rel="noopener nofollow ugc">cuDNN Archive | NVIDIA Developer</a></li>
</ol>
<p>5)Replace (overwrite/replace) the docs from ProgramFiles/NVIDIA GPU Computing Toolkit/Cuda/YourVersion (Same as download), replace the different files from the cudnn…download (the ones in the Folders → include, lib, bin to the rogramFiles/NVIDIA GPU Computing Toolkit/Cuda/YourVersion)</p>
<ol start="6">
<li>
<p>In my case the Enviroment Variables were not necesarry change them</p>
</li>
<li>
<p>Install in yoru CONDA Envioroment with the next command:<br>
conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia</p>
</li>
</ol>
<p>At the end, using the next lines of code:</p>
<p>import torch</p>
<p>print(torch.<strong>version</strong>)<br>
print(torch.cuda.is_available()) correctamente<br>
print(torch.cuda.get_device_name(0))</p>
<p>I got the next:<br>
2.3.1<br>
True<br>
NVIDIA GeForce RTX 3050 Laptop GPU</p>
<p>Some of the solutions (as the correct instalation of the binaries where extract from this video: <a href="https://www.youtube.com/watch?v=r7Am-ZGMef8" rel="noopener nofollow ugc">https://www.youtube.com/watch?v=r7Am-ZGMef8</a> → SL7 Tech / “How to setup NVIDIA GPU for Pytorch on windows 10/11”)</p>
How to disable fake_tensor mode in torch.compile

username: Vaen_Joe
cooked: <pre><code class="lang-auto">def _base_backend(gm: torch.fx.GraphModule, example_inputs):
    # Set up the session, context and invocation.
    # Note that we do this on one in-memory module in a few phases:
    #  1. Build it from the FX graph.
    #  2. Run torch MLIR passes to lower it to a suitable form for
    #     input.
    #  3. Run IREE's main compiler.
    #  4. Output to an mmap buffer.
    example_input0 = example_inputs[-1]
    print(type(example_input0))
</code></pre>
<p>Above is a code sample in shark-turbine cpu.py, example_inputs is model input and parameters, but it is a faketensor. I want to dump my parameters here but I do know faketensor is no-data designed. So I want to ask is there some way to dump parameters? Disable faketensor mode or some else?</p>

username: Vaen_Joe
cooked: <p>After a lot of check and test, I found that there is no way to dump data from fake tensor, you should jump to the place where you really use the data if you really want to do that.</p>

username: ezyang
cooked: <p>The internal function <code>maybe_disable_fake_tensor_mode</code> in torch.fx.experimental.proxy_tensor may be useful.</p>
When should I detect a fake tensor mode?

username: mhs4670go
cooked: <p>Hello.</p>
<p>I’m writing a constant folding pass of the fx graph that is made by <code>torch.export.export</code>.</p>
<p>When I update a meta data for newly created nodes, I’m using fake mode like below.</p>
<pre data-code-wrap="python"><code class="lang-python">new_node.meta["val"] = fake_mode.from_tensor(
            prop_constant_tensor, static_shapes=True
        )
</code></pre>
<p>But I couldn’t find the document about where I should get a fake tensor mode. I guess there are two options.</p>
<ol>
<li>Detect the existing mode</li>
</ol>
<pre data-code-wrap="python"><code class="lang-python">def get_fake_mode(exported_program: ExportedProgram):
    fake_mode = detect_fake_mode(
        tuple(
            node.meta["val"]
            for node in exported_program.graph.nodes
            if node.op == "placeholder"
        )
    )
    assert fake_mode is not None
    return fake_mode
</code></pre>
<ol start="2">
<li>Create new one</li>
</ol>
<pre data-code-wrap="python"><code class="lang-python">def get_fake_mode():
    return FakeTensorMode()
</code></pre>
<p>Which one is better? Is it okay for me to create a new <code>FakeTensorMode</code> every time when a fake mode is needed? Or should I detect the fake mode?</p>

username: ezyang
cooked: <p>detect_fake_mode is better because if the export in question has dynamic shapes, you want to reuse the old FakeTensorMode which has a ShapeEnv tracking the dynamic shapes. If it’s all static shapes and your fake tensor usage doesn’t escape, it doesn’t really matter.</p>
How to do bilinear interpolation?

username: ryan_chandra
cooked: <p>I have some coordinates with shape (bs, x, y) and want to do bilinear interpolation on some input with shape (bs, C, H, W). When I check to the documentation, one way to do bilinear interpolation is by using " torch.nn.functional.grid_sample" but the input must be in grid. Is there any way to do this with the coordinate instead of grid?</p>
1d CNN model bad at generalization

username: L_Z
cooked: <p>I have designed a 1d CNN with 2 main blocks each has 2 layers of 1d CNN and I am using layer norm. But when I am testing my model, I feel like it is bad at generalization. So my guesses are it is because the model cannot pick up major features from my data which causes it overfit my training data.</p>
<p>I have increased the number of epochs and add in more new data to the validation set just to avoid data leakage. The model gets a bit better with increasing in the testing accuracy, but the issue is still there.</p>
<p>Any thoughts on how should I improve my model? Or maybe I think how to let the model to focus on the global features and trend instead of the locals? And I normalized my data over the range of 1 to -1. I do not know if this is the reason that is causing the overfit/bad generalization.<br>
Thanks in advance.</p>
Seeds for Dataloader

username: thistlillo
cooked: <p>I am looking at this page to understand how I can aspire to reproducibility:<br>
<a href="https://pytorch.org/docs/stable/notes/randomness.html" class="onebox" target="_blank" rel="noopener nofollow ugc">https://pytorch.org/docs/stable/notes/randomness.html</a></p>
<p>Specifically, this code:</p>
<pre><code class="lang-auto">def seed_worker(worker_id):
    worker_seed = torch.initial_seed() % 2**32
    numpy.random.seed(worker_seed)
    random.seed(worker_seed)

g = torch.Generator()
g.manual_seed(0)

DataLoader(
    train_dataset,
    batch_size=batch_size,
    num_workers=num_workers,
    worker_init_fn=seed_worker,
    generator=g,
)
</code></pre>
<p>I cannot understand this line:</p>
<pre><code class="lang-auto">g.manual_seed(0)
</code></pre>
<p>Questions:</p>
<ul>
<li>has 0 a special meaning?</li>
<li>what if I want to use the seed 1?</li>
</ul>
<p>Suppose I have already set the seed to the value 1 as indicated at the beginning of the same page, so that <code>torch.initial_seed() == 1</code>. Should I keep 0 in that line?</p>

username: ignaciobartol
cooked: <p>Hello! The line <code>g.manual_seed(0)</code> is setting the seed of the random number generator <code>g</code> to 0.<br>
Just to let you know, I was looking at the tutorial and 0 does not have any special meaning but is just used throughout the tutorial, so it will make sense to stick with 0. It is simply an example seed value used in the code.</p>
<h3><a name="should-i-keep-0-in-that-line-if-torchinitial_seed-1-1" class="anchor" href="#should-i-keep-0-in-that-line-if-torchinitial_seed-1-1"></a>Should I keep 0 in that line if torch.initial_seed() == 1?</h3>
<p>No, you should set the seed in <code>g.manual_seed()</code> to match the seed you want to use throughout your code for reproducibility. If you have already set the seed to 1 using <code>torch.manual_seed(1)</code> at the beginning, you should use the same seed value consistently.</p>
LSTM - GRU speed on CPU and GPU

username: Andrea_Ferrari
cooked: <p>Dear all,</p>
<p>I trained two neural networks using PyTorch: one with <code>torch.nn.LSTM</code> and the other with <code>torch.nn.GRU</code>. Both models have identical structures and hyperparameters (same number of layers, neurons, etc.). I wanted to test the prediction speed of these models on my laptop (Dell XPS 15 i7-10750H CPU NVIDIA GeForce GTX 1650 Ti).</p>
<p>When using the GPU via CUDA, the prediction speeds are similar, with the LSTM model being slightly slower than the GRU model (0.893404 ms vs. 0.78311 ms on average). However, on the CPU, the prediction speeds differ significantly: the LSTM model is much faster than the GRU model (0.849297 ms vs. 3.635143 ms). Interestingly, the LSTM model’s prediction speed on the CPU is even faster than on the GPU.</p>
<p>I also tested the models on another computer with a GPU, and while the absolute speeds varied, the pattern was the same: similar performance on the GPU and the LSTM much faster than the GRU on the CPU.</p>
<p>How is this possible? Is PyTorch utilizing some sort of optimization for LSTM on the CPU?</p>
<p>Thanks in advance!</p>
The most efficient way to find value of spikes on pyplots

username: Geetanjli_sharma
cooked: <p><img src="https://discuss.pytorch.org/uploads/default/original/3X/c/e/cefe2873a55c6e80cd422cc4ffa8a68d0c0b63ee.jpeg" alt="demo" data-base62-sha1="tx8TaXoRzxpSSRHn2BrekNdsn7g" width="547" height="409"><br>
I am trying to plot accuracy that shows some spikes at certain training rounds… My question is how can I find that there is a sudden spike in the graph and eventually which nodes are having the spike…</p>
<p>I tried to apply the quantile method, but that also returns a value for no spikes round as well. Can I get any method which just returns true positives and not false positives.</p>

username: Brock_Brown
cooked: <p>If I were you, I would take three samples side by side and determine if there’s a bump in the middle. If there’s a bump, note the size of the bump. If the bump is bigger than any previous bumps, mark the location and value of the bump. Do this for every location in the graph.</p>
<pre data-code-wrap="python"><code class="lang-python">graph = [1, 5, 1, 2, 1]

def spike_value(graph):
    spike_record = 0
    spike_location = 0
    spike_value = None
    for i in range(len(graph) - 2):
        chunk = graph[i:i+3]
        left, middle, right = chunk
        # if it's a bump
        if middle &gt; left and middle &gt; right:
            bump_size = ( (middle - left) + (middle - right) )  / 2
            if bump_size &gt; spike_record:
                spike_location = i + 1
                spike_record = bump_size
                spike_value = middle
    return spike_value

print(spike_value(graph))
</code></pre>
<p><sub>note: this algorithm will not detect the spike if the spike location is either at the very beginning or very end of the graph</sub></p>

username: Geetanjli_sharma
cooked: <p>Thanks <a class="mention" href="/u/brock_brown">@Brock_Brown</a>… but the the spike location gone unnoticed at beginning or end would be an issue., and also I think this won’t work in the case where there will be multiple spikes at one particular instance…</p>
Autograd of a matrix with respect to a scalar

username: GoldenalCheese
cooked: <p>Is there an efficient way to remove the for-loop? Maybe use <code>torch.vmap</code>?</p>
<pre><code class="lang-auto">import torch

a = torch.tensor([1.0], requires_grad=True)

b = torch.exp(torch.rand(100, 100)) * a
grad = torch.zeros(100, 100)

for i in range(b.shape[0]):
    for j in range(b.shape[1]):
        grad[i, j] = torch.autograd.grad(b[i, j], a, create_graph=True)[0]

print(grad)

</code></pre>

username: GoldenalCheese
cooked: <p>No worry. I found <code>torch.autograd.functional.jacobian</code>. It works for a <code>func</code>, for a <code>nn.Module</code>, we need a little more workaround as discussed here: <a href="https://github.com/pytorch/pytorch/issues/49171" class="inline-onebox" rel="noopener nofollow ugc">NN Module functional API · Issue #49171 · pytorch/pytorch · GitHub</a></p>

username: KFrank
cooked: <p>Hi Cheese!</p>
<p>Backward-mode automatic differentiation naturally gives you the gradient<br>
of a scalar function, that is, the (partial) derivatives of that scalar with<br>
respect to the elements of one or more tensors.</p>
<p>Conversely, <a href="https://pytorch.org/docs/2.3/autograd.html#forward-mode-automatic-differentiation" rel="noopener nofollow ugc">forward-mode automatic differentiation</a> naturally gives you the<br>
derivatives of the elements of one or more tensors with respect to a single<br>
scalar, and it does so with a single forward-mode pass.</p>
<p>For your specific example, that’s the best way to go.</p>
<p>Best.</p>
<p>K. Frank</p>
Scatter_add with two index tensor

username: jwlai
cooked: <p>Dear all,</p>
<p>suppose I have two index[N] and a src[M,N] tensor defined by</p>
<pre><code class="lang-auto">M, N, K = 1000, 100, 512
target = torch.zeros(M, N, N)
src = torch.randn(M, K)
index1 = torch.randint(0, N, (N,))
index2 = torch.randint(0, N, (N,))
</code></pre>
<p>How could I perform</p>
<pre><code class="lang-auto">for i in range(M):
  for j in range(K):
    target[i,index1[j],index2[j]] += src[i,j] 
</code></pre>
<p>by using <code>tensor.scatter_add_</code> or anything to accelerate this calculation as M, K are actually very large in actual calculation</p>

username: ptrblck
cooked: <p>I guess flattening the last two dimensions and creating a new indexing tensor should work. (I’m not at my workstation so cannot post a code snippet showing this approach right now)</p>
Ddp with slurm hangs when ntasks-per_node>1

username: divyanshu_mishra1
cooked: <p>Hello <a class="mention" href="/u/ptrblck">@ptrblck</a> ,</p>
<p>I am trying to run a ddp code with slurm. When I use the below sbatch commands, the model is training in parallel.</p>
<pre><code class="lang-auto">#!/bin/bash
#SBATCH --cpus-per-task=4      # CPU cores per task
#SBATCH --gres=gpu:2             # Number of allocated GPUs per node
#SBATCH --ntasks-per-node=1              # Number of tasks (processes)
#SBATCH --nodes=1                # Number of nodes
#SBATCH --job-name=videomae      # Job name
#SBATCH --output=videomae_%j.log # Standard output and error log
</code></pre>
<p>However, when I set --ntasks-per-node=2, which is how people usually do. The code is stuck as distributed init as shown below.</p>
<pre><code class="lang-auto">World_size 2
| distributed init (rank 0): env://, gpu 1
World_size 2
node04:163609:163609 [0] NCCL INFO Bootstrap : Using ib0:XXX.XXX.XXX.XXX&lt;0&gt;
node04:163609:163609 [0] NCCL INFO NET/Plugin : dlerror=libnccl-net.so: cannot open shared object file: No such file or directory No plugin found (libnccl-net.so), using internal implementation
node04:163609:163609 [0] NCCL INFO cudaDriverVersion 12020
NCCL version 2.20.5+cuda11.8
node04:163610:163610 [1] NCCL INFO Bootstrap : Using ib0:XXX.XXX.XXX.XXX&lt;0&gt;
node04:163610:163610 [1] NCCL INFO NET/Plugin : dlerror=libnccl-net.so: cannot open shared object file: No such file or directory No plugin found (libnccl-net.so), using internal implementation
node04:163610:163610 [0] NCCL INFO cudaDriverVersion 12020
NCCL version 2.20.5+cuda11.8
node04:163609:164050 [0] NCCL INFO NET/IB : Using [0]hfi1_0:1/IB ; OOB ib0:XXX.XXX.XXX.XXX&lt;0&gt;
node04:163609:164050 [0] NCCL INFO Using non-device net plugin version 0
node04:163609:164050 [0] NCCL INFO Using network IB
node04:163610:164059 [0] NCCL INFO NET/IB : Using [0]hfi1_0:1/IB ; OOB ib0:XXX.XXX.XXX.XXX&lt;0&gt;
node04:163610:164059 [0] NCCL INFO Using non-device net plugin version 0
node04:163610:164059 [0] NCCL INFO Using network IB

</code></pre>
<p>Please help,</p>
Cannot export pytorch to ONNX and import ONNX to opencv

username: edamondo
cooked: <p>Hi,</p>
<p>I would like to export a network that I created with onnx and then import it in opencv. Here is a minimal working example</p>
<pre><code class="lang-auto">import torch
import torch.nn as nn
import cv2 as cv
import torch.nn.functional as F

class Network(nn.Module):
    def __init__(self, in_channels, out_channels):
        super().__init__()
        self.conv1 = nn.Conv1d(in_channels, 1, kernel_size=3, padding='same')
        nn.init.normal_(self.conv1.weight, mean=0.0, std=1.0)
        self.conv2 = nn.Conv1d(2, 1, kernel_size=3, padding='same')
        nn.init.normal_(self.conv2.weight, mean=0.0, std=1.0)
        self.upconv = nn.ConvTranspose1d(1, out_channels, kernel_size=2, stride=2)

    def forward(self, x):
        convolved = self.conv1(x)
        pooled = F.max_pool1d(input=convolved, kernel_size=2)
        upconvolved = self.upconv(pooled)
        concatenated = torch.cat((convolved, upconvolved), dim=1)
        final = self.conv2(concatenated)
        return final

network = Network(1, 1)
dummy_input = torch.tensor([1.0, 2.0, 3.0, 5.0], dtype=torch.float32).reshape(1, 1, -1)
output = network(dummy_input)

torch.onnx.export(network,
                  dummy_input,
                  "dummy_model.onnx",
                  export_params=True,
                  opset_version=15,
                  do_constant_folding=True,
                  input_names=['input'],
                  output_names=['output'],
                  dynamic_axes={'input': {0: 'batch_size'}, 'output': {0: 'batch_size'}})

net = cv.dnn.readNetFromONNX("dummy_model.onnx") ###### exception thrown here #####

input_array = dummy_input.numpy()
input_array = input_array.reshape(1,1,1,-1)
net.setInput(input_array)
output = net.forward()
</code></pre>
<p>However, there is an exception thrown at the line <code>net = cv.dnn.readNetFromONNX("dummy_model.onnx")</code> which sais</p>
<pre><code class="lang-auto">
cv2.error: OpenCV(4.9.0) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\onnx\onnx_importer.cpp:1053: error: (-2:Unspecified error) in function 'cv::dnn::dnn4_v20231225::ONNXImporter::handleNode'
&gt; Node [Concat@ai.onnx]:(onnx_node!/Concat) parse error: OpenCV(4.9.0) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\layers\concat_layer.cpp:105: error: (-215:Assertion failed) curShape.size() == outputs[0].size() in function 'cv::dnn::ConcatLayerImpl::getMemoryShapes'
</code></pre>
<p>what is going on here and how can I resolve the issue?</p>
<p>I am using torch version 2.3.0 and opencv version 4.9.0</p>
RendezvousClosedError in Torchrun Elastic

username: Leandro_Libutti
cooked: <p>When I scaled down my app from 2 to 1 nodes, the rendezvous broke with “RendezvousClosedError” message. I’m sending a stop signal to the process of the node that I want to down, is that a problem? How can I test that the elasticity really works without that error?</p>
<p>I am launching torchrun on both machines as follows:<br>
torchrun --nnodes=1:2 --nproc-per-node=1 --max_restarts=3 --rdzv_id=1 --rdzv_backend=c10d --rdzv_endpoint=[IP-HOST]:29500 app.py</p>
<p>After one training epoch I send “kill -9 [PID]”, where PID is the worker process of node 2.</p>
<p>Best regards!</p>
Right loss function for VAE with word2vec (cbow and skipgram)

username: CR_DL
cooked: <p>Hi Everyone,</p>
<p>Can anyone suggest a good loss function for training and to analyse the validation performance for VAE implemented for CBOW and Skipgram (word2vec). If you can suggest an online code for word2vec with VAE would be much appreciated.</p>
<p>Thank you very much!</p>
Traffic of Distributed Data Parallel (DDP) using CPU

username: omidnr
cooked: <p>while using Distributed data parallel of Pytorch on CPU, I used CIFAR10 dataset , I run on two servers just with cpu and captured the traffic . i have two question, first is the master node during the whole process also does the computation and meanwhile sending packets to worker or no? second is why there is heavy flow always and why it doesn’t have steady line then sometimes during each epoch it doesn’t make peaks and it has always heavy flow?  because I was expecting a peak on each epoch that nodes do the backward pass but there are always packets going and returning</p>
<p>*I know the CPU is not suitable for this reason but it’s just an experiment</p>
KMeans Clustering on GPU with Torch

username: Nafees_Ahmad
cooked: <p>I have a tensor x of shape <code>[32, 10, 128]</code>, where:</p>
<ul>
<li>
<p><code>32</code> is the batch size,</p>
</li>
<li>
<p><code>10</code> represents nodes,</p>
</li>
<li>
<p><code>128</code> denotes features per<br>
node.</p>
</li>
</ul>
<p>My objective is to compute node similarities based on their features across each batch input independently. Specifically, I aim to cluster nodes within each input using KMeans clustering on their feature similarities. The end goal is to aggregate nodes that are similar in feature space into clusters and then compute a representative average feature vector for each cluster.</p>
<p><strong>Key requirements:</strong></p>
<ul>
<li>Perform KMeans clustering independently for each input.</li>
<li>Utilize Torch to leverage GPU acceleration effectively to execute all the batch inputs parallelly.</li>
</ul>
<p>Could someone guide me on how to implement this efficiently in Torch?</p>

username: ptrblck
cooked: <p>Have you checked a few open-source <code>kmeans</code> implementations, e.g. <a href="https://github.com/subhadarship/kmeans_pytorch">this one</a>? If so, did it not work for you?</p>

username: Nafees_Ahmad
cooked: <p>I checked your mentioned one, but I think it would not work in my case. Thank you</p>
Extension_device test can't work

username: molojl
cooked: <p>I was start to add a new backend for pytorch out of tree, I tried to modify the <code>test/inductor/test_extension_backend.py</code> and reuse the <code>test/inductor/extension_backends/extension_device.cpp</code> to run a simple cpp_extension test, like this:</p>
<pre data-code-wrap="python"><code class="lang-python">source_file_path = os.path.dirname(os.path.abspath(__file__))
source_file = os.path.join(
    source_file_path, "extension_device.cpp"
)

module = torch.utils.cpp_extension.load(
  name="extension_device1",
  sources=[
    str(source_file),
  ],
  build_directory="./build_path",
  extra_cflags=["-g"],
  verbose=True,
)

torch.utils.rename_privateuse1_backend("extension_device1")

device = module.custom_device()
x = torch.empty(3, 16)
print(x.data_ptr())
x = x.to(device)
print(x.data_ptr())
x = x.fill_(1)
</code></pre>
<p>this code works well, but the <code>x.to(device)</code> seems not go into the <code>custom_to_device()</code> fuction in <code>extension_device.cpp</code>, in other word, I add a <code>printf()</code> the <code>custom_to_device()</code> but nothing was printed.</p>
<p>can anybody tell me how to fix this?</p>

username: molojl
cooked: <p>Problem solved,<br>
This “to.device” is just a facade. the real tensor.to will go into the custom backend’s allocate fuction,<br>
such as <code>DummyCustomAllocator::allocate fuction</code>.<br>
see :</p>
<blockquote>
<p>pytorch/aten/src/ATen/native/native_functions.yaml:7599</p>
</blockquote>
Pavement failure classification (Help!)

username: Matias_Maciel
cooked: <p>Hi everyone. My name is Matías, from Uruguay.</p>
<p>I am working to help improve procedures for a government office dedicated to road maintenance. This office has a truck equipped with a camera that can take pictures of the road and georeference each one. However, people are not using this tool because they don’t have any means to analyze the material.</p>
<p>I am trying to find a trained algorithm to detect and classify different types of pavement failures, but I haven’t found anything. I need an algorithm that can classify 20 different types of failures and measure them (area and length).</p>
<p>Do you know anything similar to what I am searching for? I was thinking of an algorithm like YOLO, first training it to detect all types of failures, and then training it again to classify the different types (for the 20 classifications).</p>
<p>Any help would be useful!</p>
<p>Thanks a lot!</p>
Behavior of trilinear interpolation when input and output depth are the same

username: null
cooked: <p>I would like to upsample a 5D tensor using the trilinear mode with torch.nn.Upsample. Specifically, I want to resize only the last two dimensions (H, W).</p>
<p>I have heard that trilinear interpolation typically uses depth information for interpolation. So my question is: If the depth remains the same between the input and the output tensor, does the trilinear mode still influence the depth dimension in any way, or is the upsampling performed independently for each depth slice?</p>
<p>Here is an example script to illustrate my question:</p>
<pre data-code-wrap="Python"><code class="lang-Python">b, c, d, h, w = 1, 10, 3, 10, 20
trg_h, trg_w = 20, 40
tensor_5d = torch.randn(b, c, d, h, w)
upsample = torch.nn.Upsample(size=(d, trg_h, trg_w), mode='trilinear')
# or upsample = torch.nn.Upsample(scale_factor=(1, 2, 2), mode='trilinear')
tensor_5d_up = upsample(tensor_5d)
</code></pre>
Floating-point masks are not supported for fast path

username: bigtree
cooked: <p>I am trying to enable the fastpath to speed up the inference in the “class MultiheadAttention()” then I hit this.<a href="https://github.com/pytorch/pytorch/blob/042d764872a6307ed2f087cf8a741b2106370207/torch/nn/modules/activation.py#L1211" class="inline-onebox" rel="noopener nofollow ugc">pytorch/torch/nn/modules/activation.py at 042d764872a6307ed2f087cf8a741b2106370207 · pytorch/pytorch · GitHub</a> “floating-point masks are not supported for fast path” .  my atten_mask is float. does that mean we have to convert it to int?</p>

username: ptrblck
cooked: <p>You should pass it as a binary mask (i.e. a <code>BoolTensor</code>). From the docs:</p>
<blockquote>
<p>Binary and float masks are supported. For a binary mask, a <code>True</code> value indicates that the<br>
corresponding position is not allowed to attend.</p>
</blockquote>
Custom convolutions

username: caffedude
cooked: <p>In standard convolutions, a 3x3 kernel can be thought of as having a center pixel and 8 neighboring pixels which are slid across the entire input image.</p>
<p>I’d like to create a convolution where the kernel shape changes as it is slid across the image. For a target “pixel”, I’d like 4 pixels to be convolved with it: itself, and the 3 pixels it corresponds to if the image is rotated 90, 180, and 270 degrees. The kernel weights stay the same as its shape changes and it is slid across the entire image.</p>
<p>For example, when the kernel starts in the top left, the pixels convolved with it would be top right, bottom right and bottom left.</p>
<p>Is this possible in pytorch? Would I have to modify any C++ code?</p>

username: caffedude
cooked: <p>Hmm… I think I know how.<br>
The image can be rotated and concatenated across the channel axis. Then a 1x1 convolution can be used to achieve the same thing.</p>

username: JuanFMontesinos
cooked: <p>May it be related to deformable convolutions?<br>
<a href="https://pytorch.org/vision/main/generated/torchvision.ops.deform_conv2d.html" class="onebox" target="_blank" rel="noopener nofollow ugc">https://pytorch.org/vision/main/generated/torchvision.ops.deform_conv2d.html</a></p>
Libtorch takes forever to compile

username: billy_bob
cooked: <p>I am working with libtorch in a cpp environment. When I link libtorch against my cmake target and attempt to compile it takes 2-3 minutes to build. Why is this so slow?</p>
<p>I’m fetching libtorch like this:</p>
<pre><code class="lang-auto">##############################
# Libtorch
##############################

set(BUILD_TEST OFF)
set(CMAKE_CXX_STANDARD 17)
set(TORCH_USE_CUDA_DSA 1)
find_package(Torch ${libtorch_VERSION} QUIET CONFIG)
if (NOT Torch_FOUND)
    message(STATUS "libtorch ${libtorch_VERSION} - not found")
    message(STATUS "Fetching libtorch")
    include(FetchContent)
    FetchContent_Declare(
            libtorch
            # URL https://download.pytorch.org/libtorch/cu121/libtorch-cxx11-abi-shared-with-deps-2.1.2%2Bcu121.zip
            URL https://download.pytorch.org/libtorch/cu121/libtorch-cxx11-abi-static-with-deps-2.1.0%2Bcu121.zip
            SOURCE_DIR libtorch)
    FetchContent_GetProperties(libtorch)
    if (NOT libtorch_POPULATED)
        unset(FETCHCONTENT_QUIET CACHE)
        FetchContent_Populate(libtorch)
        list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/libtorch)
    endif ()
    find_package(Torch ${libtorch_VERSION} CONFIG REQUIRED)
else ()
    message(STATUS "libtorch ${libtorch_VERSION} - found")
endif ()
</code></pre>
<p>and link to my project link this:</p>
<pre><code class="lang-auto">
##############################################
# Setup Tests
##############################################

enable_testing()

add_executable(
        tests
        test_core.cu

)
target_link_libraries(
        tests
        GTest::gtest_main
        ${CUDA_LIBRARIES}
        ${TORCH_LIBRARIES}
        simulator
        viewer
)
target_include_directories(tests PUBLIC
        ${CUDA_INCLUDE_DIRS}
        ${TORCH_INCLUDE_DIRS}
)
</code></pre>
<p>Yet building the tests target takes 3 minutes. Why so slow?</p>

username: BSchneider
cooked: <p>I ran into this issue when doing similar work. It seems like the work is being spent on including very large header files (torch.h includes a bunch of headers which each in turn include a bunch of headers, etc.) My solution was to put all torch headers in a single .h in my project and precompile that header for reuse.</p>
<pre><code class="lang-auto">/**
 * torch_includes.h
 * Place all torch headers here and include this header instead.
 * This header is pre-compiled and reused between builds.
 * Allows for linking against libtorch while maintaining fast build times.
 * **/

#ifndef CUDA_FOR_ML_TORCH_INCLUDES_H
#define CUDA_FOR_ML_TORCH_INCLUDES_H

#include "torch/torch.h"
// more torch includes here

#endif
</code></pre>
<p>Then I set this header to be precompiled in my cmake config with:</p>
<pre><code class="lang-auto">target_precompile_headers(CUDA_for_ML PUBLIC torch_includes.h)
</code></pre>
<p>The first compile is still slow but after that my builds were quite quick. The process for using pre-compiled headers may vary depending on your compiler. I believe msvc is slightly different.</p>
Future Trends in Generative AI Technology?

username: kodexolabs
cooked: <p>Hi all,</p>
<p>Generative AI is rapidly evolving. What are the upcoming trends and advancements we should be aware of in this field? How do you see generative AI transforming industries in the next few years? Any predictions or insights into emerging technologies and applications would be great to hear.</p>
<p>Looking forward to your thoughts!</p>

username: anantguptadbl
cooked: <p>Difficult to predict anything, but definitely</p>
<ul>
<li>
<p>More general intelligence</p>
</li>
<li>
<p>Larger context lengths</p>
</li>
</ul>
<p>BTW this list is awesome</p><aside class="onebox allowlistedgeneric" data-onebox-src="https://github.com/steven2358/awesome-generative-ai">
  <header class="source">
      <img src="https://github.githubassets.com/favicons/favicon.svg" class="site-icon" width="32" height="32">

      <a href="https://github.com/steven2358/awesome-generative-ai" target="_blank" rel="noopener nofollow ugc">GitHub</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/344;"><img src="https://opengraph.githubassets.com/9ca9b102b956773393a9a548cb7b42043aad95d73357fb3aecc140eb8dcdca58/steven2358/awesome-generative-ai" class="thumbnail" width="690" height="345"></div>

<h3><a href="https://github.com/steven2358/awesome-generative-ai" target="_blank" rel="noopener nofollow ugc">GitHub - steven2358/awesome-generative-ai: A curated list of modern...</a></h3>

  <p>A curated list of modern Generative Artificial Intelligence projects and services - steven2358/awesome-generative-ai</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>
Is there a sane way of creating a timeout for loading a model?

username: jbsabbagh
cooked: <p>Hi there!</p>
<p>I am deploying a Pytorch model to a Dataflow streaming pipeline for ML Inference. The workers on the pipeline are mounted with a GPU to accelerate the inference. Essentially, dataflow in this case, creates one python process per core on the worker (in my case 16 cores so 16 python processes) and loads the model to the GPU.</p>
<p>In some events, this loading process gets stuck and does not really recover (unclear why this happens but my best guess is some sort of deadlock).</p>
<p>In this case, I’m trying to implement a timeout to pre-empt this so it can try again or at least prevent the pipeline from getting stuck. Is there a sane way of doing this?</p>
<p>This is the solution I’ve tried:</p>
<pre><code class="lang-auto">pool = ProcessPoolExecutor(max_workers=1)
    logging.info(f"Loading model with timeout as {timeout} seconds.")
    start = time.time()
    future = pool.submit(load_func)
    try:
        model = future.result(timeout=timeout)
        end = time.time()
    except (TimeoutError, CancelledError) as e:
        # Don't wait for the process to finish, otherwise it will hang if the process is stuck
        logging.debug("Shutting down executor.")
        pool.shutdown(wait=False)
        logging.debug("Killing child processes.")
        _kill_child_processes(os.getpid())
        raise LoadModelTimeoutError(f"Model loading timed out after {timeout} seconds.") from e
    logging.info(f"Model loaded in {end - start:.2f} seconds.")
    return model
</code></pre>
<p>This seems to be problematic though because, AFAIK, you cannot kill the producing process (in this case the child process that generates the future) while the consuming process is trying to access it.</p>
Model training time increase more than 10x in some case

username: s1030512149
cooked: <pre><code class="lang-auto">import torch
para =torch.Tensor(initial_para)
x,y  = torch.tensor(x),torch.relu(torch.tensor(y))
para.requires_grad = True
loss = torch.nn.MSELoss()
optimizer = torch.optim.Adam([para], lr=lr)
for i in `range(max_iter):`
    y_fit = multi_gaussian(x,para)
    l = loss(y_fit,y)
    try:
        if torch.isnan(l) or torch.isinf(l) :
            print("l is nan or inf")
            break
        l.backward()
        optimizer.step()
        optimizer.zero_grad()
    except:
        break
def multi_gaussian(x, params):
    y = torch.zeros_like(x)
    for i in range(0, params.shape[0], 3):
        g = gaussian(x, params[i], params[i + 1], params[i + 2])
        if torch.any(torch.isnan(g)) or torch.any(torch.isinf(g)):
            continue
        y = y + g
    return y
def gaussian(x,center,amp,variance, offset = None):
    return amp*torch.exp(-(x-center)**2/(variance ))
</code></pre>
<p>Hi, im using pytorch to fit gaussian mixture model. It works perfect via directly run main.py. My data had length of 1024, and it only took less than <strong>0.1 s</strong> to fit the model. However, a strange issue occurred when I using PythonNet package in CSharp. After the python environment was initialized, the main.py was also successfully runned. But the time for model fit increased to nearly <strong>1.8 s, 18 times slower than previous condition</strong>.<br>
While i used another fit methed named scipy.optimize.curve_fit method, it tooks <strong>almost the same time (0.03 s)</strong> as run main.py directly or by CSharp code call. I was so confused by the difference, and I want to know if there is way to solve the problem.</p>
<p><strong>(By the way, im coding my program in net4.8 framework, i cant using torchsharp in Csharp which need net6.0).</strong></p>
<p>Thank a lot!</p>
Memory leaking for dataloader

username: Yuyang_Hu
cooked: <p>When I tried to use the dataloader provided in “<a href="https://github.com/PatrickTUM/UnCRtainTS/blob/main/data/dataLoader.py," rel="noopener nofollow ugc">https://github.com/PatrickTUM/UnCRtainTS/blob/main/data/dataLoader.py,</a>” I noticed a memory leak issue. The dataloader gradually consumes all my RAM, eventually causing my desktop to freeze.</p>
<h3><a name="some-experiments-i-did-to-fix-it-1" class="anchor" href="#some-experiments-i-did-to-fix-it-1"></a>some experiments I did to fix it</h3>
<p>(1) I tried to transfer all the python list to np.array but It does not work.<br>
(2) I tried to just use the dataloader without any training but still get memory leaking. Like:<br>
sen12mscr_test = SEN12MSCR(opt.data_root, split=‘test’, cloud_masks=‘s2cloudless_map_mask’)<br>
test_dataloader = torch.utils.data.DataLoader(sen12mscr_test, batch_size=2, shuffle=False, num_workers=0, pin_memory=True)<br>
for pdx, samples in enumerate(test_dataloader):<br>
print(pdx)</p>

username: anantguptadbl
cooked: <p><a class="mention" href="/u/yuyang_hu">@Yuyang_Hu</a> the file is not available at the mentioned link. Can you re-post the file in the github link?</p>

username: Yuyang_Hu
cooked: <p><a href="https://github.com/PatrickTUM/UnCRtainTS/blob/main/data/dataLoader.py" rel="noopener nofollow ugc">https://github.com/PatrickTUM/UnCRtainTS/blob/main/data/dataLoader.py</a> It is the correct link.</p>

username: Yuyang_Hu
cooked: <p>[quote=“Yuyang_Hu, post:3, topic:205626”]</p><aside class="onebox githubblob" data-onebox-src="https://github.com/PatrickTUM/UnCRtainTS/blob/main/data/dataLoader.py">
  <header class="source">

      <a href="https://github.com/PatrickTUM/UnCRtainTS/blob/main/data/dataLoader.py" target="_blank" rel="noopener nofollow ugc">github.com</a>
  </header>

  <article class="onebox-body">
    <h4><a href="https://github.com/PatrickTUM/UnCRtainTS/blob/main/data/dataLoader.py" target="_blank" rel="noopener nofollow ugc">PatrickTUM/UnCRtainTS/blob/main/data/dataLoader.py</a></h4>


      <pre><code class="lang-py">import os
import glob
import warnings
import numpy as np
from tqdm import tqdm
from natsort import natsorted

from datetime import datetime
to_date   = lambda string: datetime.strptime(string, '%Y-%m-%d')
S1_LAUNCH = to_date('2014-04-03')

# s2cloudless: see https://github.com/sentinel-hub/sentinel2-cloud-detector
from s2cloudless import S2PixelCloudDetector

import rasterio
from rasterio.merge import merge
from scipy.ndimage import gaussian_filter
from torch.utils.data import Dataset

from util.detect_cloudshadow import get_cloud_mask, get_shadow_mask
</code></pre>



  This file has been truncated. <a href="https://github.com/PatrickTUM/UnCRtainTS/blob/main/data/dataLoader.py" target="_blank" rel="noopener nofollow ugc">show original</a>

  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>
<p>
[/quote] Sorry, It is the correct one. Thanks.</p>
Libtorch giving same output for different inputs

username: Nima_Chelongar
cooked: <p>i have saved my model using script in python but when i want to use it in ibtorch c++, for different inputs i always get the same output like [0.4816  0.5184].</p>

username: Nima_Chelongar
cooked: <p>SOLVED!</p>
<pre><code class="lang-auto">net = Net()
net.load_state_dict(torch.load("Path/weights.pth"))
net.eval()
input_random = torch.rand((1, 3, 224, 224))
output = net(input_tensor)
print(output)
traced_net = torch.jit.trace(Net(), input_random)
traced_net.save("Saving_Path/jit.pt")
</code></pre>
<p>my problem was putting</p>
<blockquote>
<p><strong>Net()</strong></p>
</blockquote>
<p>instead of</p>
<blockquote>
<p><strong>net</strong></p>
</blockquote>
<p>inside the</p>
<blockquote>
<p>torch.jit.trace()</p>
</blockquote>
<p>so the true code must be like:</p>
<pre><code class="lang-auto">traced_net = torch.jit.trace(net, input_random)
</code></pre>
Changing the "milestones" of a Saved multisteplr Optimizer

username: Candas_Unal
cooked: <p>I have my optimizer’s state_dict(), my model.state_dict() along with epoch number saved, and I want to add more milestones when I load the model and optimizer and start training.</p>
<p>The current milestones end in 4000 epoch, and I’d like to add 4250, 4500, 4750 etc.</p>
<p>Is it possible to load, change, and continue the training without messing up anything?</p>

username: Brock_Brown
cooked: <p>It should be fine just to load a new scheduler if you need to change the milestones, the implementation is pretty lightweight (see the <code>LRScheduler</code> and <code>MultiStepLR</code> source <a href="https://pytorch.org/docs/stable/_modules/torch/optim/lr_scheduler.html" rel="noopener nofollow ugc">here</a>). Just make sure to pass the last epoch into the <code>last_epoch</code> parameter in the initialization of <code>MultiStepLR</code>, otherwise the scheduler will assume that it’s on the first epoch.</p>
GH200 System RAM and VRAM

username: Abhinav_Reddy
cooked: <p>When attempting to run a training run for a 7 billion parameter model, I receive this error:</p>
<pre><code class="lang-auto">OutOfMemoryError: CUDA out of memory. Tried to allocate 344.00 MiB. GPU 0 has a total capacity of 95.00 GiB of which 238.12 MiB is free. Including non-PyTorch memory, this process has 0 bytes memory in use. Of the allocated memory 92.96 GiB is allocated by PyTorch, and 667.94 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
</code></pre>
<p>When running <code>torch.cuda.get_device_properties(0)</code>, torch returns <code>CudaDeviceProperties(name='GH200 480GB', major=9, minor=0, total* memory=97280MB, multi_processor_count=132)</code>. Is the LPDDR5 memory not fully coherent with system memory? If so, is there anyway to expose it to pytorch without a custom allocator?</p>

username: ptrblck
cooked: <p>No, you would need to use a custom allocator or custom memory pool as described in <a href="https://github.com/pytorch/pytorch/pull/125722">this WIP PR</a>.</p>
PyTorch C++ API binary compiled with xmake crashes

username: George.Wang
cooked: <p>Hi,all</p>
<p>Today I created a manual_seed_test project. Then the content of xmake.lua is as follows</p>
<pre><code class="lang-auto">-- set xmake minimum version
set_xmakever("2.7.3")

-- set common flags
set_languages("c++17")
set_warnings("more")


add_requires("cmake::Torch", {alias = "libtorch", system = true, configs = {shared=false, envs = {CMAKE_PREFIX_PATH = "D:/3rdparty/libtorch-win-shared-with-deps-2.3.1+cu118/libtorch"}}})
add_packages("libtorch")


add_rules("mode.debug", "mode.release")

target("manual_seed_test")
    set_kind("binary")
    add_files("src/*.cpp")
</code></pre>
<p>The contents of main.cpp are as follows：</p>
<pre><code class="lang-auto">#include &lt;iostream&gt;

#include &lt;torch/torch.h&gt;

using namespace std;

int main(int argc, char** argv)
{
    try {
       torch::manual_seed(0);
        auto random_tensor = torch::rand({4, 3, 384, 288});
        std::cout &lt;&lt; "Random tensor shape: " &lt;&lt; random_tensor.sizes() &lt;&lt; std::endl;
    } catch (std::exception &amp;e) {
        std::cout &lt;&lt; e.what() &lt;&lt; std::endl;
    }

    return 0;
}

</code></pre>
<p>run code , as follows:</p>
<pre><code class="lang-auto">xmake b manual_seed_test &amp;&amp; xmake r manual_seed_test
</code></pre>
<p>run result as follows:</p>
<pre><code class="lang-auto">checking for Microsoft Visual Studio (x64) version ... 2022
[ 25%]: cache compiling.release src\main.cpp
[ 50%]: linking.release manual_seed_test.exe
[100%]: build ok!
error: execv(D:\manual_seed_test\build\windows\x64\release\manual_seed_test.exe) failed(-1073741819)
</code></pre>
<p>The specific content of the project is as follows：<br>
<img src="https://github.com/pytorch/pytorch/assets/37261042/60966bc7-b8d2-4ab2-9c53-6fde2d0f37e1" alt="image" width="" height=""></p>
<p>I use the same xmake and libtorch versions as others. It works on other people’s computers, but mine gives an error. How can I solve this problem? I have used Dependency walker to analyze manual_seed_test.exe and followed the solution in the Microsoft community, but it still doesn’t work. Please help me, I’d be grateful.</p>