akankshakshurai/cuda-error-resolution-analysis huggingface dataset:
Some questions about CUDA usage

username: ChineseBest
cooked: <p>Hi, I wonder how to understand the CUDA usage about training neural networks based on GPU.</p>
<p>My question lies in the memory usage before and after training. Before training, I think only our model will occupy memories. After training, if we delete all the other data, the memories should not change a lot.</p>
<p>However, if I do not run torch.cuda.empty_cache(), the memory usage will be quite large. Even if I run this method, the memory usage is still large than the original memory occupy.</p>
<p>Can anyone please help me? Thanks a lot.</p>

username: eqy
cooked: <p>The behavior your are seeing is normal and expected because PyTorch uses a caching allocator for GPU memory. The caching allocator will often allocate more memory than is needed and hold on to it for longer than it is used during the execution of a PyTorch program because it can be expensive to call <code>cudaMalloc</code> and <code>cudaFree</code> repeatedly as tensors (such as inputs and model activations) are created and destroyed during training. By caching allocations, memory can be reused immediately. However, as you noticed, if you do not call <code>empty_cache()</code> it will still be held by the underlying Python process.</p>

username: ChineseBest
cooked: <p>OK, thanks a lot. After each training process, I will call this instruction.</p>

username: raining_day513
cooked: <blockquote>
<p>The caching allocator will often allocate more memory than is needed and hold on to it for longer than it is used during the execution of a PyTorch program</p>
</blockquote>
<p>How to get the exact GPU memory usage then? Is that <code>torch.cuda.memory_allocated</code>?</p>

username: eqy
cooked: <p>If you mean memory used by tensors, then yes <code>torch.cuda.memory_allocated</code> would be accurate. Note that it would not consider CUDA context memory usage or memory used by library kernels such as those in cuBLAS or cuDNN.</p>
Unpacked sequences are of different lengths than expected

username: Kornelija
cooked: <p>Hi,</p>
<p>Was hoping anyone could confirm that my understanding is correct and maybe even explain why that happens because I don’t see any clues in the documentation.</p>
<p>I’m training an LSTM using variable length data sequences and I noticed that after unpacking lengths of training sequences differ from validation set although I pad all data points to the same max length when initializing the dataset. I believe they end up truncated to the max length of that particular batch. I am packing/unpacking the two batches separately in the training loop (my dataset is pretty small so I feed the entire training data as one batch).</p>
<p>Thank you!</p>
Pytorch docker image gives unexpected CUDA initialization error

username: maxim0815
cooked: <p>Hello everyone,</p>
<p>I wanted to use a newer version for my pytroch base image. I wanted to use this <a href="https://Tag" rel="noopener nofollow ugc">https://hub.docker.com/layers/pytorch/pytorch/2.0.0-cuda11.7-cudnn8-devel/images/sha256-96ccb2997a131f2455d70fb78dbb284bafe4529aaf265e344bae932c8b32b2a4?context=explore</a>.</p>
<p>Checking for cuda availability ends up in the following error:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/0/1/01777f9db6fa31a375a37a532d038e7c6c3de289.png" data-download-href="https://discuss.pytorch.org/uploads/default/01777f9db6fa31a375a37a532d038e7c6c3de289" title="Screenshot from 2023-06-01 10-38-23"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/0/1/01777f9db6fa31a375a37a532d038e7c6c3de289_2_690x55.png" alt="Screenshot from 2023-06-01 10-38-23" data-base62-sha1="cYv71jzKOaeoH5z7heicwCa8hX" width="690" height="55" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/0/1/01777f9db6fa31a375a37a532d038e7c6c3de289_2_690x55.png, https://discuss.pytorch.org/uploads/default/optimized/3X/0/1/01777f9db6fa31a375a37a532d038e7c6c3de289_2_1035x82.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/0/1/01777f9db6fa31a375a37a532d038e7c6c3de289_2_1380x110.png 2x" data-dominant-color="060606"><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">Screenshot from 2023-06-01 10-38-23</span><span class="informations">1903×152 23.9 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>Even if nvidia-smi outputs the following:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/2/c/2c04906020fdae1921b1abd7ffb65e7816871a1d.png" data-download-href="https://discuss.pytorch.org/uploads/default/2c04906020fdae1921b1abd7ffb65e7816871a1d" title="Screenshot from 2023-06-01 10-40-04"><img src="https://discuss.pytorch.org/uploads/default/original/3X/2/c/2c04906020fdae1921b1abd7ffb65e7816871a1d.png" alt="Screenshot from 2023-06-01 10-40-04" data-base62-sha1="6hoMN346v2OSQbnEkAFBAuZ9yCp" width="690" height="307" data-dominant-color="080808"><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">Screenshot from 2023-06-01 10-40-04</span><span class="informations">742×331 24.6 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>I would appreciate feedback if anyone knows where the problem might be. I have not made any changes to the image itself.</p>
Index filtering or vector product for filtered backpropagation

username: ThibautChataing
cooked: <p>Hello,</p>
<p>I’m working on a supervised deep learning model. The loss used should be different depends on the class of the input.<br>
For example : If X_0 is the input vector and its from the class 0, resp X_1 from the class 1. The used loss for X_0 will be L_0 and the one for X_1 will be L_1.</p>
<p>Now we are in a training session. Inside the current batch we have D our current data of n samples and Y their associated label (either 0 or 1).</p>
<p>What is the difference, if there is one,  between :</p>
<ol>
<li>
<p>Filtering the calcul though index selection<br>
LOSS = L_0(D[class == 0]) + L_1(D[class == 1])</p>
</li>
<li>
<p>Forcing 0 for the unwanted calcul.<br>
LOSS = (1-Y)<em>L_0(D) + Y</em>L_1(D)</p>
</li>
</ol>
<p>Please.</p>

username: ptrblck
cooked: <p>I would claim it depends on the used reductions in the loss functions and how the losses are masked in the second approach.<br>
E.g. if you are calculating the mean losses in <code>L_0</code> and <code>L_1</code> I would expect to see a difference since the number of samples would differ. However, I also wouldn’t know how you are masking the reduced losses in the second use case if the losses are already reduced.</p>

