id stringlengths 7 11 | source stringclasses 1
value | category stringclasses 11
values | title stringlengths 15 214 | text stringlengths 70 30.5k | url stringlengths 57 160 | tags stringlengths 3 113 | created_at int64 1.22B 1.79B |
|---|---|---|---|---|---|---|---|
se_79479038 | stackoverflow | MACHINE_LEARNING | Masked aggregations in pytorch | Masked aggregations in pytorch
Given data and mask tensors are there a pytorch-way to obtain masked aggregations of data (mean, max, min, etc.)?
x = torch.tensor([
[1, 2, -1, -1],
[10, 20, 30, -1]
])
mask = torch.tensor([
[True, True, False, False],
[True, True, True, False]
])
To compute a masked me... | https://stackoverflow.com/questions/79479038/masked-aggregations-in-pytorch | python, pytorch, aggregation, mask, masking | 1,740,916,517 |
se_79470053 | stackoverflow | MACHINE_LEARNING | Replicating GPU environment across architectures | Replicating GPU environment across architectures
I am training a Mamba model on two different GPU architectures: RTX 4090 and RTX A6000. Despite setting all random seeds and using deterministic algorithms, I am observing significant non-deterministic behavior in the training process on the RTX 4090, while the RTX A600... | https://stackoverflow.com/questions/79470053/replicating-gpu-environment-across-architectures | python, pytorch, cuda, gpu, mamba-ssm | 1,740,579,714 |
se_54242123 | stackoverflow | MACHINE_LEARNING | Order of layers in hidden states in PyTorch GRU return | Order of layers in hidden states in PyTorch GRU return
This is the API I am looking at, https://pytorch.org/docs/stable/nn.html#gru
It outputs:
output of shape (seq_len, batch, num_directions * hidden_size)
h_n of shape (num_layers * num_directions, batch, hidden_size)
For GRU with more than one layers, I wonder ... | https://stackoverflow.com/questions/54242123/order-of-layers-in-hidden-states-in-pytorch-gru-return | deep-learning, pytorch, recurrent-neural-network, tensor, gated-recurrent-unit | 1,547,749,681 |
se_65439154 | stackoverflow | MACHINE_LEARNING | Pytorch doesn't work with CUDA in PyCharm/IntelliJ | Pytorch doesn't work with CUDA in PyCharm/IntelliJ
I have just downloaded PyTorch with CUDA via Anaconda and when I type into the Anaconda terminal:
import torch
if torch.cuda.is_available():
print('it works')
then he outputs that; that means that it worked and it works with PyTorch.
But when I go to my IDE ... | https://stackoverflow.com/questions/65439154/pytorch-doesnt-work-with-cuda-in-pycharm-intellij | python, intellij-idea, pycharm, pytorch | 1,608,817,504 |
se_74594256 | stackoverflow | MACHINE_LEARNING | PyTorch Error loading "\lib\site-packages\torch\lib\shm.dll" or one of its dependencies | PyTorch Error loading "\lib\site-packages\torch\lib\shm.dll" or one of its dependencies
I cannot use PyTorch and Shap getting this error
PyTorch Error loading "\lib\site-packages\torch\lib\shm.dll" or one of its dependencies.
I have tried
to uninstall and re-install PyTorch, failed
create a new conda envi... | https://stackoverflow.com/questions/74594256/pytorch-error-loading-lib-site-packages-torch-lib-shm-dll-or-one-of-its-depen | python, pytorch, conda, shap | 1,669,587,885 |
se_60144922 | stackoverflow | MACHINE_LEARNING | RuntimeError: cuDNN version mismatch: PyTorch was compiled against 7102 but linked against 7604 | RuntimeError: cuDNN version mismatch: PyTorch was compiled against 7102 but linked against 7604
I got this error when running training a deep learning model and although looking at many solutions over the Internet, they did not help me. The log is as follows:
Traceback (most recent call last):
File "main.py", line ... | https://stackoverflow.com/questions/60144922/runtimeerror-cudnn-version-mismatch-pytorch-was-compiled-against-7102-but-link | python, deep-learning, pytorch, cudnn | 1,581,315,079 |
se_79451638 | stackoverflow | MACHINE_LEARNING | Pytorch 'smaller than' operation on tensor gives wrong result | 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 range(t.shape[0]):
print(i, "%.20f" % (t[i].sum(-1)-1))... | https://stackoverflow.com/questions/79451638/pytorch-smaller-than-operation-on-tensor-gives-wrong-result | pytorch, tensor | 1,739,974,080 |
se_79455504 | stackoverflow | MACHINE_LEARNING | Load Phi 3 model extract attention layer and visualize it | Load Phi 3 model extract attention layer and visualize it
I would like to visualize the attention layer of a Phi-3-medium-4k-instruct (or mini) model downloaded from hugging-face. In particular, I am using the following model, tokenizer:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeli... | https://stackoverflow.com/questions/79455504/load-phi-3-model-extract-attention-layer-and-visualize-it | python, pytorch, huggingface-transformers, attention-model | 1,740,075,948 |
se_79473712 | stackoverflow | MACHINE_LEARNING | Stable torch, ultralytics, tensorflow packages for requirements.txt | Stable torch, ultralytics, tensorflow packages for requirements.txt
I'm writing a requirements.txt for a real-time sports video analysis project and testing various libraries such as YOLOv8, Torch, TensorFlow, etc.
I've tried multiple Python versions but encountered compatibility issues.
Which versions should I instal... | https://stackoverflow.com/questions/79473712/stable-torch-ultralytics-tensorflow-packages-for-requirements-txt | python, numpy, machine-learning, pytorch, ultralytics | 1,740,683,980 |
se_78606054 | stackoverflow | MACHINE_LEARNING | torchvision::nms does not exist | torchvision::nms does not exist
Im trying to run the llama3 models using nf4 data format on cpu using intel extension . I download the pytorch from https://github.com/pytorch/pytorch and use the following command to compile: DEBUG=1 python ./setup.py develop. The version is the same as before and other dependencies do... | https://stackoverflow.com/questions/78606054/torchvisionnms-does-not-exist | pytorch, compiler-errors, torchvision | 1,718,091,765 |
se_78620402 | stackoverflow | MACHINE_LEARNING | Dataloader error in pytorch PascalVOC dataset: RuntimeError: each element in list of batch should be of equal size | Dataloader error in pytorch PascalVOC dataset: RuntimeError: each element in list of batch should be of equal size
When trying to implement the yolo algortithm, one of the steps is to resize each image to (448, 448). But even with the transform applied the Dataloader throw an exception about difference of size in the ... | https://stackoverflow.com/questions/78620402/dataloader-error-in-pytorch-pascalvoc-dataset-runtimeerror-each-element-in-lis | machine-learning, deep-learning, pytorch, yolo, pytorch-dataloader | 1,718,318,629 |
se_79473125 | stackoverflow | MACHINE_LEARNING | How to let PyTorch learn coefficients variables for the loss outside of nn.Module? | How to let PyTorch learn coefficients variables for the loss outside of nn.Module?
I have a combined loss funcation like this:
loss = alpha * loss0 + beta* loss1 + gamma * loss2 + delta* loss3
I would like to make alpha, beta, gamma, and delta learnable parameters. Notice that alpha, beta, gamma, and delta are outsid... | https://stackoverflow.com/questions/79473125/how-to-let-pytorch-learn-coefficients-variables-for-the-loss-outside-of-nn-modul | machine-learning, pytorch | 1,740,669,392 |
se_74239556 | stackoverflow | MACHINE_LEARNING | KeyError: 'eval_loss' in Hugginface Trainer | KeyError: 'eval_loss' in Hugginface Trainer
I am trying to build a Question Answering Pipeline with the Hugginface framework but facing the KeyError: 'eval_loss' error. My goal is to train and save the best model at last and evaluate the validation test on the loaded model. My trainer configuration looks like ... | https://stackoverflow.com/questions/74239556/keyerror-eval-loss-in-hugginface-trainer | python-3.x, machine-learning, pytorch, huggingface-transformers, huggingface-tokenizers | 1,666,981,828 |
se_79473994 | stackoverflow | MACHINE_LEARNING | Loss function for Multi-Label Classification of multiple labels and sparse outcomes | Loss function for Multi-Label Classification of multiple labels and sparse outcomes
Consider the Multi-Label Classification with ANN where the targeted labels were of the form
[0,0,0,0,0,1,0,1,0,0,0,1]
[0,0,0,1,0,0,0,0,0,0,0,0]
...
There were N labels each of True(1) or False(0) represented in a N length vector.
I en... | https://stackoverflow.com/questions/79473994/loss-function-for-multi-label-classification-of-multiple-labels-and-sparse-outco | tensorflow, pytorch, classification, multilabel-classification | 1,740,692,896 |
se_79473058 | stackoverflow | MACHINE_LEARNING | PyTorch - Efficiently computing the per pixel gradient of an image with respect to some parameter? | PyTorch - Efficiently computing the per pixel gradient of an image with respect to some parameter?
I have a function that takes a single parameter (alpha) as an input an outputs a N by N image (2048x2048). I want to obtain the gradient of this image with respect to the parameter (alpha). I'm not talking about a sobel ... | https://stackoverflow.com/questions/79473058/pytorch-efficiently-computing-the-per-pixel-gradient-of-an-image-with-respect | python, pytorch | 1,740,668,122 |
se_76012523 | stackoverflow | MACHINE_LEARNING | HuggingFace - model.generate() is extremely slow when I load from checkpoint | HuggingFace - model.generate() is extremely slow when I load from checkpoint
I'm trying to use Donut model (provided in HuggingFace library) for document classification using my custom dataset (format similar to RVL-CDIP). When I train the model and run model inference (using model.generate() method) in the training l... | https://stackoverflow.com/questions/76012523/huggingface-model-generate-is-extremely-slow-when-i-load-from-checkpoint | python, pytorch, huggingface-transformers | 1,681,456,862 |
se_50665141 | stackoverflow | MACHINE_LEARNING | Converting a scipy coo_matrix to pytorch sparse tensor | Converting a scipy coo_matrix to pytorch sparse tensor
I have a coo_matrix:
from scipy.sparse import coo_matrix
coo = coo_matrix((3, 4), dtype = "int8")
That I want converted to a pytorch sparse tensor. According to the documentation https://pytorch.org/docs/master/sparse.html it should follow the coo format, but I... | https://stackoverflow.com/questions/50665141/converting-a-scipy-coo-matrix-to-pytorch-sparse-tensor | python, numpy, scipy, sparse-matrix, pytorch | 1,528,019,688 |
se_79467972 | stackoverflow | MACHINE_LEARNING | Calling Multiple Functions on Multiple Rows of a Tensor in Parallel | Calling Multiple Functions on Multiple Rows of a Tensor in Parallel
import torch
x = torch.ones(3, 3)
factors = [lambda x: 2*x, lambda x: 3*x, lambda x: 4*x]
indices = torch.tensor([0, 1, 2])
def multiply_row_by_factor(row, idx):
return factors[idx](row)
result = torch.vmap(multiply_row_by_factor, in_dims=(0, ... | https://stackoverflow.com/questions/79467972/calling-multiple-functions-on-multiple-rows-of-a-tensor-in-parallel | python, pytorch, transformation, tensor | 1,740,520,411 |
se_69276961 | stackoverflow | MACHINE_LEARNING | How to extract loss and accuracy from logger by each epoch in pytorch lightning? | How to extract loss and accuracy from logger by each epoch in pytorch lightning?
I want to extract all data to make the plot, not with tensorboard. My understanding is all log with loss and accuracy is stored in a defined directory since tensorboard draw the line graph.
%reload_ext tensorboard
%tensorboard --logdir li... | https://stackoverflow.com/questions/69276961/how-to-extract-loss-and-accuracy-from-logger-by-each-epoch-in-pytorch-lightning | logging, pytorch, tensorboard, pytorch-lightning | 1,632,271,475 |
se_79127383 | stackoverflow | MACHINE_LEARNING | How to solve this ERROR: Could not find a version that satisfies the requirement torch==1.6.0? | How to solve this ERROR: Could not find a version that satisfies the requirement torch==1.6.0?
I'm using a demo on Colab notebook called Deep Exemplar Based Video Colorization. https://colab.research.google.com/drive/1Y1XTlTdUG-2LzrH1Vnr_osg9BQavfYsz?usp=sharing
Worked swimmingly for four years until this monday. In t... | https://stackoverflow.com/questions/79127383/how-to-solve-this-error-could-not-find-a-version-that-satisfies-the-requirement | python, pytorch, pip, scipy, scikit-image | 1,729,892,435 |
se_79469831 | stackoverflow | MACHINE_LEARNING | Using binary ({0,1}) weights in a Neural Network layer | Using binary ({0,1}) weights in a Neural Network layer
I want to create a custom linear (not fully connected) layer in Pytorch. What is special in this layer is that I need its weights to be binary (0 or 1), so that this layer acts as a "mask", masking out these features that get a weight of 0. Since backpropagation i... | https://stackoverflow.com/questions/79469831/using-binary-0-1-weights-in-a-neural-network-layer | python, machine-learning, deep-learning, pytorch, neural-network | 1,740,574,940 |
se_78690154 | stackoverflow | MACHINE_LEARNING | Pytorch, Can't find the inplace operation that's preventing my network from calculating gradient | Pytorch, Can't find the inplace operation that's preventing my network from calculating gradient
I'm trying to implement Proximal Policy Optimisation with multiple Actor heads: there are multiple actions the agent can perform, so I need one head to chose which action(s) to perform, and then several others to d... | https://stackoverflow.com/questions/78690154/pytorch-cant-find-the-inplace-operation-thats-preventing-my-network-from-calc | python, pytorch, tensor, reinforcement-learning, backpropagation | 1,719,795,445 |
se_78239566 | stackoverflow | MACHINE_LEARNING | In GPytorch is there any way to initialize a VNNGP model with faiss-cpu and then set it to cuda? | In GPytorch is there any way to initialize a VNNGP model with faiss-cpu and then set it to cuda?
As faiss-gpu does not support windows i am forced to use faiss-cpu (which i would like do to as initializing my model with it takes about 4 minutes compared to the 38 minutes it takes with scikit-learn) I run in to the an ... | https://stackoverflow.com/questions/78239566/in-gpytorch-is-there-any-way-to-initialize-a-vnngp-model-with-faiss-cpu-and-then | pytorch, faiss, gpytorch | 1,711,642,323 |
se_78943401 | stackoverflow | MACHINE_LEARNING | Fine-tuning a Pretrained Model with Quantization and AMP: Scaler Error "Attempting to Unscale FP16 Gradients" | Fine-tuning a Pretrained Model with Quantization and AMP: Scaler Error "Attempting to Unscale FP16 Gradients"
I am trying to fine-tune a pretrained model with limited VRAM. To achieve this, I am using quantization and automatic mixed precision (AMP). However, I am encountering an issue that I can't seem to r... | https://stackoverflow.com/questions/78943401/fine-tuning-a-pretrained-model-with-quantization-and-amp-scaler-error-attempti | python, pytorch, nlp, huggingface-transformers, fine-tuning | 1,725,352,703 |
se_59134499 | stackoverflow | MACHINE_LEARNING | How to modify path where Torch Hub models are downloaded | How to modify path where Torch Hub models are downloaded
When I download models through Torch Hub, models are automatically downloaded in /home/me/.cache/torch.
How can I modify this behavior ? | https://stackoverflow.com/questions/59134499/how-to-modify-path-where-torch-hub-models-are-downloaded | path, pytorch | 1,575,272,528 |
se_79464907 | stackoverflow | MACHINE_LEARNING | Memory keeps increasing in pytorch training loop, even with empty_cache() | Memory keeps increasing in pytorch training loop, even with empty_cache()
I have a pytorch training script, and I'm getting an out-of-memory error after a few epochs even tho I'm calling torch.cuda.empty_cache(). The GPU memory just keeps going up and I can't figure out why.
Here's basically what I'm doing:
import tor... | https://stackoverflow.com/questions/79464907/memory-keeps-increasing-in-pytorch-training-loop-even-with-empty-cache | python, pytorch | 1,740,434,645 |
se_79463165 | stackoverflow | MACHINE_LEARNING | train and validation metrics and loss using torchvision | train and validation metrics and loss using torchvision
I am new to pytorch and torchvision.
Apparently, the __call__ method of a model returns different things if they are on train mode or not. The first case returns the loss, the second returns the outputs.
This is quite bothersome for two reasons:
I need to do ver... | https://stackoverflow.com/questions/79463165/train-and-validation-metrics-and-loss-using-torchvision | pytorch, torchvision | 1,740,392,223 |
se_79462366 | stackoverflow | MACHINE_LEARNING | Is there a pre-built wheel for PyTorch for Jetson Nano? | Is there a pre-built wheel for PyTorch for Jetson Nano?
I'm trying to install PyTorch with CUDA support on a Jetson Nano. It's running the Ubuntu 18.04 that the jetson-nano-jp461-sd-card-image image from Nvidia put on it with Python 3.6.9, CUDA 10.2, and JetPack 4.6.6. I tried:
pip3 install torch --index-url https://... | https://stackoverflow.com/questions/79462366/is-there-a-pre-built-wheel-for-pytorch-for-jetson-nano | pytorch, nvidia-jetson-nano | 1,740,365,761 |
se_77494696 | stackoverflow | MACHINE_LEARNING | PyTorch For Loop Optimisations and Speedup techniques | PyTorch For Loop Optimisations and Speedup techniques
This is a problem I've now encountered three times in the past year.
I appreciate that in certain scenarios, a vectorized solution will be better and considerably faster.
However IMHO, there is a trade off between discovering a vectorizing solution and using what i... | https://stackoverflow.com/questions/77494696/pytorch-for-loop-optimisations-and-speedup-techniques | python, for-loop, pytorch | 1,700,136,777 |
se_79464608 | stackoverflow | MACHINE_LEARNING | How do I correctly order conv1d weights in PyTorch when using groups for per-batch unique filters? | How do I correctly order conv1d weights in PyTorch when using groups for per-batch unique filters?
I'm working on a PyTorch project where I have a special parameter that learns conv1d weights. After obtaining these weights, I apply a multiplying factor that can vary for each item in the batch. My goal is to use the gr... | https://stackoverflow.com/questions/79464608/how-do-i-correctly-order-conv1d-weights-in-pytorch-when-using-groups-for-per-bat | python, pytorch | 1,740,424,892 |
se_79463660 | stackoverflow | MACHINE_LEARNING | Tensorflow GradientTape Error "inside its context is signficantly less efficient than calling it outside the context"? | Tensorflow GradientTape Error "inside its context is signficantly less efficient than calling it outside the context"?
I am currently working on Adversarial Attacks on Image dataset. The most important libraries in my project are :
Tensorflow 2.10.1 (with CUDA) (the error is with tensorflow)
Pytorch 1.13.1+... | https://stackoverflow.com/questions/79463660/tensorflow-gradienttape-error-inside-its-context-is-signficantly-less-efficient | python, tensorflow, pytorch, gradient | 1,740,403,055 |
se_75693007 | stackoverflow | MACHINE_LEARNING | Pytorch RuntimeError: mat1 & mat2 shapes cannot be multiplied | Pytorch RuntimeError: mat1 & mat2 shapes cannot be multiplied
I am building a CNN on Pytorch and getting the following error message:
RuntimeError: mat1 and mat2 shapes cannot be multiplied (32x32768 and
512x256)
I have built the following model:
def classifier_block(input, output, kernel_size, stride, last_laye... | https://stackoverflow.com/questions/75693007/pytorch-runtimeerror-mat1-mat2-shapes-cannot-be-multiplied | python, machine-learning, deep-learning, pytorch, conv-neural-network | 1,678,430,896 |
se_79463986 | stackoverflow | MACHINE_LEARNING | Issue with running LLM | Issue with running LLM
I have a RX 6600 XT and Ryzen 7 5700G and I am trying to run the deepseek r1 qweb 7b instill model from huggingface after downloading the model weights, the tokenizer and normal config and the weight's index. I am trying to make the code work and run it. Please explain why my code stops after mo... | https://stackoverflow.com/questions/79463986/issue-with-running-llm | debugging, pytorch, localhost, large-language-model, deepseek | 1,740,409,283 |
se_79463813 | stackoverflow | MACHINE_LEARNING | Autoencoder for multi-label classification task | Autoencoder for multi-label classification task
I'm working on a multi-label classification problem using an autoencoder-based neural network built in PyTorch. The overall idea of my approach is as follows:
I load my dataset from a CSV file, perform cleaning (dropping missing values and unnecessary columns), and selec... | https://stackoverflow.com/questions/79463813/autoencoder-for-multi-label-classification-task | python, machine-learning, pytorch, neural-network, autoencoder | 1,740,406,673 |
se_78828715 | stackoverflow | MACHINE_LEARNING | Finding config.json for Llama 3.1 8B | Finding config.json for Llama 3.1 8B
I installed the Llama 3.1 8B model through Meta's Github page, but I can't get their example code to work. I'm running the following code in the same directory as the Meta-Llama-3.1-8B folder:
import transformers
import torch
pipeline = transformers.pipeline(
"text-generation",
... | https://stackoverflow.com/questions/78828715/finding-config-json-for-llama-3-1-8b | python, pytorch, huggingface, llama, llama3 | 1,722,689,658 |
se_50812838 | stackoverflow | MACHINE_LEARNING | Error in pip install torchvision on Windows 10 | Error in pip install torchvision on Windows 10
on pytorch, installing on Windows 10, conda and Cuda 9.0.
cmd did not complain when i ran conda install pytorch cuda90 -c pytorch, then when I ran pip3 install torchvision I get this error message.
Requirement already satisfied: torchvision in PATHTOFILE\python35\lib\si... | https://stackoverflow.com/questions/50812838/error-in-pip-install-torchvision-on-windows-10 | python, python-3.x, pytorch | 1,528,792,938 |
se_60398211 | stackoverflow | MACHINE_LEARNING | Predicted Image id and box from SSD | Predicted Image id and box from SSD
How to find predicted image id and Box from SSD, I am using this GitHub link here is the test function which I want to save the image id and box
def test(loader, net, criterion, device):
net.eval()
running_loss = 0.0
running_regression_loss = 0.0
running_classificati... | https://stackoverflow.com/questions/60398211/predicted-image-id-and-box-from-ssd | python, machine-learning, deep-learning, pytorch, neural-network | 1,582,644,961 |
se_72431190 | stackoverflow | MACHINE_LEARNING | CUDA Out of memory when there is plenty available | CUDA Out of memory when there is plenty available
I'm having trouble with using Pytorch and CUDA. Sometimes it works fine, other times it tells me RuntimeError: CUDA out of memory. However, I am confused because checking nvidia-smi shows that the used memory of my card is 563MiB / 6144 MiB, which should in theory leav... | https://stackoverflow.com/questions/72431190/cuda-out-of-memory-when-there-is-plenty-available | python, pytorch, nvidia | 1,653,898,754 |
se_79460310 | stackoverflow | MACHINE_LEARNING | loss.backward() takes 10 times the time of network.forward() | loss.backward() takes 10 times the time of network.forward()
I want to train my model using own loss function, however I noticed that loss.backward() takes 2 seconds and learning iteration without this function takes only 0.2 seconds.
I tried to optimize the calculation graph but it didnt do much. All of the tensors a... | https://stackoverflow.com/questions/79460310/loss-backward-takes-10-times-the-time-of-network-forward | python, deep-learning, pytorch | 1,740,258,270 |
se_76220101 | stackoverflow | MACHINE_LEARNING | Comparing the Weights and Biases of several different Yolov8s models trained through transfer learning | Comparing the Weights and Biases of several different Yolov8s models trained through transfer learning
I have 3 different yolov8s models which I would like to assess:
Yolov8s trained with the normal model.train() command
Yolo8vs model trained with a frozen backbone
Yolov8s model trained with all layers frozen
I a... | https://stackoverflow.com/questions/76220101/comparing-the-weights-and-biases-of-several-different-yolov8s-models-trained-thr | python, machine-learning, pytorch, yolo, transfer-learning | 1,683,731,616 |
se_79457741 | stackoverflow | MACHINE_LEARNING | Why do custom backward functions and torch.autograd yield different results after network training? | Why do custom backward functions and torch.autograd yield different results after network training?
I'd like to custom a nn.Linear()'s backward function:
class Linear(torch.autograd.Function):
@staticmethod
def forward(ctx, inputs, weight, bias):
e = F.linear(inputs, weight, bias)
ctx.save_for_... | https://stackoverflow.com/questions/79457741/why-do-custom-backward-functions-and-torch-autograd-yield-different-results-afte | pytorch, neural-network, backpropagation, automatic-differentiation | 1,740,149,216 |
se_68194251 | stackoverflow | MACHINE_LEARNING | How to open/read a feature file with .pth extension? | How to open/read a feature file with .pth extension?
I have a file with .pth extension. It's actually a features/model file.
Please let me know how can I read/open the complete file. | https://stackoverflow.com/questions/68194251/how-to-open-read-a-feature-file-with-pth-extension | python, pytorch, feature-extraction | 1,625,054,028 |
se_78844279 | stackoverflow | MACHINE_LEARNING | Shapes mismatch while training diffusers/UNet2DConditionModel | Shapes mismatch while training diffusers/UNet2DConditionModel
I am trying to train diffusers/UNet2DConditionModel from scratch. Currently I have error on unet forwarding: mat1 and mat2 shapes cannot be multiplied (288x512 and 1280x512). I noticed that mat1 first dimension (288) can vary depending on dataset batch.
How... | https://stackoverflow.com/questions/78844279/shapes-mismatch-while-training-diffusers-unet2dconditionmodel | machine-learning, pytorch, stable-diffusion, image-generation, diffusers | 1,723,041,326 |
se_78734964 | stackoverflow | MACHINE_LEARNING | Ollama isnt using my gpu on a runpod.io pod | Ollama isnt using my gpu on a runpod.io pod
I am testing different AI models on runpod.io. One of those models is dolphin-mixtral:8x22b. I followed Runpod's tutorial for setting up the pod with Ollama: https://docs.runpod.io/tutorials/pods/run-ollama, and I used the H100SXM with 80GB VRAM and 16 vCPU 125 GB RAM.
Howev... | https://stackoverflow.com/questions/78734964/ollama-isnt-using-my-gpu-on-a-runpod-io-pod | pytorch, artificial-intelligence, ollama | 1,720,693,703 |
se_79401951 | stackoverflow | MACHINE_LEARNING | How to correctly change layers in onnx model and restore them in onnxruntime | How to correctly change layers in onnx model and restore them in onnxruntime
I want to change onnx model and then restore the weights when using it with onnxruntime. However, the model doesn't seem to be changed.
First, I load the existing model and change the weights based on this output.
Then I save the model and tr... | https://stackoverflow.com/questions/79401951/how-to-correctly-change-layers-in-onnx-model-and-restore-them-in-onnxruntime | python, pytorch, onnx, onnxruntime | 1,738,305,704 |
se_79455810 | stackoverflow | MACHINE_LEARNING | How do I install a different CUDA-toolkit version in my conda env (that is different from base)? | How do I install a different CUDA-toolkit version in my conda env (that is different from base)?
I am working on a project that requires cuda-toolkit 11.8. However, in my base env, I have 12.6 cuda-toolkit version installed with cuda version 12.6. I remember I was able to do this before, but I am not able to install a... | https://stackoverflow.com/questions/79455810/how-do-i-install-a-different-cuda-toolkit-version-in-my-conda-env-that-is-diffe | pytorch, cuda, conda, cudatoolkit | 1,740,084,522 |
se_79453088 | stackoverflow | MACHINE_LEARNING | How can I perform image clustering effectively? | How can I perform image clustering effectively?
I have images of graph lines with trends, and I want to cluster similar trends together. However, after trying several clustering algorithms, they are not working as well as I expected. I believe that effective feature extraction is crucial, but since the images have a b... | https://stackoverflow.com/questions/79453088/how-can-i-perform-image-clustering-effectively | python, pytorch, computer-vision, conv-neural-network, hierarchical-clustering | 1,740,012,096 |
se_79451702 | stackoverflow | MACHINE_LEARNING | Python multiprocessing.Process hangs when large PyTorch tensors are initialised in both processes | Python multiprocessing.Process hangs when large PyTorch tensors are initialised in both processes
Why does the code shown below either finish normally or hang depending on which lines are commented/uncommented, as described in the table below?
Summary of table: if I initialise sufficiently large tensors in both proces... | https://stackoverflow.com/questions/79451702/python-multiprocessing-process-hangs-when-large-pytorch-tensors-are-initialised | python, pytorch, python-multiprocessing, freeze | 1,739,975,224 |
se_78447930 | stackoverflow | MACHINE_LEARNING | Different tensor output for PyTorch tensors in function | Different tensor output for PyTorch tensors in function
I have a problem with PyTorch, cause I am a beginner. I am trying to implement some encoding algorithm using vocabularies and torch.zero matrix. But I have a trouble, it did not worked properly:
For example having the same function with or without break gives a d... | https://stackoverflow.com/questions/78447930/different-tensor-output-for-pytorch-tensors-in-function | python, pytorch, tensor | 1,715,165,439 |
se_79185168 | stackoverflow | MACHINE_LEARNING | RuntimeError: r.nvmlDeviceGetNvLinkRemoteDeviceType_ INTERNAL ASSERT FAILED at | RuntimeError: r.nvmlDeviceGetNvLinkRemoteDeviceType_ INTERNAL ASSERT FAILED at
I am writing a Python code that trains a classifier to classify samples (10 sentences per sample). I am using Sentence_Transformer with additional layers and running the model training on a linux server. The code is below. The part that mat... | https://stackoverflow.com/questions/79185168/runtimeerror-r-nvmldevicegetnvlinkremotedevicetype-internal-assert-failed-at | python, pytorch, gpu, nvidia, sentence-transformers | 1,731,505,264 |
se_79451900 | stackoverflow | MACHINE_LEARNING | Equivalent of _new_empty_tensor from torchvision in pure torch function | Equivalent of _new_empty_tensor from torchvision in pure torch function
I am trying to use a vision transformer repository (https://github.com/wangjian123799/L-DETR) which uses a version of torch and torchvision. Anyway, because exact versions are not given and torch is super fast at deprecating versions I guess I am ... | https://stackoverflow.com/questions/79451900/equivalent-of-new-empty-tensor-from-torchvision-in-pure-torch-function | pytorch, torchvision | 1,739,978,689 |
se_79335746 | stackoverflow | MACHINE_LEARNING | I want to use the distributed package in PyTorch for point-to-point communication between two ranks. but run error | I want to use the distributed package in PyTorch for point-to-point communication between two ranks. but run error
def runTpoly(rank, size, pp, cs, pkArithmetics_evals,
pkSelectors_evals, domain):
init_process(rank, size)
group2 = torch.distributed.new_group([1,2])
if rank == 0:
device = t... | https://stackoverflow.com/questions/79335746/i-want-to-use-the-distributed-package-in-pytorch-for-point-to-point-communicatio | python, pytorch, distributed-computing | 1,736,247,598 |
se_79431134 | stackoverflow | MACHINE_LEARNING | torch cannot add NamedTuple class to safe_globals | torch cannot add NamedTuple class to safe_globals
I define some named tuple like this:
class checkpoint_t(NamedTuple):
epoch: int
model_state_dict: Dict[str, Any]
optimizer_state_dict: Dict[str, Any]
model_name: str | None = None
However I after save I cannot load this namedtuple via
import torch
fro... | https://stackoverflow.com/questions/79431134/torch-cannot-add-namedtuple-class-to-safe-globals | python, pytorch | 1,739,301,940 |
se_55810665 | stackoverflow | MACHINE_LEARNING | Changing input dimension for AlexNet | Changing input dimension for AlexNet
I am beginner and I am trying to implement AlexNet for image classification. The pytorch implementation of AlexNet is as follows:
class AlexNet(nn.Module):
def __init__(self, num_classes=1000):
super(AlexNet, self).__init__()
self.features = nn.Sequential(
... | https://stackoverflow.com/questions/55810665/changing-input-dimension-for-alexnet | pytorch, computer-vision, conv-neural-network, transfer-learning | 1,556,020,471 |
se_79428887 | stackoverflow | MACHINE_LEARNING | No matter how low is the GPU Vram is set in max_memory, the loading of the model throws error | No matter how low is the GPU Vram is set in max_memory, the loading of the model throws error
On one Nvidia 4070 Super with 12GB VRAM, the loading of deepseek "deepseek-ai/deepseek-llm-7b-chat" model constantly throws error even the GPU VRAM is set at as low as 4GB in max_memory:
Error loading quantized model: Some mo... | https://stackoverflow.com/questions/79428887/no-matter-how-low-is-the-gpu-vram-is-set-in-max-memory-the-loading-of-the-model | pytorch, large-language-model, deepseek | 1,739,248,144 |
se_79433165 | stackoverflow | MACHINE_LEARNING | Gradient computation with PyTorch autograd with 1st and 2nd order derivatives does not work | Gradient computation with PyTorch autograd with 1st and 2nd order derivatives does not work
I am having a weird issue with PyTorch's autograd functionality when implementing a custom loss calculation on a second order differential equation. In the code below, predictions of the neural network are checked if they satis... | https://stackoverflow.com/questions/79433165/gradient-computation-with-pytorch-autograd-with-1st-and-2nd-order-derivatives-do | python, math, pytorch, autograd | 1,739,365,504 |
se_79436736 | stackoverflow | MACHINE_LEARNING | RuntimeError: CUDA error: device-side assert triggered - Compile with TORCH_USE_CUDA_DSA to enable device-side assertions | RuntimeError: CUDA error: device-side assert triggered - Compile with TORCH_USE_CUDA_DSA to enable device-side assertions
I’m encountering the following error while running a TTS (text-to-speech) model on a GPU using PyTorch:
RuntimeError: CUDA error: device-side assert triggered
Compile with `TORCH_USE_CUDA_DSA` to e... | https://stackoverflow.com/questions/79436736/runtimeerror-cuda-error-device-side-assert-triggered-compile-with-torch-use | python, pytorch, runtime-error, text-to-speech | 1,739,459,050 |
se_79439095 | stackoverflow | MACHINE_LEARNING | Remove GPU Ram with VLLM | Remove GPU Ram with VLLM
After running this code within a jupyter notebook, it runs properly. However, the memory is still stored in the GPU. How do I get rid of this memory to clear up space on my GPU. Sorry if I am formatting this question poorly, I am not used to posting. Provided is the code:
llm = LLM(
model=mo... | https://stackoverflow.com/questions/79439095/remove-gpu-ram-with-vllm | python, pytorch, out-of-memory, large-language-model | 1,739,529,802 |
se_79447650 | stackoverflow | MACHINE_LEARNING | How to check the memory consumption of a Python object? | How to check the memory consumption of a Python object?
I want to measure the memory consumption of a Python list, where each list member is a tuple, and each tuple has three Pytorch tensors, two being dense and the other being COO sparse.
I know sys.getsizeof(). But it doesn't work.
I want a convenient way to get the... | https://stackoverflow.com/questions/79447650/how-to-check-the-memory-consumption-of-a-python-object | python, pytorch | 1,739,869,395 |
se_79447495 | stackoverflow | MACHINE_LEARNING | Is there any difference between these two implementations of LoRA (Low-Rank Adaptation)? | Is there any difference between these two implementations of LoRA (Low-Rank Adaptation)?
We all know that LoRA is a low-rank adaptation method, which can be formulated as follows: x = W_0 * x + (A @ B) * x. I have two different code implementations of this. Are there any differences between them?
Code 1:
def forward(s... | https://stackoverflow.com/questions/79447495/is-there-any-difference-between-these-two-implementations-of-lora-low-rank-adap | machine-learning, pytorch, peft | 1,739,865,416 |
se_79439177 | stackoverflow | MACHINE_LEARNING | Why are the outputs from PyTorch and TensorFlow GRU layers not equivalent? | Why are the outputs from PyTorch and TensorFlow GRU layers not equivalent?
I'm trying to port a trained Multi-cell GRU model in TensorFlow 1.x to PyTorch because I want to combine the encoder with some other, more advanced PyTorch modules. I managed to extract the weights to a separate NumPy array per layer. However, ... | https://stackoverflow.com/questions/79439177/why-are-the-outputs-from-pytorch-and-tensorflow-gru-layers-not-equivalent | tensorflow, pytorch, gru | 1,739,531,646 |
se_56649583 | stackoverflow | MACHINE_LEARNING | fastai.vision Import Error: How to fix the import error so I can use ImageDataBunch.from_folder? | fastai.vision Import Error: How to fix the import error so I can use ImageDataBunch.from_folder?
I'm working on google colab ( python 3.6 and GPU), I import torch (1.2.0) nicely and I use the following to import fastai:
import fastai
print(fastai.__version__)
from fastai import *
from fastai.vision i... | https://stackoverflow.com/questions/56649583/fastai-vision-import-error-how-to-fix-the-import-error-so-i-can-use-imagedatabu | python, pytorch, google-colaboratory, torch, fast-ai | 1,560,862,206 |
se_77991685 | stackoverflow | MACHINE_LEARNING | Should the PyTorch validation and test loaders shuffle the data? | Should the PyTorch validation and test loaders shuffle the data?
In PyTorch should you shuffle the validation and test datasets?
According to this pytorch discussion thread I believe the answer is no, it should be False.
The official docs/tutorial states While training a model, we typically want to pass samples in “mi... | https://stackoverflow.com/questions/77991685/should-the-pytorch-validation-and-test-loaders-shuffle-the-data | pytorch | 1,707,873,648 |
se_55792837 | stackoverflow | MACHINE_LEARNING | In pytorch data parallel mode, how to use the global tensor? | In pytorch data parallel mode, how to use the global tensor?
In this example, I wish the z_proto could be global for different GPUs. However, in the data parallel mode, it is split into different GPUs as well. How to solve such a problem? Thank you.
class SequencePrototypeTokenClassification(nn.Module):
def __init... | https://stackoverflow.com/questions/55792837/in-pytorch-data-parallel-mode-how-to-use-the-global-tensor | mpi, pytorch | 1,555,928,442 |
se_55740332 | stackoverflow | MACHINE_LEARNING | How to save cuda memory with torch in this case? | How to save cuda memory with torch in this case?
Just as the code below, I am trying to get the mean of 47 repeated outputs of the model. But it is always out of memory. If I remove the z_proto_class_list.append(z_proto_class), then it is fine. I guess it is because the memory is freed if I don't append the tensor. I ... | https://stackoverflow.com/questions/55740332/how-to-save-cuda-memory-with-torch-in-this-case | memory-management, out-of-memory, pytorch | 1,555,569,280 |
se_79444383 | stackoverflow | MACHINE_LEARNING | I need help understanding code for creating a dataset in an PyTorch tutorial | I need help understanding code for creating a dataset in an PyTorch tutorial
I'm reading through a PyTorch tutorial for transfer learning and I'm having a hard time figuring out exactly what the following block is doing, with regards to generating the dataset:
# Data augmentation and normalization for training
# Just ... | https://stackoverflow.com/questions/79444383/i-need-help-understanding-code-for-creating-a-dataset-in-an-pytorch-tutorial | python, for-loop, pytorch | 1,739,765,617 |
se_60721831 | stackoverflow | MACHINE_LEARNING | Deploying a pytorch model in java | Deploying a pytorch model in java
I have a pytorch model trained and saved and now I want to use it in a java (not android) environment in windows os (since I'm using some library only available in java), Is it possible? I couldn't find a straight answer in the pytorch docs, and when clicking java api docs the link is... | https://stackoverflow.com/questions/60721831/deploying-a-pytorch-model-in-java | java, pytorch | 1,584,445,810 |
se_79443444 | stackoverflow | MACHINE_LEARNING | Error loading model using Torch TensorRT in Libtorch on Windows | 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 Cmake to generate lib and dll
Option : Export
If you want ... | https://stackoverflow.com/questions/79443444/error-loading-model-using-torch-tensorrt-in-libtorch-on-windows | python, pytorch, tensorrt, libtorch, torchscript | 1,739,720,622 |
se_79440564 | stackoverflow | MACHINE_LEARNING | Impossible to install mistral-inference python package | Impossible to install mistral-inference python package
I want to install the python package 'mistral-inference'.
My computer has a GPU and is using windows 11.
Python 3.13.2
pip 24.3.1
I created a new virtual environnment.
Then I ran 'pip install mistral-inference'.
I got the following error:
Collecting xformers>=0.0.... | https://stackoverflow.com/questions/79440564/impossible-to-install-mistral-inference-python-package | python, pytorch, pip, mistral-7b | 1,739,567,681 |
se_79441614 | stackoverflow | MACHINE_LEARNING | How does Pytorch handle in-place operations without losing information necessary for backpropagation? | How does Pytorch handle in-place operations without losing information necessary for backpropagation?
I've seen several questions about in-place operations regarding their efficiency, but I'm actually more confused about the inner-workings of pytorch.
Let's take a simple example like
a = torch.randn(10)
b = torch.rand... | https://stackoverflow.com/questions/79441614/how-does-pytorch-handle-in-place-operations-without-losing-information-necessary | pytorch | 1,739,626,715 |
se_79177291 | stackoverflow | MACHINE_LEARNING | Colab stuck in an infinite loop while installing PyTorch-related packages | Colab stuck in an infinite loop while installing PyTorch-related packages
I'm trying to install several PyTorch-related packages in Colab, but the installation process gets stuck in an infinite loop and doesn't complete, even though it doesn't give any error messages. I'm uninstalling and reinstalling the packages, bu... | https://stackoverflow.com/questions/79177291/colab-stuck-in-an-infinite-loop-while-installing-pytorch-related-packages | pytorch, scatter-plot, torch, google-cloud-colab-enterprise | 1,731,321,059 |
se_76366780 | stackoverflow | MACHINE_LEARNING | ModuleNotFoundError: No module named 'torch' when installing xformers for Stable Diffusion on Macbook M2 Max | ModuleNotFoundError: No module named 'torch' when installing xformers for Stable Diffusion on Macbook M2 Max
I'm working on Stable Diffusion and try to install xformers to train my Lora.
My Computer is Macbook M2 Max and already installed latest python3.11 and pip 23.1.2
which python3
/Library/Frameworks/Pytho... | https://stackoverflow.com/questions/76366780/modulenotfounderror-no-module-named-torch-when-installing-xformers-for-stable | python, pip, pytorch, stable-diffusion | 1,685,463,520 |
se_67934643 | stackoverflow | MACHINE_LEARNING | Pytorch inferencing from the model is giving me different results every time | Pytorch inferencing from the model is giving me different results every time
I have created and trained one very simple network in pytorch as shown below:
self.task_layers[task][task_layer_key]; TaskLayerManager(
(taskLayers): ModuleList(
(0): lc_hidden(
(dropout_layer): Dropout(p=0.0, inplace=False)
... | https://stackoverflow.com/questions/67934643/pytorch-inferencing-from-the-model-is-giving-me-different-results-every-time | python, deep-learning, pytorch, torch | 1,623,404,283 |
se_68220613 | stackoverflow | MACHINE_LEARNING | Where can I get official PyTorch documentation in pdf form? | Where can I get official PyTorch documentation in pdf form?
I want to learn PyTorch in great detail.
I have read all the docs and tutorials on the main site. I learn better from paper. When I print from website pages, I am getting very small letters. This makes the printouts difficult to read them.
The packages offer ... | https://stackoverflow.com/questions/68220613/where-can-i-get-official-pytorch-documentation-in-pdf-form | printing, pytorch, resources | 1,625,207,764 |
se_75529047 | stackoverflow | MACHINE_LEARNING | how to print model summary of yolov5 model | how to print model summary of yolov5 model
How to print model summary of yolov5 model for a .pt file?
# Model
model = torch.hub.load('ultralytics/yolov5', 'yolov5s', device='cpu')
from torchstat import stat #try 1
stat(model, (3,640,640))
from torchsummary import summary #try 2
from torchinfo import summary #try 3
s... | https://stackoverflow.com/questions/75529047/how-to-print-model-summary-of-yolov5-model | pytorch, model, yolov5 | 1,677,047,977 |
se_77880191 | stackoverflow | MACHINE_LEARNING | RuntimeError: Expected is_sm80 || is_sm90 to be true, but got false | RuntimeError: Expected is_sm80 || is_sm90 to be true, but got false
I want to run a local FineTuning of LLama. I followed the colab notebook from the pytorch blog post "Finetune LLMs on your own consumer hardware using tools from PyTorch and Hugging Face ecosystem".
I got everything up and running but in the training ... | https://stackoverflow.com/questions/77880191/runtimeerror-expected-is-sm80-is-sm90-to-be-true-but-got-false | pytorch, cuda, nvidia, huggingface-transformers, large-language-model | 1,706,187,878 |
se_78717341 | stackoverflow | MACHINE_LEARNING | Keras training speed with PyTorch backend is a lot slower than with TensorFlow | Keras training speed with PyTorch backend is a lot slower than with TensorFlow
I am on native Windows and I used old Keras with TensorFlow 2.10 (GPU accelerated) before. I wanted to try Keras 3 with PyTorch backend.
Can someone please help me why this model trains 10x slower with Keras 3.4.1 and PyTorch 2.3.1 backend?... | https://stackoverflow.com/questions/78717341/keras-training-speed-with-pytorch-backend-is-a-lot-slower-than-with-tensorflow | python, performance, tensorflow, keras, pytorch | 1,720,356,519 |
se_79434940 | stackoverflow | MACHINE_LEARNING | Why is the GPU slower than the CPU when performing svd on a double-precision array? | Why is the GPU slower than the CPU when performing svd on a double-precision array?
I get the same results in both Julia and Python. Singular Value Decomposition is slower on the GPU than on the CPU for Float64 arrays. (Float32 arrays behave how one would expect, with the GPU being faster.)
Python benchmark code using... | https://stackoverflow.com/questions/79434940/why-is-the-gpu-slower-than-the-cpu-when-performing-svd-on-a-double-precision-arr | python, pytorch, cuda, julia, svd | 1,739,413,899 |
se_58848100 | stackoverflow | MACHINE_LEARNING | Is there a similar function in tensorflow like load_state_dict() in Pytorch? | Is there a similar function in tensorflow like load_state_dict() in Pytorch?
Like it has been described, I am wondering is there a similar function in tensorflow for load_state_dict() like the one does in Pytorch. To demonstrate a scenario, please refer to the code following:
# Suppose we have two correctly initiali... | https://stackoverflow.com/questions/58848100/is-there-a-similar-function-in-tensorflow-like-load-state-dict-in-pytorch | tensorflow, neural-network, deep-learning, pytorch | 1,573,695,191 |
se_79436298 | stackoverflow | MACHINE_LEARNING | How to investigate memory consumption of pytorch_geometric data | How to investigate memory consumption of pytorch_geometric data
I am working on a framework that uses pytorch_geometric graph data stored in the usual way in data.x and data.edge_index Additionally, the data loading process appends multiple other keys to that data object, such as the path to the database or the model'... | https://stackoverflow.com/questions/79436298/how-to-investigate-memory-consumption-of-pytorch-geometric-data | pytorch, pytorch-dataloader, pytorch-geometric | 1,739,452,633 |
se_79372090 | stackoverflow | MACHINE_LEARNING | Matrix multiplication in log space for sum of exponents | Matrix multiplication in log space for sum of exponents
I have been coding an implementation for the following problem: Given two matrices A and B, both with the same shape (bs, n, m, m), I want to compute the following expression in an optimal manner.
out = torch.log(torch.exp(A).sum(dim=1)@torch.exp(B).sum(dim=1))
T... | https://stackoverflow.com/questions/79372090/matrix-multiplication-in-log-space-for-sum-of-exponents | python, pytorch | 1,737,392,041 |
se_79433640 | stackoverflow | MACHINE_LEARNING | Python: Deep Q Learning agent doesn't seem to learn | Python: Deep Q Learning agent doesn't seem to learn
I am using gymnasium and torch. I initially created a custom environment by following the official gymnasium's guide: it shows you how to build a NxN Box where the agent needs to reach a randomly placed target by moving right, up, left or down.
I modified it so t... | https://stackoverflow.com/questions/79433640/python-deep-q-learning-agent-doesnt-seem-to-learn | python, deep-learning, pytorch, agent, gymnasium | 1,739,374,552 |
se_65343377 | stackoverflow | MACHINE_LEARNING | Adam optimizer with warmup on PyTorch | Adam optimizer with warmup on PyTorch
In the paper Attention is all you need, under section 5.3, the authors suggested to increase the learning rate linearly and then decrease proportionally to the inverse square root of steps.
How do we implement this in PyTorch with Adam optimizer? Preferably without additional pac... | https://stackoverflow.com/questions/65343377/adam-optimizer-with-warmup-on-pytorch | python, machine-learning, pytorch | 1,608,217,976 |
se_71498324 | stackoverflow | MACHINE_LEARNING | Pytorch RuntimeError: CUDA out of memory with a huge amount of free memory | Pytorch RuntimeError: CUDA out of memory with a huge amount of free memory
While training the model, I encountered the following problem:
RuntimeError: CUDA out of memory. Tried to allocate 304.00 MiB (GPU 0; 8.00 GiB total capacity; 142.76 MiB already allocated; 6.32 GiB free; 158.00 MiB reserved in total by PyTorch)... | https://stackoverflow.com/questions/71498324/pytorch-runtimeerror-cuda-out-of-memory-with-a-huge-amount-of-free-memory | python, machine-learning, pytorch, computer-vision | 1,647,438,825 |
se_64277224 | stackoverflow | MACHINE_LEARNING | Segmentation Fault when exporting to onnx a quantized Pytorch model | Segmentation Fault when exporting to onnx a quantized Pytorch model
I am trying to export a model to the onnx format. The architecture is complicated so I won't share it here, but basically, I have the network weights in a .pth file. I'm able to load them, create the network and perform inference with it.
It's import... | https://stackoverflow.com/questions/64277224/segmentation-fault-when-exporting-to-onnx-a-quantized-pytorch-model | python, segmentation-fault, pytorch, onnx | 1,602,235,338 |
se_66268131 | stackoverflow | MACHINE_LEARNING | How does one fix a `Exception: process 0 terminated with signal SIGSEGV` error and if the single gpu code works fine? | How does one fix a `Exception: process 0 terminated with signal SIGSEGV` error and if the single gpu code works fine?
I start 2 processes because I only have 2 gpus but then it gives me a Exception: process 0 terminated with signal SIGSEGV. This code does work with multiple cpus (or at least no error is thrown). Also,... | https://stackoverflow.com/questions/66268131/how-does-one-fix-a-exception-process-0-terminated-with-signal-sigsegv-error-a | python, multiprocessing, pytorch, distributed-computing | 1,613,682,189 |
se_54846905 | stackoverflow | MACHINE_LEARNING | PyTorch get all layers of model | PyTorch get all layers of model
What's the easiest way to take a pytorch model and get a list of all the layers without any nn.Sequence groupings? For example, a better way to do this?
import pretrainedmodels
def unwrap_model(model):
for i in children(model):
if isinstance(i, nn.Sequential): unwrap_model(... | https://stackoverflow.com/questions/54846905/pytorch-get-all-layers-of-model | python, pytorch | 1,550,961,072 |
se_68602072 | stackoverflow | MACHINE_LEARNING | How to maintain state in a DataLoader's Dataset | How to maintain state in a DataLoader's Dataset
I have something like: (see self.cache for the bit that's interesting).
class DescriptorDataset(torch.utils.data.Dataset):
def __init__(self, descriptor_dir):
super().__init__()
self.file_paths = glob(osp.join(descriptor_dir, '*'))
self.im... | https://stackoverflow.com/questions/68602072/how-to-maintain-state-in-a-dataloaders-dataset | pytorch | 1,627,734,204 |
se_79409149 | stackoverflow | MACHINE_LEARNING | Why do I have to unsqueeze the data from torch.Size([50]) to torch.Size([50, 1]) | Why do I have to unsqueeze the data from torch.Size([50]) to torch.Size([50, 1])
I was doing the PyTorch Deep Learning course from FreeCodeCamp and the doubt is:
weight = 0.7
bias = 0.3
start = 0
end = 1
step = 0.02
X = torch.arange(start, end, step).unsqueeze(dim=1)
y=weight*X + bias
X[:10], y[:10]
train_split=int(0... | https://stackoverflow.com/questions/79409149/why-do-i-have-to-unsqueeze-the-data-from-torch-size50-to-torch-size50-1 | python, machine-learning, deep-learning, pytorch | 1,738,593,848 |
se_57238344 | stackoverflow | MACHINE_LEARNING | I have a GPU and CUDA installed in Windows 10 but Pytorch's torch.cuda.is_available() returns false; how can I correct this? | I have a GPU and CUDA installed in Windows 10 but Pytorch's torch.cuda.is_available() returns false; how can I correct this?
I have PyTorch installed on a Windows 10 machine with a Nvidia GTX 1050 GPU. I have installed the CUDA Toolkit and tested it using Nvidia instructions and that has gone smoothly, including e... | https://stackoverflow.com/questions/57238344/i-have-a-gpu-and-cuda-installed-in-windows-10-but-pytorchs-torch-cuda-is-availa | windows, pytorch | 1,564,293,470 |
se_78638576 | stackoverflow | MACHINE_LEARNING | Error RuntimeError: CUDA error: operation not supported when tried to locate something into CUDA | Error RuntimeError: CUDA error: operation not supported when tried to locate something into CUDA
Here is my code:
from transformers import AutoModelForCausalLM, AutoTokenizer, QuantoConfig
import torch
device = "cuda:0"
model_id = "bigscience/bloom-560m"
quantization_config = QuantoConfig(weights="int8")
model = Auto... | https://stackoverflow.com/questions/78638576/error-runtimeerror-cuda-error-operation-not-supported-when-tried-to-locate-som | python, pytorch, huggingface-transformers | 1,718,727,328 |
se_79422978 | stackoverflow | MACHINE_LEARNING | Different concate dimension parameters in the up-and-down sampling phase of U-shaped networks in the diffusion model | Different concate dimension parameters in the up-and-down sampling phase of U-shaped networks in the diffusion model
The error I am getting is
File "/media/xd/hdd/wxy/spectraldiff_diffusion-master/codes/unet3d.py", line 113, in forward
x = torch.cat((x, residual_x), dim=1)
RuntimeError: Sizes of tensors must ma... | https://stackoverflow.com/questions/79422978/different-concate-dimension-parameters-in-the-up-and-down-sampling-phase-of-u-sh | python, machine-learning, deep-learning, pytorch, neural-network | 1,739,009,674 |
se_76310533 | stackoverflow | MACHINE_LEARNING | How to fix "Trainer: evaluation requires an eval_dataset" in Huggingface Transformers? | How to fix "Trainer: evaluation requires an eval_dataset" in Huggingface Transformers?
I’m trying to do a finetuning without an evaluation dataset.
For that, I’m using the following code:
training_args = TrainingArguments(
output_dir=resume_from_checkpoint,
evaluation_strategy="epoch",
per_device... | https://stackoverflow.com/questions/76310533/how-to-fix-trainer-evaluation-requires-an-eval-dataset-in-huggingface-transfo | python, pytorch, huggingface-transformers, pre-trained-model, huggingface-trainer | 1,684,799,641 |
se_77139509 | stackoverflow | MACHINE_LEARNING | No module named 'torch' in Jupyter Notebook although pytorch is installed | No module named 'torch' in Jupyter Notebook although pytorch is installed
The Jupyter Notebook not able to find the torch module,despite I have it installed.
In the console it has no issue to import torch:
How do it fix the issue so that I can import torch in Jupyter Notebook?
Note: the kernel "scan_env"(Jup... | https://stackoverflow.com/questions/77139509/no-module-named-torch-in-jupyter-notebook-although-pytorch-is-installed | jupyter-notebook, pytorch, virtualenv | 1,695,187,604 |
se_71135018 | stackoverflow | MACHINE_LEARNING | Is there a function in Pytorch to do a batch span selection? | Is there a function in Pytorch to do a batch span selection?
I have three tensors:
tokens (shape [N, T]),
start_index of shape [N] and values in range [0, T)
end_index of shape [N] and values in range [0, T)
I want to select spans from the batch of token sequences tokens using start_index and end_index.
Essentially ... | https://stackoverflow.com/questions/71135018/is-there-a-function-in-pytorch-to-do-a-batch-span-selection | python-3.x, pytorch, vectorization | 1,644,970,866 |
se_79424280 | stackoverflow | MACHINE_LEARNING | Can't manage to run Pytorch with GPU | Can't manage to run Pytorch with GPU
everyone! I have a problem - I am trying to make pytorch run on GPU, but I got no success.
I innstalled CUDA version 12.6, downloaded CUDA 12.6 compatible pytorch, reinstalled all things a few times, but python still outputs that no CUDA found. What else could I do?
My specs - ... | https://stackoverflow.com/questions/79424280/cant-manage-to-run-pytorch-with-gpu | python, pytorch | 1,739,069,971 |
se_71277693 | stackoverflow | MACHINE_LEARNING | Pytorch: How to get the first N item from dataloader | Pytorch: How to get the first N item from dataloader
There are 3000 pictures in my list, but I only want the first N of them, like 1000, for training.
I wonder how can I achieve this by changing the loop code:
for (image, label) in enumerate(train_loader): | https://stackoverflow.com/questions/71277693/pytorch-how-to-get-the-first-n-item-from-dataloader | pytorch, enumerate | 1,645,887,640 |
se_52656692 | stackoverflow | MACHINE_LEARNING | Debugging in Google Colab | Debugging in Google Colab
I am running the following code snippet in google colab in a single cell:
%debug
# Create tensors of shape (10, 3) and (10, 2).
x = torch.randn(10, 3)
y = torch.randn(10, 2)
# Build a fully connected layer.
linear = nn.Linear(3, 2)
print ('w: ', linear.weight)
print ('b: ', linear.bias)
I... | https://stackoverflow.com/questions/52656692/debugging-in-google-colab | python, deep-learning, pytorch, tensor, google-colaboratory | 1,538,698,514 |
se_79026181 | stackoverflow | MACHINE_LEARNING | How do I run a LLM on multiple GPUs? | How do I run a LLM on multiple GPUs?
I am trying to run Mistral-7b across multiple GPUs, as I have a large number of prompts. I am using a cluster, which provides usage of up to 4 GPUs. However, only one of them is used for inference.
model_name = 'mistralai/Mistral-7B-Instruct-v0.2'
# Load the model and tokenizer
to... | https://stackoverflow.com/questions/79026181/how-do-i-run-a-llm-on-multiple-gpus | pytorch, gpu, large-language-model | 1,727,338,262 |
se_79421842 | stackoverflow | MACHINE_LEARNING | How to Select/Isolate GPUs when Using ROCm in Python | How to Select/Isolate GPUs when Using ROCm in Python
Is their an equivalent for os.environ["CUDA_VISIBLE_DEVICES"]="0" in the os module for isolating GPUs when using AMD ROCm? | https://stackoverflow.com/questions/79421842/how-to-select-isolate-gpus-when-using-rocm-in-python | python, tensorflow, pytorch, amd-gpu, amd-rocm | 1,738,953,088 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.