2,906 questions
0
votes
2
answers
52
views
pytorch Module B=A, A.to('cpu'), but the tensor in B is still in GPU, why?
After converting module A to CPU, the origin parameter tensor still stays on the GPU? When it is released? Is it wrong if I reuse the parameter?
My code:
import torch.nn as nn
class A(nn.Module):
...
0
votes
0
answers
24
views
Change contravariant tensor to covariant tensor in einsteinpy package
Using einsteinpy package of Python, I am defining the electromagnetic tensor (or any other arbitrary tensor). While defining, I am defining it as 'uu' tensor using the BaseRelativityTensor class file. ...
1
vote
1
answer
283
views
How are fp6 and fp4 supported on NVIDIA Tensor Core on Blackwell?
I am writing PTX assembly code on CUDA C++ for research. This is my setup:
I have just downloaded the latest CUDA C++ toolkit (13.0) yesterday on WSL linux.
The local compilation environment does not ...
0
votes
1
answer
33
views
RuntimeError when trying to run suno/bark-small on GPU
When I run:
from transformers import AutoProcessor, BarkModel
import os
from scipy.io.wavfile import write as write_wav
CUDA_VISIBLE_DEVICES=0
os.environ["SUNO_OFFLOAD_CPU"] = "True&...
1
vote
0
answers
40
views
Difference between tokens generated on a configuration in two different contexts
I have a model that given a configuration, or state (of a Rubik's cube, but whatever, it is a sequence of integers) generates a movement (from 0 to 5). This movement can be used to bring the ...
0
votes
1
answer
37
views
why TensorDataset devide the data to minibatches?
Why TensorDataset devide the data to minibatches? For example, when putting in it 2D array, instead of yielding 2D tensors as batches, it sets the required batches to be minibatches, and its actual &...
1
vote
0
answers
41
views
How to optimize CPU tensor slicing and asynchronous transfer to the GPU?
My code involves slicing large tensors on the CPU by index and asynchronously transmitting them back to the GPU. However, through the Profiler debugging tool, I found that this step would seriously ...
0
votes
1
answer
71
views
Torch: how to insert a tensor into another tensor at certain index
I have a padded tensor X with shape (B, T1, C) and a padded tensor Y with shape (B, T2, C), I also know the sample lengths L for X. I want to insert the samples of X into Y at certain index I and pad ...
1
vote
0
answers
42
views
Image Tensors Return As Zero When num_workers > 0
I am facing an issue with multiprocessing. I am trying to load my .pt data as dataloaders. Everything works fine when I set the num_workers = 0. But when I set it to a value greater than 0, the tensor ...
1
vote
2
answers
174
views
Why do we reshape key, query, and value tensors in multi-head attention?
In my PyTorch implementation of multi-head attention, i have those in __init__()
class MultiHeadAttentionLayer(nn.Module):
def __init__(self,d_in,d_out,context_length,dropout,num_heads,use_bias=...
0
votes
1
answer
84
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....
1
vote
1
answer
54
views
How to produce tensor of first occurrencies of another tensor using PyTorch
Let's say we have an ordered 1D tensor of ints/longs t.
I want to produce a new tensor a with size max(t) where each term a[i] contains the first occurrence of the value i in the tensor t.
We could ...
-1
votes
1
answer
273
views
How to solve RuntimeError: Tensors must have same number of dimensions: got 2 and 3?
i am trying to run newly announced model: Phi-4-mini-instruct
https://huggingface.co/microsoft/Phi-4-mini-instruct
It has example, I tried it on Google Colab T4 Notebook, but here is what I got
import ...
3
votes
1
answer
53
views
Pytorch 'smaller than' operation on tensor gives wrong result
I get a very weird behavior for a 'smaller' operation on a float torch tensor.
Consider the following snippet
t = torch.load(r"value.pt")
print(t.shape, t.dtype)
#t = t.double()
for i in ...
2
votes
1
answer
99
views
How to map values from a 3D tensor to a 1D tensor in PyTorch?
I'm stuck with a Pytorch problem and could use some help:
I've got two tensors:
A 3D tensor (shape: i, j, j) with integer values from 0 to n
A 1D tensor (shape: n)
I need to create a new tensor that'...
1
vote
1
answer
59
views
How to add density plots for x and z axes in a tensor smooth plot?
I created this plot using tensor smooths..
I would like to add a visualization of the data density along the x-axis and z-axis. Ideally, this could be done with either:
A rug plot on the respective ...
0
votes
1
answer
51
views
Why does batch() return only one batch?
I'm beginner in image processing. I have two binary classes as subdirectory which total of 496 images and I have an issue with the last batch that has remainder of 13 images. So, instead of tf.dataset ...
2
votes
2
answers
61
views
RuntimeError: Trying to backward through the graph a second time on loss tensor
I have the following training code. I am quite sure I call loss.backward() just once, and yet I am getting the error from the title. What am I doing wrong? Note that the X_train_tensor is output from ...
0
votes
1
answer
137
views
Why do I keep getting an unrecognized data type when running the fit method in this CNN code using Keras 3 API?
I am following an online course and running the following code in python 3.11 to build a CNN for image classification using Keras 3.6 and TensorFlow 2.18:
# Convolutional Nueral Network
import ...
0
votes
1
answer
59
views
Reshaping out tensor in pytorch produces weird behavior
I was going through https://github.com/parrt/fundamentals-of-deep-learning/blob/main/notebooks/3.train-test-diabetes.ipynb as an exercise, but forgot to reshape y tensors in these lines
y_train = ...
1
vote
0
answers
77
views
Dealing with tensors and symbolic language in python
I want to do manipulations with big mathematical expressions containing tensors and symbols. For example I have expressions containing the Kronecker delta $δ_{ij}$ and the 3-dimension Levi-Civitta ε_{...
3
votes
1
answer
125
views
usage of retain graph in pytorch
I get error if I don't supply retain_graph=True in y1.backward()
import torch
x = torch.tensor([2.0], requires_grad=True)
y = torch.tensor([3.0], requires_grad=True)
f = x+y
z = 2*f
...
1
vote
1
answer
523
views
TypeError: Binding inputs to tf.function failed, Can not cast input_tensor TensorSpec to TensorSpec
error message:
Traceback (most recent call last):
File "/home/prakrisht/-------------/detect_from_webcam.py", line 173, in <module>
run_inference(detection_model, category_index, ...
1
vote
1
answer
1k
views
How to check my tensor core occupancy and utilization by Nsight Compute?
In my cuda program, I use many tensor cores operations like m8n8k4 and even use cusparseSpMV. However, when checking the ncu report, it shows like this:
There is no active tensors in my program. The ...
0
votes
1
answer
90
views
Detailed description of `numpy.linalg.tensorsolve`
The official documentation of numpy.linalg.tensorsolve does not really say much about what the function does. Is there any other description available in addition to the source code? A description ...