username: ThibautChataing
cooked: <p>Thank you I did not think about the impact of the data size used in the following calculation.</p>
Dataloader adding extra dimension, I don't know why

username: Abhishek_Gupta
cooked: <p>Let me explain the secenry which i think is not important. I have created a tensor of images length of which is 30 so its shape is <code>(30,3,448,448)</code> where 3 is color channel and 448 is the pixel values.</p>
<p>But after passing it through DataLoader:<br>
<code>train_data = DataLoader(               batch_size = 32,               shuffle = False,               dataset = train_data )</code></p>
<p>where <code>x_train</code> has the shape of mentions above.</p>
<p>After doing the above operation with DataLoader the shape of <code>train_data</code> becomes <code>(30,30,3,448,448)</code>. Now my Question from where did that <code>30</code> came from as i was expecting <code>(30,3,448,448)</code></p>
<p>Hope You all understand the problem</p>

username: ptrblck
cooked: <p>I don’t fully understand the issue as I would expect to see an output batch from the <code>DataLoader</code> in the shape <code>[batch_size=32, 30, 3, 448, 448]</code> since the <code>DataLoader</code> will add the batch dimension containing <code>batch_size</code> samples.<br>
Also, <code>x_train</code> is undefined so I assume you are passing it to the <code>DataLoader</code> instead of <code>train_data</code>?</p>

username: Abhishek_Gupta
cooked: <p>Yes my bad ! While posting by mistakenly wrote <code>train_data</code> instead of <code>x_train</code></p>
<p>Why would it add <code>batch_size</code> in dim = 0, because i think dataloader works here to divide the data in size of <code>batch_size</code> so if the data has size <code>n</code> so it will divide data such each batch will have size <code>(32,3,448,448)</code>. Here <code>n = 30</code>, so there will be only one batch of <code>(30,3,448,448)</code></p>
<p>I know I am wrong, Please tell me wherever I am wrong</p>
<p>Thank You Sir for replying (<a class="mention" href="/u/ptrblck">@ptrblck</a> )</p>

username: ptrblck
cooked: <p>Sorry I might have misunderstood your use case as I thought each sample has a shape of <code>[30, 3, 448, 448]</code>, but it seems that’s the overall dataset.<br>
In this case the code works fone for me and I see the expected shape:</p>
<pre><code class="lang-python">train_data = torch.randn(30, 3, 448, 448)
loader = DataLoader(train_data, batch_size=32, shuffle=False)

for data in loader:
    print(data.shape)
# torch.Size([30, 3, 448, 448])
</code></pre>
Retrieve segmentation labels from segmentation mask

username: Tornike_Amaglobeli
cooked: <p>Hi, i’m trying to do semantic segmentation using Segformer(I would appreciate an advice if there is a better transformer based segmentation model).</p>
<p>i have a dataset with images with the mask(label) images but i don’t have a csv of dataset where labels are with their mask representations (tuple of rgb color value, for example ((255,235,0): car) and etc…)</p>
<p>Question is, how can i retrieve segmentation mask colors for each class in the dataset? is there any way to do that ?</p>
How to use Pack_padded_sequence in TCN?

username: yanzhou01
cooked: <p>I am inputing pad_sequence to the conv1d based TCN model to train.<br>
I want to ignore the zero paddings during the training.<br>
So I tried to input the pack padded sequence object instead, just as in the way of training RNN-based models.<br>
However, the errors came out and it won’t work.</p>
<p>Could you please help me with this issue?</p>
AttributeError: module 'torch.cuda._memory_viz' has no attribute 'profile_plot'

username: Frank_Lu
cooked: <p>I want to use torch.cuda._memory_viz.profile_plot to review my gpu usage. However, I got this error <code>AttributeError: module 'torch.cuda._memory_viz' has no attribute 'profile_plot'</code>.<br>
My torch version is 1.13+cu117.<br>
Anyone can help? Thanks.</p>

username: ptrblck
cooked: <p><code>profile_plot</code> wasn’t available in <code>torch==1.13.0</code> so you would need to update your PyTorch installation.</p>

username: Frank_Lu
cooked: <p><a class="mention" href="/u/ptrblck">@ptrblck</a><br>
Thanks. I have updated the version to 2.0.0 and find it. However, when I do<br>
<code>plot_html = profile_plot(prof, device=torch.device("cuda:0"))</code><br>
it shows:</p>
<blockquote>
<p>Traceback (most recent call last):<br>
File “/media/lk2/sgccai/15_DLAcceleration/lukuan_lightning_test/torch_viz.py”, line 54, in <br>
plot_html = profile_plot(prof, device=torch.device(“cuda:0”))<br>
File “/home/lk2/anaconda3/envs/ai/lib/python3.10/site-packages/torch/cuda/_memory_viz.py”, line 415, in profile_plot<br>
for event in memory_profile._op_tree.sorted_nodes:<br>
AttributeError: ‘profile’ object has no attribute ‘_op_tree’</p>
</blockquote>
<p>My whole code is:</p>
<blockquote>
<p>import torch<br>
import torch.nn<br>
import torch.optim<br>
import torch.profiler<br>
import torch.utils.data<br>
import torchvision.datasets<br>
import torchvision.models<br>
import torchvision.transforms as T<br>
import os<br>
from torch.cuda._memory_viz import profile_plot<br>
import datetime</p>
<p>transform = T.Compose(<br>
[T.Resize(224),<br>
T.ToTensor(),<br>
T.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])<br>
train_set = torchvision.datasets.CIFAR10(root=‘./data’, train=True, download=True, transform=transform)<br>
train_loader = torch.utils.data.DataLoader(train_set, batch_size=32, shuffle=True)</p>
<p>device = torch.device(“cuda:0”)<br>
model = torchvision.models.resnet18(weights=‘IMAGENET1K_V1’).cuda(device)<br>
criterion = torch.nn.CrossEntropyLoss().cuda(device)<br>
optimizer = torch.optim.SGD(model.parameters(), lr=0.001, momentum=0.9)<br>
model.train()</p>
<p>def train(data):<br>
inputs, labels = data[0].to(device=device), data[1].to(device=device)<br>
outputs = model(inputs)<br>
loss = criterion(outputs, labels)<br>
optimizer.zero_grad()<br>
loss.backward()<br>
optimizer.step()</p>
<p>with torch.profiler.profile(<br>
schedule=torch.profiler.schedule(wait=1, warmup=1, active=3, repeat=2),<br>
record_shapes=True,<br>
profile_memory=True,<br>
with_stack=True<br>
) as prof:<br>
for step, batch_data in enumerate(train_loader):<br>
if step &gt;= (1 + 1 + 3) * 2:<br>
break<br>
train(batch_data)<br>
prof.step()</p>
<p>trace_dir = os.path.abspath(os.path.join(os.path.split(<strong>file</strong>)[0], “.”, “traces”))<br>
now = datetime.datetime.now().strftime(“%Y_%m_%d:%H.%M.%S.pt.trace.json.gz”)<br>
prof.export_chrome_trace(os.path.join(trace_dir, f"lukuan_{now}"))</p>
<p>plot_html = profile_plot(prof, device=torch.device(“cuda:0”))<br>
with open(os.path.join(trace_dir, f"lukuan_{now}.html"), “w”) as f:<br>
f.write(plot_html)</p>
</blockquote>
Modifying network weights under DistributedDataParallel

