2,172 questions
2
votes
1
answer
73
views
Having trouble with R's torch and tensor dimensions
I am trying to follow along with this webpage: https://jtr13.github.io/cc21fall2/tutorial-on-r-torch-package.html
I am trying to understand R's implementation of PyTorch.
I am having some trouble with ...
2
votes
1
answer
25
views
PyTorch .view() operation to manipulate tensor dimensions vis a vis using torch.unbind followed by torch.cat
In Torch, .view() reshapes the tensor. However, there are multiple ways to reshape a multi-dimensional tensor to a target shape. How does it decide between those different ways?
For example, in Torch, ...
Advice
0
votes
4
replies
62
views
Regex-logic in a numpy/torch array
Evening,
Is there any way to find a specific sequence of numerical values, matching certain logic (in the same way as in a regex), within a numpy/torch array or matrix row?
I know i could just convert ...
0
votes
0
answers
65
views
Does setting torch_dtype=torch.float16 override 8-bit quantization in BitsAndBytes?
I'm trying to run the Qwen2.5-Coder-3B model locally with 8-bit quantization using BitsAndBytes.
While loading the model, I noticed that some examples also specify torch_dtype=torch.float16.
From my ...
0
votes
0
answers
89
views
pip install --no-cache-dir torch==2.7.0+cu126 works on the host machine,but fails in Docker with No matching distribution found for torch==2.7.0+cu126
I am trying to install PyTorch 2.7.0 with CUDA 12.6 support in a Docker container, but I get the following error:
ERROR: Could not find a version that satisfies the requirement torch==2.7.0+cu126 (...
0
votes
0
answers
64
views
torch cant see my cuda and cudnn have some one know how to fix it?
i use windows 11
nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2025 NVIDIA Corporation
Built on Wed_Apr__9_19:29:17_Pacific_Daylight_Time_2025
Cuda compilation tools, release ...
3
votes
0
answers
112
views
How does one log the operations done on a GPU during the execution of Python code?
I have encountered a particular problem while executing a function from the transformers library of huggingface on an Intel GPU wheel of torch. Since I am doing something I normally shouldn't be ...
0
votes
0
answers
64
views
Utilizing GPU with RNN models which takes it's output as input [torch]
I have a machine-translation model. In this model, I calculate a vector for a given sentence and I take this vector, aggregate with each generated output of RNN and put it into RNN again for ...
0
votes
1
answer
116
views
import torch error: DLL load failed while importing _C
I was trying to follow a project in university where we had to import cellpose. The import delivered an error message which could be tracebacked to import torch (see below). Every import was done in a ...
0
votes
0
answers
271
views
How to handle "Could not initialize NNPACK! Reason: Unsupported hardware" warning in PyTorch / Silero VAD on cloud CPU?
I’m running Silero VAD (via PyTorch + torchaudio) on a Linode cloud instance (2 dedicated CPUs, 4 GB RAM). When I process 10-minute audio chunks, I always get repeated warnings like this and it doesn'...
0
votes
1
answer
76
views
fvcore multiple arguments forward modules? [closed]
I have a model that take more than one arguments in forward.
Recently I'm trying to query some informations my model by fvcore module in python, but I can't find any document for multiple forward ...
0
votes
1
answer
61
views
Tuning starting and final learning rate
If you use cosine decay for example and you have starting learning rate and final learning rate, can you tune those hyperparameters so that final learning rate is in some ratio of starting learning ...
1
vote
1
answer
142
views
Why do different L-BFGS implementations in R give different results?
I am trying to minimize a non-convex function using three different L-BFGS implementations in R:
optim(method = "L-BFGS-B"), torch::optim_lbfgs(), and lbfgs::lbfgs().
I have set the same ...
0
votes
0
answers
48
views
module 'shap' has no attribute 'DeepExplainer' with pytorch
I wrote a code for SHAP on images. It was working for two days, then it brought following error :
module 'shap' has no attribute 'DeepExplainer'
I uninstalled and installed the SHAP module again and ...
0
votes
0
answers
40
views
torch.autograd.functional.jacobian returns tensors with all zeros
I am trying to use torch.autograd.functional.jacobian to calculate the gradients of the model parameters with respect to a set of losses, but it returns all zeros. My function definition is as follows
...
2
votes
1
answer
95
views
Confused about r-torch syntax
I have been trying to tackle a regression problem by training a neural network to predict a continuous variable using r-torch. My question pertains to the syntax used to achieve this.
When ...
0
votes
0
answers
137
views
My ResNet training loop has a CPU bottleneck, A100 GPU is barely utilized regardless of workers num
I'm training a ResNet50 model on 300W-LP dataset with AFLW2000 as a validation dataset.
The task is head pose angle prediction (pitch, yaw, roll) with a 1-bin head output for each angle.
When training ...
0
votes
0
answers
67
views
Why does adding token and positional embeddings in transformers work?
In transformer models, I've noticed that token embeddings and positional embeddings are added together before being passed into the attention layers:
import torch
import torch.nn as nn
class ...
1
vote
1
answer
160
views
Stable Diffusion WebUI Torch Installation Error: [WinError 32] File in Use by Another Process
I'm trying to run Stable Diffusion WebUI (v1.10.1) on Windows using the built-in launch.py script. However, during the environment setup, it fails to install torch==2.1.2 and torchvision==0.16.2.
Here ...
0
votes
0
answers
76
views
Why is attention scaled by sqrt(d_k) in Transformer architectures?
I have this code in transformer model:
keys = x @ W_key
queries = x @ W_query
values = x @ W_value
attention_scores = queries @ keys.T
# keys.shape[-1]**0.5: used to scale the attention scores before ...
0
votes
0
answers
53
views
How to convert PyTorch file from version 3 to version 2 without update PyTorch version
I have a model that I want to infer in the PyTorch v1.4.0 environment, but I get the error "Attempted to read a PyTorch file with version 3, but the maximum supported version for reading is 2. ...
0
votes
1
answer
344
views
python 3.13 - ChatTTS transformer text to speech
I'm trying to use ChatTTS which uses Torch. I installed it via the Pycharm packages repository (PIP) with no errors.
But when I run the main webpages basic example code.
import ChatTTS
import torch
...
1
vote
1
answer
106
views
How do I make torch.ones(...) work inside a traced wrapper model during symbolic_trace()?
Thanks for giving this a read...
I am getting going with PyTorch. I’m building a tool that wraps HuggingFace models in a custom WrappedModel so I can trace their execution using torch.fx....
0
votes
0
answers
60
views
How is MNIST structured in Torch for R and how can I structure my own dataset the same way?
[NOTE: It turned out to be much easier to do what I wanted to do by building on another CNN example in the same textbook: https://skeydan.github.io/Deep-Learning-and-Scientific-Computing-with-R-torch/...
4
votes
0
answers
127
views
Cmake: undefined reference to `rclcpp::Node::Node(std::string const&, rclcpp::NodeOptions const&)'
I'm working on a ROS2 Humble project. As always, I created the ament_cmake package, wrote a C++ node with Torch Scripts, and made Cmake - but I got this error: undefined reference to `rclcpp::Node::...
0
votes
0
answers
36
views
Pytorch RuntimeError when building NN model from ISMIR tutorial: mat1 & mat2 shapes cannot be multiplied
I am bulding an NN model as a newbee on Pytorch and getting the following error message when my model makes the call to the embedding torch's function:
Traceback (most recent call last):
...
0
votes
0
answers
168
views
Unhandled FakeTensor Device Propagation for aten.index_select.default, found two different devices mps:0, mps
FULL ERROR:
TorchRuntimeError: Failed running call_module L__self___position_embedding_table(*(FakeTensor(..., device='mps', ...), **{}): Unhandled FakeTensor Device Propagation for aten.index_select....
0
votes
1
answer
25
views
gradient not backpropgating to mu
my mu cannot have any valid gradient somehow, here is the code:
import torch
torch.manual_seed(0)
mu = torch.zeros(1, requires_grad=True)
sigma = 1.0
eps = torch.randn(1)
sampled = mu + sigma * eps
...
0
votes
1
answer
90
views
Problems downloading a dataset for Torch for R
I'm trying to load the MNIST dataset in Torch for R, following https://skeydan.github.io/Deep-Learning-and-Scientific-Computing-with-R-torch/overfitting.html#classic-data-augmentation:
library(torch)
...
2
votes
1
answer
138
views
In Torch for R, fitting a Dataloader object yields "Indexing starts at 1 but found a 0" error
I keep getting the error "Indexing starts at 1 but found a 0" when fitting a model where the input or output started life as R objects (vectors, matrices, or arrays), but only when using a ...
0
votes
0
answers
55
views
Why does torch_geometric.Batch add edge_index, edge_attr and pos to my custom Data even when not set?
I'm using PyTorch Geometric and have a custom Torus class (a subclass of Data) that conditionally initializes attributes such as edge_index, edge_attr, and pos only when no_fixed is False. For example:...
0
votes
0
answers
39
views
torch-scatter. torch-sparse installation issue on google collab pro
import os
import torch
os.environ['TORCH'] = torch.__version__
print(torch.__version__)
!pip install -q torch-scatter -f https://data.pyg.org/whl/torch-${TORCH}.html
!pip install -q torch-sparse -f ...
1
vote
0
answers
72
views
Why the global_step (training step) is no sync with the wandb plot steps?
I'm using torch LightningModule trainer.
I create trainer with:
trainer = pl.Trainer(max_epochs = 3)
Each train epoch has 511 steps (total = 1533) and each validation epoch has 127 steps.
I use ...
1
vote
1
answer
455
views
How to avoid a Torch error with Open WebUI/Ollama
I'd like to get Open WebUI working with Ollama on Ubuntu 24.10, but installing it using pip and venv leads me to a torch error.
Firstly, Ollama (0.6.2) is working: I can type /path/to/ollama list and ...
1
vote
0
answers
41
views
Florence2 Torch JiT Inference
I am using the Florence2 model and trying to speed up inference through torch.jit.trace()
Orig model -
import torch
from transformers import AutoProcessor, AutoModelForCausalLM
from PIL import Image
...
0
votes
0
answers
1k
views
torch upgrade throwing error Weights only load failed
torch version is upgraded from "torch==2.5.1" to "torch==2.6.0", but when tried to run below code we are getting error , can anyone please let me know how to resolve this issue?
...
0
votes
1
answer
85
views
Can PyTorch `scatter` or `gather` be used to reproduce `torch_geometric` aggregation functions?
I can't understand if torch.scatter or torch.gather could be used to reduce values of a tensor according to a reduction function over specified indices.
I've frequently used the torch_geometric.nn....
0
votes
1
answer
113
views
loading a dataset with datasets.load_dataset is hanging
I'm trying to load some data using datasets.load_datasets. It runs correctly on a head node. The issue is happening on a slurm node. I'm using a conda env with datasets installed.
When I run on head ...
1
vote
1
answer
301
views
Why does setting torch.backends.cudnn.deterministic = True make my TCN model extremely slow in PyTorch?
I encountered a very interesting issue when training a deep learning model using Python and PyTorch. I designed a simple TCN as follows:
import torch
import torch.nn as nn
class TCN(nn.Module):
...
2
votes
0
answers
266
views
Not able to access GPU within the docker container
I am using Ubuntu 22.04. I have nvidia-570 driver installed along with cuda 12.4 on my host machine. However, I am not able to access gpu in my container.
This is my docker-compose-file
version: '3.8'
...
1
vote
1
answer
349
views
pytorch on termux shows ImportError: dlopen failed in libtorch_cpu.so
I have searched the method how to install pytorch on termux and run the command as be told:
pkg update
pkg install x11-repo
pkg update
pkg upgrade
pkg install python-torch
from now on, everything ...
-1
votes
1
answer
45
views
Computing only the n first rows of a distance matrix with R torch
I am writing a fast version of sf::st_is_within_distance(points, dist) for 100k+ points. I start by creating a grid with sf::st_make_grid, then determine which point lies in which grid cell, compute ...
0
votes
0
answers
27
views
Msg onload conda env: "REM The OpenCL loader ignores value of this variable if running with elevated privileges"
My env has this message every time it is loaded:
>REM The OpenCL loader ignores value of this variable if running with elevated privileges
>set "OCL_ICD_FILENAMES=C:\Users\myuser\.conda\...
2
votes
1
answer
484
views
Moviepy errors when using TextClip
I'm having some trouble using Moviepy library, specially when using SubtitlesClip().
Since I can't provide the whole code, I hope I can provide enough so you can understand my problem. This was my ...
0
votes
1
answer
371
views
Running Stable Diffusion locally
I've been trying to follow the instructions here to run StableDiffusion locally, but the code appears to just hang.
I've cloned the repo, and installed dependencies:
$ git show --stat
commit ...
0
votes
0
answers
439
views
Facing issue with connecting to socket with DDP and Pytorch (single node, multi-GPU communication)
I am completely new to distributed programming and I have been trying to port the original code that ran on a multi-node cluster to single-node cluster with multiple GPUs. My goal is to simulate a ...
0
votes
1
answer
62
views
Create differentiable 2d projection of 3d tensor in pytorch?
I need to create a 2d projection of 3d tensor on the surface plane touching unit sphere in 3d space, in such a way that this projection is differentiable.
1
vote
0
answers
78
views
Torch Freezes Ultra-Wide Camera When Switching Between Wide & Ultra-Wide (AVFoundation Bug?)
I'm working on an iOS app using AVFoundation to handle real time video capture and object detection.
However, I’ve encountered a frustrating issue when switching between the Wide and Ultra Wide ...
0
votes
0
answers
30
views
A GRU Neural Network Training Issue in PyTorch on Windows
I have been building a GRU neural network in Python using PyTorch. When I attempt to train it, I encounter the following error, and the process gets stuck without displaying any further information. I ...
0
votes
0
answers
211
views
IP-adapter plus face model not working as expected
I came from these two links,
https://huggingface.co/h94/IP-Adapter-FaceID
https://stable-diffusion-art.com/consistent-face/
They all mentioned I can preserve face id with the controlnet model.
So I ...