akankshakshurai/cuda-error-resolution-analysis huggingface dataset:
Efficient dataloader for pathology whole slide images

username: lely475
cooked: <p>I’m working with pathology WSIs (very large, e.g., 100,000×100,000 px), split into tiles (224×224 RGB). Each WSI can have 500–15,000 tiles. Labels are only at the WSI level, so I need a DataLoader that:</p>
<ul>
<li>
<p>Samples a subset of tiles per WSI (e.g., 1,000)</p>
</li>
<li>
<p>Applies augmentations to each tile individually. I am using albumentations due to specific transforms which don’t exist in torchvision.</p>
</li>
<li>
<p>Returns a single tensor of all tiles, forward/backprop happens per WSI</p>
</li>
</ul>
<p>The challenge is <strong>CPU utilization</strong>. A standard DataLoader parallelizes at the WSI level (<code>num_workers &gt; 0</code>), but each WSI contains many tiles. Processing all tiles serially in <code>__getitem__</code> underutilizes CPUs, while trying to parallelize tile augmentations inside <code>__getitem__</code> risks nested parallelism, oversubscription, and deadlocks.</p>
<p>This is my Dataset class:</p>
<pre data-code-wrap="python"><code class="lang-python">class WSIDataset(Dataset):
    def __init__(self, wsi_list, transform=None, max_tiles=None):
        self.wsi_list = wsi_list           # list of WSIs
        self.transform = transform         # augmentation function
        self.max_tiles = max_tiles

    def __len__(self):
        return len(self.wsi_list)

    def __getitem__(self, idx):
        tiles = self._load_tiles_for_wsi(self.wsi_list[idx])
        
        if self.max_tiles and len(tiles) &gt; self.max_tiles:
            tiles = tiles[:self.max_tiles]
        
        # Apply augmentations
        augmented = torch.stack([self.transform(tile) for tile in tiles])
        return augmented
</code></pre>
<p>Do you have any suggestions on best practices for how to parallelize workers inside a PyTorch Dataloader?</p>

username: valerian.rey
cooked: <p>I don’t think PyTorch provides anything to parallelize intra-batch processing out of the box, but I may be missing something.</p>
<p>Did you have deadlocks or reduced performance with nested parallelism (parallelizing tile loading, tile augmentations, or both, inside <code>__getitem__</code> using e.g. <a href="https://docs.python.org/3/library/multiprocessing.html" rel="noopener nofollow ugc">multiprocessing</a> yourself)?</p>
<p>If that seems reasonable, you could also pre-apply all possible transforms on all possible tiles, save them to disk, and then, when training, directly load tiles that are already transformed.</p>
<p>Also, I think you could have a small optimization of your <code>__getitem__</code> by swapping the condition on <code>max_tiles</code> and the loading of the tiles.</p>
<pre data-code-wrap="python"><code class="lang-python">def __getitem__(self, idx):
    if self.max_tiles and len(idx) &gt; self.max_tiles:
        idx = idx[:self.max_tiles]
    # Maybe add special case when idx is an int
 
    tiles = self._load_tiles_for_wsi(self.wsi_list[idx])
    ...
</code></pre>
<p>This should reduce disk loading time when trying to fetch more than the max number of tiles.</p>
<p>I hope this helps!</p>
Can we decouple model architecture from parameters with torch.export?

username: Thity
cooked: <p>In order to serialize and share a model, one can use <a href="https://docs.pytorch.org/docs/stable/export.html" rel="noopener nofollow ugc">torch.export</a> and save the <code>ExportedProgram</code> in binary format with <code>torch.export.save(exported_program, 'exported_program.pt2')</code>. However, the serialized object contains all model parameters, that can be heavy for large Vizion or generative models. To reduce the size of serialized objects, it would be helpful to decouple the model architecture from its parameters in order to export the architecture only and save space, especially when the model has not been trained before export. Is there any way to do so with torch.export? Is it planned for the future?</p>
TorchAO Migration

username: jerryzh168
cooked: <p>Hi everyone, we are moving to torchao: <a href="https://github.com/pytorch/ao" class="inline-onebox" rel="noopener nofollow ugc">GitHub - pytorch/ao: PyTorch native quantization and sparsity for training and inference</a> , docs: <a href="https://docs.pytorch.org/ao/main/" class="inline-onebox" rel="noopener nofollow ugc">Welcome to the torchao Documentation — torchao main documentation</a> and please checkout a note on migration: <a href="https://docs.pytorch.org/docs/main/quantization.html" class="inline-onebox" rel="noopener nofollow ugc">Quantization — PyTorch main documentation</a></p>
<p>Here is a previous migration post for more context: <a href="https://dev-discuss.pytorch.org/t/clarification-of-pytorch-quantization-flow-support-in-pytorch-and-torchao/2809" class="inline-onebox" rel="noopener nofollow ugc">Clarification of PyTorch Quantization Flow Support (in pytorch and torchao) - PyTorch Developer Mailing List</a> and <a href="https://dev-discuss.pytorch.org/t/torch-ao-quantization-migration-plan/2810" class="inline-onebox" rel="noopener nofollow ugc">Torch.ao.quantization Migration Plan - PyTorch Developer Mailing List</a></p>
<p>In short I think we can still help with (1) <a href="https://docs.pytorch.org/ao/main/quick_start.html#pytorch-2-export-quantization" rel="noopener nofollow ugc">pt2e quantization</a> questions (pt2e flow is migrated to torchao) (2) <a href="https://docs.pytorch.org/ao/main/generated/torchao.quantization.quantize_.html#torchao.quantization.quantize_" rel="noopener nofollow ugc">quantize_</a> (new top level API in torchao) questions.</p>
How did stager with pinned and shared memroy handle BatchNorm?