username: aluo-x
cooked: <p>Suppose I have a tensor that requires gradient, and I want to clamp the values or the norm of this tensor, what is the correct way to do this using DistributedDataParallel?</p>
<p>My guess is to use a barrier, modify the weights, then use a second barrier.</p>

username: eqy
cooked: <p>Is this tensor a model parameter? I’m not sure I see why a barrier would be needed assuming the clamp would have the same effect across all replicas, as DDP would only synchronize the gradients of parameters—each replica can then apply the clamp after e.g., the optimizer step without needing to care about synchronization as the other replicas would be doing the same operation on private copies of the same data.</p>
Save LibTorch tensor to flattened 1D C array

username: velenos14
cooked: <p>I want to save a 3D LibTorch complex-tensor (<code>kComplexDouble</code>) to a 1D C complex-array (``std::complex) in a C++ program.</p>
<p>The 3D tensor is shape <code>(N_rs, N_thetas, N_phis)</code>.</p>
<p>The 1D C array has length <code>N_rs * N_thetas * N_phis</code> and is declared as: <code>std::complex&lt;double&gt; * Psi_spec = new std::complex&lt;double&gt;       [N_rs * N_thetas * N_phis];</code></p>
<p>The 3D tensor is <code>Psi_spec_Tor</code>. The 1D C array is <code>Psi_spec</code>.</p>
<p>At the moment, I am doing:</p>
<pre><code class="lang-auto">Psi_spec_Tor = Psi_spec_Tor.view( Psi_spec_Tor.sizes()[0] * Psi_spec_Tor.sizes()[1] * Psi_spec_Tor.sizes()[2] );
Psi_spec_Tor = Psi_spec_Tor.contiguous();
Psi_spec_Tor = Psi_spec_Tor.cpu();
std::memcpy( Psi_spec, Psi_spec_Tor.data_ptr(), sizeof(std::complex&lt;double&gt;) * Psi_spec_Tor.numel() );
</code></pre>
<p>Then I index <code>Psi_spec</code> as if it was a 3D tensor, using <code>idx = i * (N_thetas * N_phis) + j * N_phis + k</code>, where the usual 3D tensor would be indexed<code> [i][j][k].</code></p>
<p>Is the above correct?</p>
<p>Or shall I do the <code>.contiguous</code> before the <code>.view</code>?</p>
<p>Thank you!</p>

username: eqy
cooked: <p>It looks like you are just flattening the tensor without changing the order of the data (e.g., by reordering the axes)?</p>
<p>In this case the <code>.contiguous()</code> call would be unnecessary, and you can verify this by checking <code>Psi_spec_Tor.is_contiguous()</code> before the call.</p>
<p>If the <code>.contiguous()</code> call is verified to be unnecessary, then the <code>view</code> is also unnecessary, as data lives in memory in this flattened order already.</p>
Which boxes do we use to calc mAP

username: Aakira
cooked: <p>Hi, I’m student and my teacher told me to present how to calculate mAP. After read many topic and some repo, I saw that there are 2 way to chose boxes (if I don’t missunderstood) to calculate mAP.</p>
<p>Let assume that model predicted two tensor as below:</p>
<pre><code class="lang-auto">boxes : shape [nbox, 4]                      # coordinate of bouding box
conf    : shape [nbox, num_class]      # confidence score for num_class each box
</code></pre>
<p>In the first way:</p>
<pre><code class="lang-auto">box_to_calc_mAP = []
conf, labels = torch.max(conf, dim=1)
for cur_class in range(num_class):
   mask = (labels == cur_class)
   cur_boxes = boxes[mask]
   cur_conf    = conf[mask]
   box_to_calc_mAP.append(non_max_suppression(cur_boxes, cur_conf))

mAP = calc_mAP(box_to_calc_mAP)
</code></pre>
<p>But the second way:</p>
<pre><code class="lang-auto">box_to_calc_mAP = []
for cur_class in range(num_class):
   box_to_calc_mAP.append(non_max_suppression(boxes, conf[:, cur_class]))

mAP = calc_mAP(box_to_calc_mAP)
</code></pre>
<p>I feel that the first way is correct, but I saw a repo use the second way, so which is actually true ?</p>
Should we use less epochs with DDP for multiple GPUs?

username: UCDuan
cooked: <p>Hi all,</p>
<p>New to distributed training and I found this discussion about the effective batch size with DDP. <a href="https://discuss.pytorch.org/t/should-we-split-batch-size-according-to-ngpu-per-node-when-distributeddataparallel/72769" class="inline-onebox">Should we split batch_size according to ngpu_per_node when DistributedDataparallel</a></p>
<p>I wonder should we also change the number of epochs with DDP? Say for the single card training, if the number of epochs is 10, it means the model will go through the training dataset 10 times. With DDP and 4 GPUs, the data loader should be copied to 4 GPUs. Does that mean in 1 epoch, 1 GPU goes through the whole dataset and the training dataset is used 4 times? In that case, if we use 4 GPUs, should we set # of epochs to # of epochs / # of GPUs?</p>
<p>Thanks for any explanation!</p>

username: Jinyi_Wan
cooked: <p>I wonder this too. Any updates?</p>
Fine tuning sam model...from meta AI

username: Sushmanth_reddy_Mere
cooked: <p><a class="mention" href="/u/ptrblck">@ptrblck</a>  I was trying to fine tune a sam model and was facing this torch error…can u pls give a look. on this error<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/3/6/36e561ca4067b9e3dcddba5ebd655feab400cd19.png" data-download-href="https://discuss.pytorch.org/uploads/default/36e561ca4067b9e3dcddba5ebd655feab400cd19" title="Screenshot 2023-06-01 at 1.17.39 AM"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/3/6/36e561ca4067b9e3dcddba5ebd655feab400cd19_2_690x103.png" alt="Screenshot 2023-06-01 at 1.17.39 AM" data-base62-sha1="7PDeo1wDhIo77pT8rIbuAPyvVyN" width="690" height="103" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/3/6/36e561ca4067b9e3dcddba5ebd655feab400cd19_2_690x103.png, https://discuss.pytorch.org/uploads/default/optimized/3X/3/6/36e561ca4067b9e3dcddba5ebd655feab400cd19_2_1035x154.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/3/6/36e561ca4067b9e3dcddba5ebd655feab400cd19_2_1380x206.png 2x" data-dominant-color="EED5D4"><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">Screenshot 2023-06-01 at 1.17.39 AM</span><span class="informations">2482×374 100 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>
SGD diverges in the implementation of joint tensor decomposition and Bayesian Personalized Ranking

username: vincentjytsai-nycu
cooked: <p>Hi,</p>
<p>I am implementing a recommendation algorithm that jointly optimizes the losses of tensor decomposition and Bayesian Personalized Ranking (BPR) in <a href="https://dl.acm.org/doi/pdf/10.1145/3357384.3357952" rel="noopener nofollow ugc">this paper</a> with Pytorch.</p>
<p>However, whenever I adopt SGD as the optimizer, the loss tends to diverge (due to unknown reason), and the embeddings easily diverge to “nan”…Even though Adam does not diverge easily, the results do not seem to coincide with the paper…</p>
<p>I tried to lower the learning rate, but the execution became slower.</p>
<p>I’m wondering if there is any bug in my code (<a href="https://drive.google.com/drive/folders/1YEKMboVJ8D6ajBSGD95qUerxdYizoMAf?usp=sharing" rel="noopener nofollow ugc">Link</a>). For instance,</p>
<ul>
<li>I’m wondering if the data loader for personalized ranking in the execution file (in the above link) is constructed in the right way.</li>
<li>I’m wondering if there is any wrong in the training algorithm implementation (see “fit” in the class file in the folder “model” of the above link)</li>
<li>In addition to the learning rate, I’m wondering if such divergence depends on the data size, batch size, or the setting of the optimizer?</li>
</ul>
<p>Any suggestion is appreciated. Thanks!</p>

username: ashishjv11
cooked: <p>Yes I am facing a similar problem . Did you solve it ?</p>
Multiple workers to send data to 1 gpu for faster preprocessing

username: KSonPham
cooked: <p>Hi everyone,</p>
<p>I’m trying to send 3D data to GPU for augmentation since it is much faster. However, I encountered the error below while trying to execute “self.points = torch.from_numpy(self.points).float().cuda()”. This only happens when i set the number of workers &gt; 0.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/0/3/038cc0809944ca6b4e6b10ee36a7f05b4009e32f.png" data-download-href="https://discuss.pytorch.org/uploads/default/038cc0809944ca6b4e6b10ee36a7f05b4009e32f" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/0/3/038cc0809944ca6b4e6b10ee36a7f05b4009e32f.png" alt="image" data-base62-sha1="voZvD8GLkTEapv2jpi1zOYsX1B" width="690" height="53" data-dominant-color="0D2426"><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">1010×79 7.45 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>

username: ptrblck
cooked: <p>This error is expected since you are trying to recreate CUDA contexts in a multiprocessing setting.<br>
You could try to use the <code>spawn</code> method to avoid it.</p>
Replicate behavior from seeded numpy pcg64 Generator with PyTorch

username: jra369
cooked: <p>I have a neuromorphic board which appears to use the same PCG64 Generator used by numpy as part of the dynamics of the neural network. I can replicate the randomness seen on the board with numpy in a forward sense assuming I seed the numpy Generator properly.</p>
<p>I’d like to train a network to run on this board making use of pytorch’s autograd capability, and using the same seeded PCG64 generated sequence. When I use:</p>
<pre><code class="lang-auto">gen1 = torch.Generator()
gen1.manual_seed(seed)
torch.rand(1, generator=gen1)
</code></pre>
<p>I get different results than if I do:</p>
<pre><code class="lang-auto">gen2 = numpy.random.default_rng(seed=seed)
gen2.random(1)
</code></pre>
<p>Is there a way to get the same PCG64 based pseudorandom sequence from both numpy and torch?</p>
<p>Thanks!</p>

username: ptrblck
cooked: <p>No, I don’t believe that’s possible as the PRNG implementations might differ internally.<br>
If needed you might be able to create the random values using <code>numpy</code> and transform them to tensors via <code>torch.from_numpy</code>.</p>
How to quantize only specific layers

username: Suyoung_Park
cooked: <p>How to quantize weights in pointwise convolution layer in MobileNet V2, not all the entire model’s parameters. I searched a lot, but most of the source code quantized the entire model’s parameters.</p>