username: TomQunChao
cooked: <p>I notice the default stager with pinned and shared memory in main branch <a href="https://github.com/pytorch/pytorch/blob/main/torch/distributed/checkpoint/staging.py#L207" class="inline-onebox" rel="noopener nofollow ugc">pytorch/torch/distributed/checkpoint/staging.py at main · pytorch/pytorch · GitHub</a> can staging model’s state_dict asynchronously, how does the stager handle layers who’s state will be modified during forward, like BatchNorm (its buffer is changed during fwd process).</p>
<p>torchtitan zero overhead checkpoint reference: <a href="https://discuss.pytorch.org/t/distributed-w-torchtitan-optimizing-checkpointing-efficiency-with-pytorch-dcp/211250" class="inline-onebox">[Distributed w/ TorchTitan] Optimizing Checkpointing Efficiency with PyTorch DCP</a></p>
OPACUS unexpected behaviour

username: gmuser
cooked: <p>Dear all,</p>
<p>I am applying OPACUS according to related tutorial:</p>
<p>self.privacy_engine = PrivacyEngine()<br>
<a href="http://self.net" rel="noopener nofollow ugc">self.net</a>, self.optimizer, self.train_loader = self.privacy_engine.make_private( <a href="http://module=self.net" rel="noopener nofollow ugc">module=self.net</a>, optimizer=self.optimizer, data_loader=self.trainloader, max_grad_norm=1., noise_multiplier=60,)</p>
<p>as you can see the noise mult is quite large and the clipping norm “reasonable” for an entry test,</p>
<p>I checked epsilon and I got quite a low value as expected, The optimizer is SGD.</p>
<p>What I find unexpected is that no drop occurs for some datasets I am applying OPACUS to.</p>
<p>Is that possible and if it is the case, how can I manage it or there is something wrong I cannot see.</p>
<p>Thanks a lot for any feedback you will provide!</p>
Torch 2.8 slower than torch 1.13 for simple operations

username: thompson2
cooked: <p>Dear torch community,</p>
<p>I noticed on a couple of occasions that torch 2 seems to be slower compared to torch1. I wrote a simple example to illustrate this:</p>
<pre><code class="lang-auto">import torch
import timeit
import numpy as np

device = 'cuda:0'

param = torch.ones(2, device=device, dtype=torch.float32, requires_grad=True)
weights = torch.tensor([1.0, 0.5], device=device, dtype=torch.float32)

def fn1():
    loss = torch.sum((param * weights) ** 2)
    loss.backward()
    torch.cuda.synchronize()

torch.cuda.synchronize()
print('fn1()', np.mean(timeit.repeat(fn1, repeat=50, number=100)) / 100 * 1000, 'ms')
</code></pre>
<p>I ran this in 2 different environments:<br>
env1:  torch version 1.13.0+cu117<br>
env2: torch version 2.8.0+cu128</p>
<p>I get the following results:<br>
env1: fn1() 0.09015519358217715 ms<br>
env2: fn1() 0.13306585904210808 ms</p>
<p>i.e., a slowdown of ~47% going from torch 1 to torch 2. Has anyone noticed such slowdowns as well &amp; found a solution to retain torch 1 performance?</p>
<p>————————<br>
System information:</p>
<ul>
<li>GPU: NVIDIA GeForce RTX 3080 (Driver Version: 535.183.01)</li>
<li>CPU: 11th Gen Intel(R) Core™ i7-11700KF @ 3.60GHz</li>
</ul>

username: nico1
cooked: <p>A while back I asked a similar question here: <a href="https://discuss.pytorch.org/t/torch-execution-time-differences-1-13-0-vs-2-4-0/212711" class="inline-onebox">Torch Execution Time Differences: 1.13.0 vs. 2.4.0</a></p>
<p>I noticed a significant slowdown when switching from Torch 1 to Torch 2. In another post ( <a href="https://discuss.pytorch.org/t/torch-gets-slower-when-upgrading-the-version/186525/7" class="inline-onebox">Torch gets slower when upgrading the version - #7 by joshua_marqo</a> ), a similar issue was also discussed.</p>
<p>In both discussions, runtime measurements seem to be problematic or inaccurate according to <a class="mention" href="/u/ptrblck">@ptrblck</a>. Sadly, he didn’t provide any details on how to properly measure execution time - at least I couldn’t figure out how to measure it based on his descriptions.</p>
<p>Would be really interested in understanding these changes.</p>
Do I need to rerun torch.compile between training and inference?

username: Saad_Amin
cooked: <p>Suppose I have the following code:</p>
<pre><code class="lang-auto">model = Model()
model.compile()

model.train()
train_model(model, ...)

model.eval()
test_model(model, ...)

</code></pre>
<p>When I switch over to evaluation model, does <code>torch.compile</code> automatically recompile the model? If it doesn’t, does this mean layers like batch norm and dropout are still enabled in <code>test_model</code>?</p>

username: ptrblck
cooked: <p>A quick check shows the dropout layer is properly disabled after calling <code>eval()</code> on a compiled model:</p>
<pre><code class="lang-auto">import torch 
import torch.nn as nn

device = "cuda"
model = nn.Sequential(
    nn.Linear(10, 10),
    nn.Dropout(p=0.9)
).to(device)

x = torch.randn(1, 10, device=device)

model = torch.compile(model)

out = model(x)
print(out.sum())
# tensor(0., device='cuda:0', grad_fn=&lt;SumBackward0&gt;)

model.eval()
out = model(x)
print(out.sum())
# tensor(1.4201, device='cuda:0', grad_fn=&lt;SumBackward0&gt;)
</code></pre>
Compatibility issue between PyTorch and NVIDIA GeForce RTX 5080

username: Nasib
cooked: <p>Hello,</p>
<p>I am trying to run the Automatic1111 Web UI on a system with an NVIDIA GeForce RTX 5080 GPU. When launching, I get the following warning from PyTorch:</p>
<p>NVIDIA GeForce RTX 5080 with CUDA capability sm_120 is not compatible with the current PyTorch installation.<br>
The current PyTorch install supports CUDA capabilities sm_50 sm_60 sm_61 sm_70 sm_75 sm_80 sm_86 sm_90.<br>
Because of this, PyTorch is unable to properly use the GPU, leading to significant performance degradation or fallback to CPU.</p>
<p>I have tried running with the latest Python version and all dependencies installed, but the issue persists.</p>
<p>Could you please advise how to configure PyTorch or Automatic1111 to properly support the RTX 5080?</p>
<p>Thank you!</p>

username: ptrblck
cooked: <p>You are using an older PyTorch binary built with CUDA&lt;=12.6 while your Blackwell GPU needs CUDA&gt;=12.8. All of our current stable and nightly binaries build with CUDA&gt;=12.8 support Blackwell GPUs and you would have to install it after uninstalling your current PyTorch binary.</p>
CPU performance issue

username: maxx-ai
cooked: <p>I have small test script to generate image:</p>
<blockquote>
<pre><code class="lang-auto">import torch
from diffusers import FluxPipeline

pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16)
#pipe.enable_model_cpu_offload() #save some VRAM by offloading the model to CPU. Remove this if you have enough GPU power