username: jerryzh168
cooked: <p>you can set qconfig only for the sub module that you want to quantize. e.g.</p>
<pre><code class="lang-auto">class M(torch.nn.Module):
   def __init__(self):
      self.conv1 = ...
      self.conv2 = ...
m  = M()
m.conv1 = qconfig # if you only want to quantize conv1
</code></pre>

username: gakadam
cooked: <p>Just to be clear, this would be exactly like this:</p>
<pre><code class="lang-auto">m.conv1.qconfig = qconfig
</code></pre>
<p>right?</p>

username: jerryzh168
cooked: <p>yes, that is correct.</p>
Fp16 matmul - CUDA kernel output differs from torch

username: Neoxion
cooked: <p>I wrote a simple CUDA matrix multiplication kernel:</p>
<pre><code class="lang-auto">template &lt;typename scalar_t&gt;
__global__ void matmul_cuda_kernel(
    const torch::PackedTensorAccessor&lt;scalar_t,2,torch::RestrictPtrTraits&gt; a,
    const torch::PackedTensorAccessor&lt;scalar_t,2,torch::RestrictPtrTraits&gt; b,
    torch::PackedTensorAccessor&lt;scalar_t,2,torch::RestrictPtrTraits&gt; out,
    const int in_size,
    const int a_size,
    const int b_size
    ) {

  const int col = blockIdx.y * blockDim.y + threadIdx.y;
  const int row = blockIdx.x * blockDim.x + threadIdx.x;


  if (row &lt; a_size &amp;&amp; col &lt; b_size) {
      scalar_t val = 0;

      for (int i = 0; i &lt; in_size; ++i) {
        scalar_t a_f = a[row][i];
        scalar_t b_f = b[i][col];
        val += a_f * b_f;
      }

      out[row][col] = val;
  }
}
</code></pre>
<p>Tensors are dispatched with:</p>
<pre><code class="lang-auto">AT_DISPATCH_FLOATING_TYPES_AND_HALF(a.type(), "matmul_cuda", ([&amp;] {
                matmul_cuda_kernel&lt;scalar_t&gt;&lt;&lt;&lt;blocks, threads_per_block&gt;&gt;&gt;(
                a.packed_accessor&lt;scalar_t,2,torch::RestrictPtrTraits&gt;(),
                b.packed_accessor&lt;scalar_t,2,torch::RestrictPtrTraits&gt;(),
                out.packed_accessor&lt;scalar_t,2,torch::RestrictPtrTraits&gt;(),
                in_size, a_size, b_size);
        } ) );
</code></pre>
<p>When I test the accuracy of the kernel and compare its output with <code>F.linear(a, b, None)</code> on random tensors, I get no deviation for <code>torch.float</code>, around 1e-12 for <code>torch.double,</code> but for <code>torch.float16</code> deviation reaches 1%. Obviously, pytorch MM implementation differs from mine, but why is the difference so high, compared to float and double?</p>

username: ptrblck
cooked: <p>PyTorch uses <code>float32</code> as the internal compute type for <code>float16</code> inputs and outputs while it seems you are also using a <code>float16</code> compute/accumulation type.</p>

username: Neoxion
cooked: <p>I see, thank you.<br>
After passing initialized <code>torch.float16</code> tensors as <code>torch.float</code> to kernel and <code>F.linear</code>, deviation went down significantly.</p>
Pytorch version error

username: shrbrh
cooked: <p>Can anyone please tell me what version of Pytorch is compatible with A100-PCIE-40GB with CUDA capability sm_80. I have tried installing different versions but keep getting the same error: “RuntimeError: CUDA error: no kernel image is available for execution on the device.CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.<br>
For debugging consider passing CUDA_LAUNCH_BLOCKING=1”<br>
Even after passing CUDA_LAUNCH_BLOCKING=1, I get the same error :“RuntimeError: CUDA error: no kernel image is available for execution on the device.” Please help.</p>

username: ptrblck
cooked: <aside class="quote no-group" data-username="shrbrh" data-post="1" data-topic="181077">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/s/b5e925/48.png" class="avatar"> shrbrh:</div>
<blockquote>
<p>Can anyone please tell me what version of Pytorch is compatible with A100-PCIE-40GB with CUDA capability sm_80.</p>
</blockquote>
</aside>
<p>Every PyTorch build using CUDA&gt;=11.0 is compatible with sm_80 and thus your A100.<br>
The latest stable <code>torch==2.0.1</code> release uses CUDA 11.7 and 11.8, and the current nightly builds use CUDA 11.8 and 12.1. All of them will work on your A100.</p>

username: shrbrh
cooked: <p>So is there any other reason due to which I might be getting this error? My script runs fine in V100.</p>

username: ptrblck
cooked: <p>It depends which PyTorch version you have installed and you could check it via <code>python -m torch.utils.collect_env</code>. E.g. if it’s an older PyTorch release with CUDA 10.2 this error would be expected and you would need to update.</p>

username: shrbrh
cooked: <p>These are the details:</p>
<pre><code class="lang-auto">PyTorch version: 1.10.1+cu102
Is debug build: False
CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A
</code></pre>
<p>Do I need to update my Pytorch version?</p>

username: ptrblck
cooked: <p>Yes, you would need to update the PyTorch binary and install one with CUDA 11, as the currently installed older one uses 10.2 as I’ve already guessed.</p>
Backend for Distributed Training

username: James_Guo
cooked: <p>Hello guys, we encounter a wired problem regarding to the backend choice for Distributed Training recently. Any help or suggestion is appreciated!</p>
<p>At the beginning of our code, we set backend to ‘nccl’ for better performance, as</p>
<pre><code class="lang-auto">torch.distributed.init_process_group(backend='nccl')
synchronize()
</code></pre>
<p>During training, we accidentally find that the actual backend being used is ‘gloo’, and the profiling validate this information.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/a/6/a62608d837c30996d27234b7b531754410aa4b62.png" data-download-href="https://discuss.pytorch.org/uploads/default/a62608d837c30996d27234b7b531754410aa4b62" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/a/6/a62608d837c30996d27234b7b531754410aa4b62_2_637x500.png" alt="image" data-base62-sha1="nHOKq9Oa8AeuAnvpnh58n8y1226" width="637" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/a/6/a62608d837c30996d27234b7b531754410aa4b62_2_637x500.png, https://discuss.pytorch.org/uploads/default/optimized/3X/a/6/a62608d837c30996d27234b7b531754410aa4b62_2_955x750.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/a/6/a62608d837c30996d27234b7b531754410aa4b62.png 2x" data-dominant-color="1B1919"><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">1139×893 179 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>We never set ‘gloo’ in our code, why does this happen? Thank you very much for your help!</p>
Best way for porting a 100% C++ torch nn::module to jit TorchScript/TensorRT?

username: Sebastien_Maraux
cooked: <p>Hello,</p>
<p>I am working with libtorch c++, and I want to port a model to tensorRT.</p>
<p>My model is defined in C++.<br>
It has some conditional expressions such as for loops and ifs in some methods, to optionally apply an (externally computed) PCA matrix to the model, and 2 methods to save / restore best weights</p>
<p>I have read that I need to go through TorchScript format, to be able to either import it in torch-tensorRT (c++ code seems available) or convert it to an ONNX model that can be imported by tensorRT</p>
<ul>
<li>
<p>For the second option, I looked at options to create a ONNX model on the fly (my model is mainly a n times linear layers) but onnxruntime does not have sufficient API to create a model from scratch and ONNX main lib is not ported to c++.</p>
</li>
<li>
<p>Then It goes back to first option, making a TorchScript from my existing model.<br>
First, would it be possible to convert it straight away ? Or could it be done after tweaking the conditional expressions and remove the save/restore weights functions (I am aware that if I want to trace the model, I need to do this anyway) ?</p>
</li>
</ul>
<ol>
<li>I tried to to so by doing :</li>
</ol>
<p>torch::serialize::OutputArchive differentialModelOut;<br>
model-&gt;to(torch::kCPU);<br>
model-&gt;save(differentialModelOut);<br>
modelsArchiveOut.write(DifferentialNetModel, differentialModelOut);</p>
<p>But that did not seem to produce a correct file to load in python or in libtorch-tensorRT</p>
<ol start="2">
<li>Can I manage to store the PCA tensor &amp; integrate a matmul at the end of the forward, and still have a valid TorchScript convertible to ONNX / TensorRT ?</li>
</ol>
<p>I have also read another option : creating a torch::jit::module that is imported and trained in C++. As this is a massive rewrite, I would preferably stick to converting my existing, pre trained, model to TorchScript.</p>
<p>Thank you for reading this, any comment will be appreciated</p>

username: Sebastien_Maraux
cooked: <p>As an update, I ended rewriting the network directly in tensorRT, this is not too hard for a model with standard layers (I use fully connected, relu and batch norm - done via a scale layer). It relies only on C++, and it is much simpler.</p>
<p>To achieve this, simply make a tensorRT builder, create a network and add layers by copying weights of existing model.</p>
One GPU always stucks/hangs when using NCCL, while gloo not

username: Will_Chi
cooked: <p>When I use <code>torchrun --nproc_per_node=4 main.py</code> to launch DDP (with NCCL), there is always one (sometimes two) GPU stucks (its utility is 0% but memory is normal, i.e., GPU 2 in the image) at the<br>
begining. However, when only 1/2/3 GPUs are used, this issue doesn’t exist.</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/8/e/8e727b771391f03565f5f316cc40ff26cdb1d506.png" data-download-href="https://discuss.pytorch.org/uploads/default/8e727b771391f03565f5f316cc40ff26cdb1d506" title="smi"><img src="https://discuss.pytorch.org/uploads/default/original/3X/8/e/8e727b771391f03565f5f316cc40ff26cdb1d506.png" alt="smi" data-base62-sha1="kk94PImskuzJ5dBPXB1lKLWGg9E" width="690" height="440" data-dominant-color="252525"><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">smi</span><span class="informations">720×460 12.5 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>My experimental environment is listed below.</p>
<ul>
<li>GPU: Quadro RTX 6000*4</li>
<li>NVIDIA Driver: 470.86</li>
<li>CUDA Version: 11.4</li>
<li>Python: 3.6.9</li>
<li>Pytorch: 1.10.0</li>
<li>Cudatoolkit: 11.3</li>
<li>NCCL: 2.10.3</li>
</ul>
<p>I have tried <code>export NCCL_P2P_DISABLE=1</code> pointed out by most similar issues, but this doesn’t work for me.</p>
<p>Look forward to your help. I really appreciate it!</p>
Selective overwriting of network output

username: Matthias_Moller
cooked: <p>I would like to override some entries of the network’s output tensor by values from its input tensor. These values are contiguously stored, i.e. in pseudo-code this would read</p>
<pre><code class="lang-auto">output[k:k+10] = input[l:l+10]
</code></pre>
<p>I don’t want to remove these entries completely because they have influence on the other non-clamped network outputs. Is there an example of <code>selective skip connections</code>?</p>
How to access and control the parts of a partial derivative?

username: chatterboy
cooked: <p>Hi, I want to access and control the parts of a partial derivative. For the below figure, x is input data, l_{1, 2, 3} are layers with learnable parameters, alpha is a learnable parameter, and the last is a loss function.</p>
<p><img src="https://discuss.pytorch.org/uploads/default/original/3X/d/0/d03a3b99aca982ebf9759fa41b68eeffea24efa4.png" alt="image" data-base62-sha1="tI44MiBXm2k4hvPtzDfLvOmA7dy" width="316" height="385"></p>
<p>The partial derivative of the loss function with respect to the alpha can be represented as follows:</p>
<p><img src="https://discuss.pytorch.org/uploads/default/original/3X/f/7/f7518f4406705e9b7b319fa98707e10c1eaa72ac.png" alt="image" data-base62-sha1="zhSFUbkeHW2Xgke1HfH4RFx41aI" width="529" height="112"></p>
<p>Is it possible to access each term in right hand side to modify its value? Right now, I do not have any idea to do that using <code>.backward()</code>.</p>
<p>Thanks.</p>