prompt = "A cat holding a sign that says hello world"
image = pipe(
    prompt,
    height=1024,
    width=1024,
    guidance_scale=3.5,
    num_inference_steps=50,
    max_sequence_length=512,
    generator=torch.Generator("cpu").manual_seed(0)
).images[0]
image.save("flux-dev.png")
</code></pre>
</blockquote>
<p>On my PC I have zen3  Ryzen 9 5900X I have speed 300 s/it. It is very bad performance.</p>
<p>My friend has new cpu Ryzen 9 9950X with radeon card He has 9.13s/it and generate image for few minutes. I need hours on my pc.</p>
<p>We both have Windows 11, I have Quadro P1000 which not supported he has radeon graphics which also not supported.</p>
<p>How I can understand what pytourch use on his PC to achieve this performance? Can I enable debug logs to see what happens? May be new cpu instructions, may it use unsupported radio graphics?</p>
Should I perform quantization after activation functions like sigmoid and SiLU?

username: IReallyWantToGoHome
cooked: <p>I’m asking because I encountered an issue. After applying a sigmoid function to a feature map, I tried to perform 16-bit asymmetric quantization based on the output’s min/max values. However, the calculated zero-point was -55083, which is a value that exceeds the 16-bit integer range. This situation made me question whether quantizing after sigmoid and SiLU is the correct approach.</p>
<p>I recall a paper from Qualcomm which explained that for activations like ReLU, you can simply apply the ReLU function directly to the already requantized output of the previous layer (e.g., a convolution).</p>
<p>So, my main question is: Following a convolution and its subsequent requantization, is there a method to compute non-linear activation functions like sigmoid or SiLU directly on the quantized tensor, thereby avoiding the typical process of dequantization → activation → requantization?</p>
Error installing PyTorch nightly -- please help

username: bfm75
cooked: <p>Hi</p>
<p>I’m getting an error running <code>conda install pytorch torchvision torchaudio -c pytorch-nightly</code><br>
I’m using the arm64 version of conda, and have tried installing/uninstalling conda multiple times now.<br>
The error I get is:</p>
<p>UnsatisfiableError: The following specifications were found to be incompatible with each other:</p>
<p>Output in format: Requested package → Available versions</p>
<p>Package setuptools conflicts for:</p>
<p>torchvision → setuptools</p>
<p>python=3.9 → pip → setuptools</p>
<p>Package pytorch conflicts for:</p>
<p>torchvision → pytorch[version=‘1.10.2|1.14.0.dev20221022’]</p>
<p>pytorch</p>
<p>torchaudio → pytorch==1.14.0.dev20221022</p>
<p>Package future conflicts for:</p>
<p>pytorch → future</p>
<p>torchvision → pytorch==1.10.2 → future</p>

username: Neil_Watts
cooked: <p>I  encountered the same problem.waiting answer。。。。</p>

username: bfm75
cooked: <p>The odd thing is that I’d installed PyTorch on my M1 MacBook Air without any issue, but got the error on my M1 iMac.</p>

username: Xelamoon
cooked: <p>Just got the same error, adding the channel conda-forge at the end fixes it.</p>
<p><code> conda install pytorch torchvision torchaudio -c pytorch-nightly -c conda-forge</code></p>

username: bfm75
cooked: <p>I still get the same error …</p>

username: Vadim_Podlevsky
cooked: <blockquote>
<p>conda install pytorch torchvision torchaudio -c pytorch-nightly -c conda-forge</p>
</blockquote>
<p>This fixed all the issues for me in macbook m1 max. Thanx!</p>
Using DataParallel for GNN training

username: Ramzi_REZKI
cooked: <p>i’m always getting this error when i  try  train GNN with Data Parallel pytorch.</p>
<p>File “/users/r/hola/.local/lib/python3.12/site-packages/torch_geometric/nn/conv/message_passing.py”, line 238, in _check_input<br>
raise ValueError(f"Expected ‘edge_index’ to have size ‘2’ in "<br>
ValueError: Expected ‘edge_index’ to have size ‘2’ in the first dimension (got ‘1’)</p>
<p>when he devides the dataset into multiple batchs for the parallel training</p>
<p>Any suggestions ,please?!</p>

username: Arunprakash-A
cooked: <p>Were you able to run the code successfully on a single GPU without DataParallel?<br>
I don’t have much experience with GNNs, but according to the documentation <a href="https://pytorch-geometric.readthedocs.io/en/2.5.0/generated/torch_geometric.nn.conv.MessagePassing.html#:~:text=If%2520edge_index%2520is%2520a%2520torch.Tensor%252C%2520its%2520dtype%2520should%2520be%2520torch.long%2520and%2520its%2520shape%2520needs%2520to%2520be%2520defined%2520as%2520%255B2%252C%2520num_messages%255D%2520where%2520messages%2520from%2520nodes%2520in%2520edge_index%255B0%255D%2520are%2520sent%2520to%2520nodes%2520in%2520edge_index%255B1%255D%2520(in%2520case%2520flow%253D%2522source_to_target%2522)" rel="noopener nofollow ugc">[link]</a> the <code>edge_index</code> should have the following format, which your code doesn’t seem to follow:</p>
<p>" If <code>edge_index</code> is a <a href="https://pytorch.org/docs/master/tensors.html#torch.Tensor" rel="noopener nofollow ugc"><code>torch.Tensor</code></a>, its <code>dtype</code> should be <code>torch.long</code> and its <strong>shape needs to be defined</strong> as <code>[2, num_messages]</code> where messages from nodes in <code>edge_index[0]</code> are sent to nodes in <code>edge_index[1]</code> (in case <code>flow="source_to_target"</code> )."</p>

username: Ramzi_REZKI
cooked: <p>thanks, yes basically i had the right shape of edge-index (2,…) , but after applying the data parallel it devides this matrix in two parts (beaause i have 2 gpu actually) and so we get this error.</p>
<p>and to ansewer ton this question :”Were you able to run the code successfully on a single GPU without DataParallel?” : yes it wirks without any problem.</p>
<p>the Challenge is still open for ideas. Thanks!</p>
Autograd engine thread creation

username: mEm
cooked: <p>Hi, I am really struggling to find the place where the Autograd engine thread (or threadpool?) is created.</p>
<p>From my guessing, assuming to be using Torch from the Python API, this happens at the time the <code>torch.autograd</code> module is imported, which triggers the Python-C++ glue code that crates the Python module objects and functions.</p>
<p>The engine’s thread pool is initialised in <code>Engine::start_device_threads()</code>:</p>
<pre data-code-wrap="cpp"><code class="lang-cpp">auto Engine::start_device_threads() -&gt; void {
  // First always initialize the thread pool for re-entrant threads
  thread_pool_shared_ = std::make_shared&lt;ThreadPoolShared&gt;();
  // [...]

</code></pre>
<p>to which the parent which counts the most is <code>Engine::execute_with_graph_task()</code>.</p>
<p>From which already a question: since <code>Engine::execute_with_graph_task()</code> is theoretically called each time <code>THPEngine_run_backward</code> is called, why  if putting a debug print within <code>initialize_device_threads_pool</code>, is showed only once?</p>
<p>However, this finally related to the threads created to run on the device. Since I am currently working on a CPU-based Pytorch version, this does not really make a different, as no accelerator is used.</p>
<p>Yet, how and where is the main Autograd engine thread created?<br>
I would expect this to happen in <code>THPAutograd_initExtension()</code>, but I do not seem to find where this happen, which might not be there at all.</p>
<p>Thanks.</p>

username: soulitzer
cooked: <p>Hi,</p>
<blockquote>
<p>why if putting a debug print within <code>initialize_device_threads_pool</code>, is showed only once?</p>
</blockquote>
<p>Autograd device threads are only initialized once the first time backward is called and reused for subsequence backwards.</p>
<blockquote>
<p>Yet, how and where is the main Autograd engine thread created?</p>
</blockquote>
<p>The main engine thread is just the thread that calls backward.</p>

username: mEm
cooked: <p>Hi <a class="mention" href="/u/soulitzer">@soulitzer</a> ,</p>
<p>thanks for your valuable answer.<br>
So, to continue on that, how many threadpools are used in Torch?<br>
Because I’ve got to realise that a Torch execution (CPU only) was using several threads, which I now understand are related to the ATen core, and its intra- and inter-op concepts when it comes to tensor operations.<br>
Are these threadpools independent from the device threads (assuming a GPU aware build), or is there any interconnection between these threadpools?</p>
Quantization of Hybrid Pytorch Model

username: Aman_230
cooked: <p>Hi,</p>
<p>I hope you are fine and doing well.<br>
I have a  pytorch model consists of Conv + Bi GRU + FC layer.<br>
I have trained it and generated a pth file.</p>
<p>I want to quantize it, how to proceed? How to specify per channel quantization in Qconfig? And how to decide between symmetric or asymmetric quantization?</p>
<p>Any help will be very appreciable.</p>
Choose a random seed that generates median or best validation loss in Latent Diffusion Models?

username: Introvert_Loner
cooked: <p>I’m training a VAE for the later stage (diffusion) of the latent diffusion model framework. I tried a few configurations (e.g. changing the number of resblocks or number of channels), and each of the training loop of one configuration is run 5 times (corresponding to 5 seeds).</p>
<p>Question: Which seed should I choose for the model parameters for the later stage (training UNet), the one that achieves the best validation loss or the one has a median validation loss? For reporting the performance of the VAE, we can choose the mean of validation loss across the seeds (<a href="https://discuss.pytorch.org/t/different-seed-lead-to-very-different-test-result-on-the-test-set/67075/5">Report model training results among different seeds)</a>. But for training, we can only choose 1.</p>

username: KFrank
cooked: <p>Hi Introvert!</p>
<aside class="quote no-group" data-username="Introvert_Loner" data-post="1" data-topic="222923" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/i/858c86/48.png" class="avatar"> Introvert_Loner:</div>
<blockquote>
<p>Question: Which seed should I choose for the model parameters for the later stage (training UNet), the one that achieves the best validation loss or the one has a median validation loss?</p>
</blockquote>
</aside>
<p>It depends on what your purpose is.</p>
<p>If your goal is to have the best trained model to then use to generate stuff,<br>
choose the trained model (that happens to have come from some specific seed)<br>
that has the best validation loss.</p>
<p>On the other hand, if you are, say, researching training protocols, it would<br>
probably make sense to report the median validation loss (or more generally,<br>
the distribution of validation losses) obtained from a series of training runs.</p>
<p>Picking the best model (provided that you don’t pick the model that performs<br>
best on your so-called test set) is a fully legitimate approach.</p>
<p>By way of example, suppose you have a function defined on a square and you want<br>
to find an approximate minimum of that function.  A legitimate algorithm would be<br>
to sample a set of random points from that square, evaluate the function at those<br>
points, and keep the lowest value.  This generally won’t be anywhere near the best<br>
algorithm, but it’s logically sensible.</p>
<p>Elaborating, sample a set of random <em>starting</em> points, run some number of<br>
gradient-descent optimization steps starting with each of the starting points,<br>
and keep the lowest optimized value.  This would also be legitimate and would be<br>
akin to keeping the best validation loss produced by your five randomly-seeded<br>
training runs.</p>
<p>Best.</p>
<p>K. Frank</p>
CUDA 10.2 or 11.1 for Nvidia 2070S?

username: nyxynyx
cooked: <p>I am installing Pytorch 1.8.1 in a new Conda env on Ubuntu machine with multiple Nvidia 2070 Super and from the Pytorch homepage, we can either install the package <code>cudatoolkit=10.2</code> or <code>cudatoolkit=11.1</code>.</p>
<p><code>nvidia-smi</code> shows</p>
<pre><code>Driver Version: 450.102.04   CUDA Version: 11.0
</code></pre>
<p>How does one generally decide which version of CUDA to use?</p>

username: jackwhoknows
cooked: <p>I have this same question! I tried using 9.1 and had compatibility errors</p>

username: ptrblck
cooked: <p>All of our binaries support Turing GPUs (sm_75) and you can select any build.</p>
Agent Masking in Multi-agent environment?

username: Jean-Marc_Fauche
cooked: <p>Hi, I would like to know if there is a way to implement an “agent mask”. To clarify things: let’s imagine an environment that for certain steps provides data or not to the agents. Some agents have it, others do not. It would be logical that for an agent with no observation (so with agent_mask=False) the policy does not provide an action and that for the calculation of the loss, the transitions concerned are ignored…</p>
Checkpointing LlamaDecodingLayer or LlamaAttention to help with memory limitations?

username: hpcpony
cooked: <p>I’m working with the Huggingface Llama3 models ( <a href="https://github.com/huggingface/transformers/blob/main/src/transformers/models/llama/modeling_llama.py#L268" class="inline-onebox" rel="noopener nofollow ugc">transformers/src/transformers/models/llama/modeling_llama.py at main · huggingface/transformers · GitHub</a> ) and having memory issues due to sequence length.  It seems like if I could checkpoint either the LlamaDecodingLayer or the LlamaAttention blocks this would be a big help.  Ideally there would be a switch on FSDP2 fully_shard that would let me checkpoint modules as I shard them, but sadly I don’t see such a thing.</p>
<p>I understand (at a high level) the torch.utils.checkpoint (<a href="https://docs.pytorch.org/docs/2.8/checkpoint.html" class="inline-onebox" rel="noopener nofollow ugc">torch.utils.checkpoint — PyTorch 2.8 documentation</a>) but I don’t see how to apply it to an existing model.  Is there a way to do so without hacking the model itself?</p>
<p>Even some pseudo-code to point me in the right direction would be welcome.</p>
Can a PyTorch CI be set up locally?

username: ghostspiders
cooked: <p>I am preparing to contribute to PyTorch long-term, but incomplete local testing is causing significant issues. Is it possible to set up a PyTorch CI environment locally?</p>

username: ptrblck
cooked: <p>I don’t understand the use case to set up an entire CI locally, but you can of course run unit tests locally from the <code>test</code> folder of the repository.</p>
GPU usages bottleneck found usages for CudaMemcpyAsync is 55%

username: Avinash_Kumar
cooked: <p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/9/3/93048c58f53ceefbb9e7e16c849fe29e4a53867d.png" data-download-href="https://discuss.pytorch.org/uploads/default/93048c58f53ceefbb9e7e16c849fe29e4a53867d" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/9/3/93048c58f53ceefbb9e7e16c849fe29e4a53867d_2_690x125.png" alt="image" data-base62-sha1="kYzVPihjHvZjEhuY7JyRc3xIoCp" width="690" height="125" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/9/3/93048c58f53ceefbb9e7e16c849fe29e4a53867d_2_690x125.png, https://discuss.pytorch.org/uploads/default/optimized/3X/9/3/93048c58f53ceefbb9e7e16c849fe29e4a53867d_2_1035x187.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/9/3/93048c58f53ceefbb9e7e16c849fe29e4a53867d_2_1380x250.png 2x" data-dominant-color="E0E2E3"><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">2674×488 124 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>
<div class="md-table">
<table>
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
<th>Column 4</th>
</tr>
</thead>
<tbody>
<tr>
<td>Time</td>
<td>Total Time</td>
<td>Instances</td>
<td>name</td>
</tr>
<tr>
<td>16.2%</td>
<td>89.701 s</td>
<td>1498640</td>
<td>void at::native::unrolled_elementwise_kernel&lt;at::native::direct_copy_kernel_cuda(at::TensorIteratorBase &amp;)::[lambda() (instance 3)]::operator ()() const::[lambda() (instance 10)]::operator ()() const::[lambda(c10::Half) (instance 1)], at::detail::Array&lt;char *, (int)2&gt;, TrivialOffsetCalculator&lt;(int)1, unsigned int&gt;, TrivialOffsetCalculator&lt;(int)1, unsigned int&gt;, at::native::memory::LoadWithCast&lt;(int)1&gt;, at::native::memory::StoreWithCast&lt;(int)1&gt;&gt;(int, T1, T2, T3, T4, T5, T6)</td>
</tr>
<tr>
<td>12.7%</td>
<td>70.378 s</td>
<td>138240</td>
<td>ampere_fp16_s16816gemm_fp16_256x128_ldg8_relu_f2f_stages_32x3_tn</td>
</tr>
<tr>
<td>12.4%</td>
<td>68.252 s</td>
<td>222520</td>
<td>void cutlass::Kernel&lt;cutlass_80_tensorop_f16_s16816gemm_relu_f16_256x128_32x3_tn_align8&gt;(T1::Params)</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div><p>We are observing 55% time CudaMemcpyAsync API is getting called and observed top three kernel are element-wise, relu and cutlass relu</p>
<p>Like to understand if there is a scope of optimizing GPU usages here?<br>
Where to start investigating here?</p>
Cumulative distribution function of a Tensor-CDF

username: amin_sabet
cooked: <p>How can I get the cumulative density function of Tensor X which is evaluated at value V?</p>
<p>Here is the equivalent code in python.</p>
<p>ecdf =  statsmodels.distributions.empirical_distribution.ECDF(X)<br>
Val= ecdf(V)</p>

username: edmondj
cooked: <p>…Too bad, it is very useful for normalizing data.</p>

username: NikolasMorshuis
cooked: <p>I translated the ECDF function from statsmodels to PyTorch, hope it helps:</p>
<pre><code class="lang-auto">class ECDF(torch.nn.Module):
    def __init__(self, x, side='right'):
        super(ECDF, self).__init__()

        if side.lower() not in ['right', 'left']:
            msg = "side can take the values 'right' or 'left'"
            raise ValueError(msg)
        self.side = side

        if len(x.shape) != 1:
            msg = 'x must be 1-dimensional'
            raise ValueError(msg)

        x = x.sort()[0]
        nobs = len(x)
        y = torch.linspace(1./nobs, 1, nobs, device=x.device)

        self.x = torch.cat((torch.tensor([-torch.inf], device=x.device), x))
        self.y = torch.cat((torch.tensor([0], device=y.device), y))
        self.n = self.x.shape[0]

    def forward(self, time):
        tind = torch.searchsorted(self.x, time, side=self.side) - 1
        return self.y[tind]
</code></pre>
<p>Now you can use the ECDF function in PyTorch in the same way as the one in statsmodels:</p>
<pre><code class="lang-auto">x1 = torch.randn(1000)
x2 = torch.randn(1000)
ecdf_fn = ECDF(x1)
y = ecdf_fn(x2)
</code></pre>

username: edmondj
cooked: <p>It works great, thank you so much.</p>
Error while converting quantized Torch model to ONNX

username: Vitali-Matteo
cooked: <p>Hi everyone, I’m Matteo.</p>
<p>I’m applying QAT to YOLOv8n model with the following configuration:</p>
<pre><code class="lang-auto">QConfig(
    activation=FakeQuantize.with_args(
        observer=MovingAverageMinMaxObserver,
        quant_min=0,
        quant_max=255,
        dtype=torch.quint8,
        qscheme=torch.per_tensor_affine,
        averaging_constant=0.005,
        reduce_range=False
    ),
    weight=FakeQuantize.with_args(
        observer=PerChannelMinMaxObserver,
        quant_min=-127,
        quant_max=127,
        dtype=torch.qint8,
        qscheme=torch.per_channel_symmetric,
        ch_axis=0
    )
)
</code></pre>
<p>With backend set to <em>qnnpack:</em></p>
<pre><code class="lang-auto">torch.backends.quantized.engine = "qnnpack"
</code></pre>
<p>Target device only supports ONNX format, so I have to convert the model (after QAT) to ONNX. To do so, I am using the following procedure:</p>
<pre><code class="lang-auto">    def save(self, quantized_onnx_path: str):
        import torch.ao.quantization as quant

        self.quantized_model.eval()
        torch.backends.quantized.engine = 'qnnpack'
        self.quantized_model.apply(.apply(torch.ao.quantization.disable_observer))
        model_to_export = quant.convert(self.quantized_model.cpu(), inplace=False)

        dummy_input = torch.randn(1, 3, 25, 256).cpu()
        
        torch.onnx.export(
            model_to_export,
            dummy_input,
            quantized_onnx_path,
            opset_version=13, 
            input_names=['images'],
            output_names=['output'],
            dynamic_axes = {
                'images' : {0 : 'batch_size'},
                'output' : {0 : 'batch_size'}
            }
        )
</code></pre>
<p>But I keep getting this error during export:</p>
<pre><code class="lang-auto">NotImplementedError: Could not run 'quantized::conv2d.new' with arguments from the 'CPU' backend. This could be because the operator doesn't exist for this backend...
</code></pre>
<p>On the official Torch documentation page, I’ve seen that it might occour because input is not quantized, but even by wrapping the model inside the suggested class:</p>
<pre><code class="lang-auto">class QuantWrapper(torch.nn.Module):
    def __init__(self, model):
        super().__init__()
        self.quant = torch.ao.quantization.QuantStub()
        self.model = model
        self.dequant = torch.ao.quantization.DeQuantStub()

    def forward(self, x):
        x = self.quant(x)      
        x = self.model(x)       
        x = self.dequant(x) 
        return x

model_to_export = QuantWrapper(model_to_export)
</code></pre>
<p>the error remains the same.</p>
<p>How can I solve?</p>
How am i supposed to get old versions of torch on windows x64 arhitecture?

username: Alex_Eugen_Botez
cooked: <p>All posts lead me to <a href="https://download.pytorch.org/whl/cu80/torch_stable.html" rel="noopener nofollow ugc">https://download.pytorch.org/whl/cu80/torch_stable.html</a>, on which i can’t seem to find any wheels for windows x64. Or how can i get a version of pytorch running for my 8.6 compute GPU?</p>

username: ptrblck
cooked: <p>PyTorch Windows builds were most likely introduced after our CUDA 8.0 builds.</p>
<aside class="quote no-group" data-username="Alex_Eugen_Botez" data-post="1" data-topic="222813">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/alex_eugen_botez/48/75235_2.png" class="avatar"> Alex_Eugen_Botez:</div>
<blockquote>
<p>Or how can i get a version of pytorch running for my 8.6 compute GPU?</p>
</blockquote>
</aside>
<p>All of our current binaries support compute capability 8.6.</p>

username: Alex_Eugen_Botez
cooked: <p>So if I install pytorch for compute platform 12.6 it should work with my GPU? I don’t exaclty understand what you mean by current binaries. If I install pytorch for compute platform 12.6 it does work and store data on my gpu, but it seems that it uses cpu for computation, and I thought that my GPU lost support since I last installed pytorch.</p>
Torch.compile does not work after first graph break

username: richardzzj
cooked: <p>I have an auto generated ‘forward’ func:</p>
<blockquote>
<p>def forward(a, b, c):<br>
…</p>
<p>tmp=torch.lstm(a, (torch.tensor(…), torch.tensor(…)), self.lstm.weight, self.lstm.bias)<br>
…<br>
return ret</p>
</blockquote>
<p>After using ‘torch._dynamo.explain‘, i got one graph containing ops before torch.lstm and one graph break reason ‘step_unsupported‘ and no more. But there are still a lot of code left after torch.lstm. i thought torch.lstm may cause one graph break instead of ending torch.compile. Why is that and what should i do to make torch.compile work on the code after torch.lstm?</p>
PyTorch not supported

username: hushtear
cooked: <p>I’m having trouble installing PyTorch. I’ve been trying to get it to work for hours, but it’s not working…<br>
I get this error:</p>
<p>Found GPU0 NVIDIA GeForce GTX 1080 Ti which is of cuda capability 6.1.<br>
Minimum and Maximum cuda capability supported by this version of PyTorch is<br>
(7.0) - (12.0)</p>
<p>I downloaded PyTorch using this command:</p>
<p>pip install torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 --index-url <a href="https://download.pytorch.org/whl/cu118" rel="noopener nofollow ugc">https://download.pytorch.org/whl/cu118</a></p>
<p>and in theory, cu118 is supported by my 1080ti.<br>
The GTX 1080 Ti has a CUDA compute capability of 6.1<br>
NVIDIA’s official documentation and support information confirm that the CUDA Toolkit 11.8 supports GPUs with compute capabilities starting at version 3.5. Since 6.1 is greater than 3.5, my GPU is fully supported.</p>

username: ptrblck
cooked: <p>What does <code>torch.__version__</code>, <code>torch.version.cuda</code> , and <code>torch.cuda.get_arch_list()</code>return?</p>

username: hushtear
cooked: <p>Thank you for your attention, here it is:</p>
<p>PyTorch Version: 2.7.1+cu118<br>
CUDA Version (PyTorch compiled with): 11.8<br>
Supported CUDA Architectures: [‘sm_37’, ‘sm_50’, ‘sm_60’, ‘sm_61’, ‘sm_70’, ‘sm_75’, ‘sm_80’, ‘sm_86’, ‘sm_90’, ‘compute_37’]</p>

username: ptrblck
cooked: <p>The error message does not match the support matrix your current PyTorch binary supports:</p>
<aside class="quote no-group" data-username="hushtear" data-post="1" data-topic="222789">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/h/67e7ee/48.png" class="avatar"> hushtear:</div>
<blockquote>
<p>Minimum and Maximum cuda capability supported by this version of PyTorch is<br>
(7.0) - (12.0)</p>
</blockquote>
</aside>
<aside class="quote no-group" data-username="hushtear" data-post="3" data-topic="222789">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/h/67e7ee/48.png" class="avatar"> hushtear:</div>
<blockquote>
<p>CUDA Version (PyTorch compiled with): 11.8<br>
Supported CUDA Architectures: [‘sm_37’, ‘sm_50’, ‘sm_60’, ‘sm_61’, ‘sm_70’, ‘sm_75’, ‘sm_80’, ‘sm_86’, ‘sm_90’, ‘compute_37’]</p>
</blockquote>
</aside>
<p>So I guess you are using different environments and have installed a new PyTorch binary built with CUDA 12.8+.</p>
<p>Make sure you are installing and using a single PyTorch binary in each environment and uninstall all others.</p>

username: hushtear
cooked: <p>OK, yes… there is a problem with the application I am using. Thank you for pointing that out to me.</p>
Work vs. Future sync primitives for Distributed Torch backends

username: mEm
cooked: <p>This is a question related to the fundamental design of the internals of the Distributed Torch implementation.<br>
To synchronize a distributed Torch execution, there are two ways, using the <code>Work</code> handles that each PG call returns, or the <code>Future</code> handle that can be derived from the Work one.<br>
Why is that? Why not only relying on the Work handle (via <code>work-&gt;wait()</code>)?<br>
Also because, in the provided examples, those based on the C++ frontend seem to prefer this approach (<code>work-&gt;wait()</code>), while when using <code>DDP</code> from Python frontend, the internals are built upon the future concept, forcing anyone willing to implement a custom backend to support both, with the future implementation being quite intricate (also, why is it marked <code>final</code>?).<br>
To me, these two try to serve the same purpose, creating a logic duplication, and creating confusion on when to use one over the other.<br>
Is there a fundamental reason which brought to require the <code>Future</code> approach over the <code>Work</code> one, which seems to be the one first developed (since all PG calls return a <code>Work</code> object)?</p>

username: yf225
cooked: <p><code>Work</code> is the one we use the most, and <code>Future</code> is only for the RPC feature currently.</p>

username: mEm
cooked: <p>I see.<br>
I finally found a solution, which required extending the <code>Future</code> class.<br>
Nonetheless, <code>Work</code> and <code>Future</code> are conceptually very similar, so why not just extending <code>Work</code> to support RPC instead of creating a separate <code>Future</code> class, as both have a <code>.wait()</code> method for example.<br>
I guess that would have been much easier to handle and support.<br>
Last, is this assuming that RPC is involved in DDP?</p>
How to understand the files generated by TORCH_COMPILE_DEBUG

username: Guitenbay
cooked: <p>I use torch.compile to run the resnet50 model. The env are:</p>
<pre data-code-wrap="bash"><code class="lang-bash">TORCH_COMPILE_DEBUG=1 INDUCTOR_ORIG_FX_SVG=1 INDUCTOR_POST_FUSION_SVG=1 TORCHINDUCTOR_FX_GRAPH_CACHE=0
</code></pre>
<p>then I get some files:</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/b/9/b961d178bff6bf56487eb75ce3c69d16f5b1f32a.png" data-download-href="https://discuss.pytorch.org/uploads/default/b961d178bff6bf56487eb75ce3c69d16f5b1f32a" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/b/9/b961d178bff6bf56487eb75ce3c69d16f5b1f32a.png" alt="image" data-base62-sha1="qrXUddwNsierxmEK3azLUQWHJ4S" width="403" height="231"><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">403×231 6.05 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 know orig_fx_graph_diagram.svg is compute graph before Inductor, and graph_diagram.svg is graph after Inductor.</p>
<p>but how can I find the relation between the op in orig_fx_graph_diagram and the op in graph_diagram ?</p>
<p>Dose the relation show in inductor_provenance_tracking_node_mappings.json or inductor_triton_kernel_to_post_grad_nodes.json ?</p>
Install from source results in shared object error

username: Mehant_Kammakomati
cooked: <p>I am trying to install pytorch from source for development involving CUDA, however, I hit the following error on the shared object file. What am I missing?</p>
<pre><code class="lang-auto">    from torch.distributed.run import main
  File "/workspace/pytorch/torch/__init__.py", line 415, in &lt;module&gt;
    from torch._C import *  # noqa: F403
    ^^^^^^^^^^^^^^^^^^^^^^
ImportError: /workspace/pytorch/torch/lib/libtorch_python.so: undefined symbol: _ZTIN5torch8inductor28AOTIModelContainerRunnerCudaE

</code></pre>
<p>I have followed the steps from <a href="https://github.com/pytorch/pytorch?tab=readme-ov-file#from-source" class="inline-onebox" rel="noopener nofollow ugc">GitHub - pytorch/pytorch: Tensors and Dynamic neural networks in Python with strong GPU acceleration</a> with pytorch from commit - fca2601c9d628e1bd2d75c7318cd22c4e8c832aa.</p>
<p>My environment is linux.</p>
I got this error message on. frame pack. Any information will be appreciated

username: Jeffery_Lee
cooked: <p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/e/d/ed9761557ca366ba5582052b1bed6bf7701a876e.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/ed9761557ca366ba5582052b1bed6bf7701a876e" title="Frame pacy"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/e/d/ed9761557ca366ba5582052b1bed6bf7701a876e_2_666x500.jpeg" alt="Frame pacy" data-base62-sha1="xTPurNmcdp17Vu6uLdiYAqGotqe" width="666" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/e/d/ed9761557ca366ba5582052b1bed6bf7701a876e_2_666x500.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/e/d/ed9761557ca366ba5582052b1bed6bf7701a876e_2_999x750.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/e/d/ed9761557ca366ba5582052b1bed6bf7701a876e_2_1332x1000.jpeg 2x" data-dominant-color="52494F"><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">Frame pacy</span><span class="informations">1920×1440 325 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>

username: ptrblck
cooked: <p>You are using an older PyTorch binary built with CUDA &lt;=12.6 while your Blackwell GPU (compute capability 12.0) requires CUDA &gt;=12.8. Uninstall your current PyTorch binary and reinstall any of our build with CUDA &gt;= 12.8.</p>

username: Jeffery_Lee
cooked: <p>ok. thank you very much.</p>
Pytorch model as a standalone binaries?

username: Rodolphe_Lampe
cooked: <p>I’d like to compile a pytorch model to a standalone binary so that it would be extremly easy to deploy. I’ve seen this video <a href="https://www.youtube.com/watch?v=2LOPdVFoErs" rel="noopener nofollow ugc">Bin Bao at Modular Hack Weekend: From PyTorch Models to Standalone Binaries</a> that is exactly on this topic but there is no code or tutorial on how to do it and I don’t find any documentation about that elsewhere.</p>
<p>How can I compile a pytorch model to a standalone binary ?</p>

username: ptrblck
cooked: <p>I haven’t watched the presentation in detail but I assume the author introduced <code>AOTInductor</code> described <a href="https://docs.pytorch.org/docs/stable/torch.compiler_aot_inductor.html">here</a>:</p>
<blockquote>
<p>AOTInductor is a specialized version of <a href="https://dev-discuss.pytorch.org/t/torchinductor-a-pytorch-native-compiler-with-define-by-run-ir-and-symbolic-shapes/747">TorchInductor</a>, designed to process exported PyTorch models, optimize them, and produce shared libraries as well as other relevant artifacts. These compiled artifacts are specifically crafted for deployment in non-Python environments, which are frequently employed for inference deployments on the server side.</p>
<p>In this tutorial, you will gain insight into the process of taking a PyTorch model, exporting it, compiling it into an artifact, and conducting model predictions using C++.</p>
</blockquote>
How to increase Macro f1 score?

username: Nibani
cooked: <p>I’m working on a 6-class animal footprint/paw classification task. The dataset has 3,000 training images and 300 validation images. I’m using ResNet-18 with ImageNet pretrained weights, ImageNet normalization, Adam (lr = 1e-3), batch size 32, 20 epochs, and Cross-Entropy loss.</p>
<p>The issue: by around epoch 10 I reach <strong>97% training accuracy</strong>, but on validation both accuracy and <strong>macro F1</strong> stay around <strong>77%</strong> and don’t really improve.</p>
<p>Here’s the model head:<br>
<code><br>
model_ft = models.resnet18(weights=‘IMAGENET1K_V1’)<br>
num_ftrs = model_ft.fc.in_features<br>
model_ft.fc = nn.Sequential(<br>
nn.Linear(num_ftrs, 256),<br>
nn.ReLU(),<br>
nn.Linear(256, num_classes)<br>
)<br>
</code></p>
<p>Here are the augmentations:<br>
<code></code></p><code>
<h1><a name="p-475002-train-1" class="anchor" href="#p-475002-train-1"></a>train</h1>
<p>transforms.RandomResizedCrop(224, scale=(0.7, 1.0)),<br>
transforms.RandomHorizontalFlip(0.5),<br>
transforms.RandomRotation(15),<br>
transforms.ColorJitter(0.3, 0.3, 0.3, 0.1),<br>
transforms.RandomAffine(degrees=0, translate=(0.1, 0.1), scale=(0.9, 1.1))</p>
<h1><a name="p-475002-val-2" class="anchor" href="#p-475002-val-2"></a>val</h1>
</code><p><code>transforms.Resize(256),<br>
transforms.CenterCrop(224)<br>
</code></p>
<p>I’m honestly not sure what to try next in this situation—any advice would be appreciated!</p>