username: chatterboy
cooked: <p>I solved it by adding additional learnable parameters between alpha and each layer.</p>
Can't do parallel computing

username: Christian
cooked: <p>I want to load Resnet model and change last layer to fit my class numbers. But after I use data parallel function right after the modified model. it give this error.</p>
<p>RuntimeError: module must have its parameters and buffers on device cuda:0 (device_ids[0]) but found one of them on device: CPU</p>
<p>this is the code:</p>
<pre><code class="lang-auto">if args.resume:
         if os.path.isfile(args.resume):
             print("=&gt; loading checkpoint '{}'".format(args.resume))
             checkpoint = torch.load(args.resume)
             args.start_epoch = checkpoint['epoch']
             best_prec1 = checkpoint['best_prec1']
             model.load_state_dict(checkpoint['state_dict'])
             model.module.fc=nn.Linear(2048,6).cuda()
             if 'optimizer' in checkpoint:
                 optimizer.load_state_dict(checkpoint['optimizer'])
             print("=&gt; loaded checkpoint '{}' (epoch {})"
                   .format(args.resume, checkpoint['epoch']))
         else:
             print("=&gt; no checkpoint found at '{}'".format(args.resume))
     
cudnn.benchmark = True
#model = model.cuda()
model = torch.nn.DataParallel(model, device_ids=list(range(args.ngpu)))
</code></pre>
<p>some times it also has another problem:<br>
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:1 and cuda:0! (when checking argument for argument weight in method wrapper_CUDA__cudnn_convolution)<br>
Can anyone help me? thank you so much</p>

username: ptrblck
cooked: <p>I don’t see any obvious issues in the posted code snippet so could you create a minimal and executable code able to reproduce the issue?</p>

username: Christian
cooked: <p>I add torch.cuda.set_device(‘cuda:0’)<br>
this works for me.<br>
Thank you</p>
Importing my functions on gpus

username: Vaibhav_Chahar
cooked: <p>Hi, for compilation of my code I am using gpu (NVIDIA GeForce RTX 2080 Ti) but on running the code is running faster on my CPU(16Gb Ram with  processors). My class of Neural network and there are several functions that I am using in my code are present on different modules on my system. Is it due to that or  I have to move the functions to gpus?</p>

username: ptrblck
cooked: <p>I’m not sure I understand the question completely, but PyTorch will not move data to the GPU automatically.<br>
You would have to move the model as well as the input data to the device via:</p>
<pre><code class="lang-python">device = "cuda"
model.to(device)
data = data.to(device)
</code></pre>
<p>before executing the forward pass.</p>

username: Vaibhav_Chahar
cooked: <p>Start=time.time()<br>
dev=torch.device(“cuda:1” if torch.cuda.is_available() else “cpu”)<br>
J1=-0.43<br>
m=5<br>
n=4<br>
I_Val=pf.linear_index(m,n) <span class="hashtag">#function</span> present in a module<br>
I_Val_2=pf.linear_index_2(m)<span class="hashtag">#function</span> present in a module<br>
P_SET=[]<br>
M_SET=[]<br>
Q_SET=[]<br>
loss_f=[]<br>
for j in range(20):<br>
Start1=time.time()<br>
I_Par=[]<br>
I_Par=rand_mat(m,n,I_Val).to(dev)# converting ((m,m,m,m,n) data structure to list as an input for the network)<br>
End1=time.time()<br>
print(I_Par.is_cuda,‘Time in uploding vector’,End1-Start1)<br>
Inter=[]<br>
P_list=[]<br>
for i in range(len(I_Par[0])):<br>
Start2=time.time()<br>
Net=pf.Neural_Made(n,m).to(dev)<br>
Net=(Net(I_Par).tolist())<br>
P_list.append(Net[i])<br>
End2=time.time()<br>
print(‘Time in network’,End2-Start2)</p>
<p>and this is my neural network:</p>
<p>class Neural_Made(nn.Module):<br>
def <strong>init</strong>(self,n,m):<br>
super(Neural_Made,self).<strong>init</strong>()<br>
self.n=n<br>
self.m=m<br>
self.in_size=n<em>m</em>m<em>m</em>m<br>
self.register_buffer(‘Mask1’,torch.ones([self.in_size]*2))<br>
self.register_buffer(‘Mask2’,torch.eye(self.in_size))<br>
self.Mask1=torch.tril(self.Mask1)<br>
self.Mask2=self.Mask1-self.Mask2</p>
<pre><code>    self.fc1=nn.Linear(self.in_size,self.in_size)
    nn.init.xavier_uniform_(self.fc1.weight)
    self.fc1.weight.data=self.fc1.weight.data*self.Mask2

    self.fc2=nn.Linear(self.in_size,self.in_size)
    nn.init.xavier_uniform_(self.fc2.weight)
    self.fc2.weight.data=self.fc2.weight.data*self.Mask1

    self.out=nn.Linear(self.in_size,self.in_size)
    nn.init.xavier_uniform_(self.out.weight)
    self.out.weight.data=self.out.weight.data*self.Mask1

    self.prelu=nn.PReLU()
    self.sig=nn.Sigmoid()
def forward(self,x):
    x=self.fc1(x)
    x=self.prelu(x)
    x=self.fc2(x)
    x=self.prelu(x)
    x=self.out(x)
    x=self.sig(x)
    return x.view(-1)
</code></pre>
Transformer model to ONNX, batch inference

username: useralina
cooked: <p>I implemented the CLTR model (crowd and localisation transformer), which uses Conditional DETR. I was able to create an onnx model with input size [12, 3, 256, 256] - similar to my image. However, I would like to process this in batches, and I was no able to do so, as an input like this (batch_size, 12, 3, 256, 256) is not supported.<br>
Any suggestions how could I solve this problem?</p>
Model not training and loss is almost constant

username: LLlearner
cooked: <p>I am trying to train a simple  model. However, it seems that the model does not learn anything, and I am unsure why I have this problem.<br>
Here is my code:</p>
<pre><code class="lang-auto">class Regressor(nn.Module):
    def __init__(self, inp_dim=1, out_dim=1, hidden_units=20):
        super(Regressor, self).__init__()
        self.criterion = torch.nn.MSELoss()
        self.model = torch.nn.Sequential(
            torch.nn.Linear(inp_dim, hidden_units),
            torch.nn.ReLU(),
            torch.nn.Linear(hidden_units, hidden_units),
            torch.nn.ReLU(),
            torch.nn.Linear(hidden_units, out_dim),
        )
        self.optimizer = torch.optim.Adam(self.model.parameters(), lr=0.1)

    def update(self, x, y_target):
        y_pred = self.model(torch.Tensor(x))
        loss = self.criterion(y_pred, torch.Tensor(y_target))
        self.optimizer.zero_grad()
        loss.backward()
        self.optimizer.step()

    def predict(self, x):
        with torch.no_grad():
            return self.model(torch.Tensor(x))

</code></pre>
<p>And the data and training loop is as follows:</p>
<pre><code class="lang-auto">x = torch.linspace(1, 20, 64)
y = 2 * x + x ** 2 + np.random.rand()
model = Regressor()

epochs = 1000
for epoch in range(epochs):
    model.update(x.unsqueeze(-1), y)

</code></pre>
<p>I would be grateful for any help.</p>

username: ajinkyakolhe112
cooked: <p>I don’t think you can do “self.optimizer = torch.optim.Adam(self.model.parameters(), lr=0.1)”, inside the class.<br>
By that time, init method hasn’t ended. Regression Model isn’t yet intialized completely. So you can’t pass it’s parameters to optimizer.</p>

username: LLlearner
cooked: <p>Since the optimizer was initialized after the model, it would still work. However, I forgot to squeeze the output of the prediction:</p>
<pre><code class="lang-auto">y_pred = self.model(torch.Tensor(x))
</code></pre>
<p>Instead, it should be</p>
<pre><code class="lang-auto">y_pred = self.model(torch.Tensor(x)).squeeze()
</code></pre>

username: ajinkyakolhe112
cooked: <p>yeah.<br>
UserWarning did warn about different shapes. <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"> Didn’t read it.</p>
PyTorch eco-design rules

username: Aghiles
cooked: <p>Hello!</p>
<p>After participating to a hackathon about developing an eco-design plugin for SonarQube, I wanted to apply the same concept for deep learning (PyTorch first, since it’s the main framework I use) by listing eco-design rules that can be detected using Python AST (aka. static parsing). The idea is to provide a list of rules that can reduce Co2 emission.</p>
<p>I already implemented 6 basic rules <a href="https://github.com/AghilesAzzoug/GreenPyData" rel="noopener nofollow ugc">here</a>, for example avoid using bias in convolutional layers before batch norms since it wastes memory and computational power.</p>
<p>TLDR; If people have ideas about eco-design rules in Pytorch, feel free to reach me, respond to this thread, or send a carrier pigeon <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
Problem with Torch 1.11

username: JDE65
cooked: <p>I upgraded my cudatoolkit to 11.3.1 and installed Pytorch using<br>
conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch in the environment.<br>
Transaction was prepared, verified and executed properly. But when I want to run a code with torch, the program stops at &gt; import torch and return<br>
OSError: [WinError 127] The specified procedure could not be found. Error loading “…envs\Torch\lib\site-packages\torch\lib\shm.dll”" or one of its dependencies.</p>
<p>cudatoolkit = 11.3.1<br>
pytorch = 1.11.0<br>
Python = 4.8.5<br>
Spyder = 4.1.5</p>

username: JDE65
cooked: <p>FYI. I desinstalled anaconda and reinstalled it completely, and it works now. Heavy and painful process, but I get it!</p>

username: miturian
cooked: <p>I’m in the same frustrating situation…</p>
<p>(reinstalling anaconda worked for me too)</p>

username: sufianj
cooked: <p>I deinstalled the troubled Conda environment and reinstalled pytorch, and it works now.<br>
Luckily, my other Conda environments are not impacted…</p>

username: Inaam1995
cooked: <p>This worked for me. Thanks</p>

username: kkyu09
cooked: <p>I solved it by installing torch, torchvision, torchaudio to the compatible version<br>
conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit==11.3 -c pytorch<br>
click below</p><aside class="onebox allowlistedgeneric" data-onebox-src="https://pytorch.org/get-started/previous-versions/">
  <header class="source">
      <img src="https://pytorch.org/favicon.ico?" class="site-icon" width="32" height="32">

      <a href="https://pytorch.org/get-started/previous-versions/" target="_blank" rel="noopener nofollow ugc">pytorch.org</a>
  </header>

  <article class="onebox-body">
    <img src="https://pytorch.org/assets/images/pytorch-logo.png" class="thumbnail onebox-avatar" width="500" height="500">

<h3><a href="https://pytorch.org/get-started/previous-versions/" target="_blank" rel="noopener nofollow ugc">PyTorch</a></h3>

  <p>An open source machine learning framework that accelerates the path from research prototyping to production deployment.</p>


  </article>

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

  <div style="clear: both"></div>
</aside>


username: kkyu09
cooked: <p>like<br>
pip install torch==1.12.0+cu113 torchvision==0.13.0+cu113 torchaudio==0.12.0 --extra-index-url <a href="https://download.pytorch.org/whl/cu113" rel="noopener nofollow ugc">https://download.pytorch.org/whl/cu113</a><br>
cudnn11.3 Ver</p>

username: Sebi
cooked: <p>Running the following command fixed the issue:</p>
<pre><code class="lang-auto">conda update --all
</code></pre>

username: KLMM_AX
cooked: <p>Perfectly worked. Thanks</p>