akankshakshurai/cuda-error-resolution-analysis huggingface dataset:
Error in Cross-Entropy Loss Computation with CUDA: Assertion Failure on Batch Size Reduction to 16

username: External_happy
cooked: <p>Hello, I encountered an error while attempting to compute the cross-entropy loss function. The code snippet below presents the relevant portion:</p>
<pre><code class="lang-auto">logits_x = logits[:inputs_x.shape[0]]
loss_s = F.cross_entropy(logits_x, targets_x)
</code></pre>
<p>Where:</p>
<ul>
<li><code>targets_x</code> has a size of [16].</li>
<li><code>logits_x</code> has a size of [16, 47].</li>
</ul>
<p>The specific error message is as follows:</p>
<pre><code class="lang-auto">nll_loss_forward_reduce_cuda_kernel_2d: block: [0,0,0], thread: [0,0,0] Assertion `t &gt;= 0 &amp;&amp; t &lt; n_classes` failed.
RuntimeError: CUDA error: device-side assert triggered
CUDA kernel errors might be asynchronously reported at some other API call, so the stack trace below might be incorrect. For debugging, consider passing CUDA_LAUNCH_BLOCKING=1.
</code></pre>
<p>It’s worth noting that the code runs without any errors on other devices. However, when I reduce the batch size to 16, it results in the aforementioned error. Any insights or suggestions on resolving this issue would be appreciated</p>

username: ptrblck
cooked: <p>Your target contains class indices which are out of bounds:</p>
<pre data-code-wrap="python"><code class="lang-python">Assertion `t &gt;= 0 &amp;&amp; t &lt; n_classes` failed.
</code></pre>

username: External_happy
cooked: <p>Thank you. I have reviewed the dataset folder and identified an additional folder that is unrelated to my dataset.</p>
Time series forecasting using pytorch

username: ajitp82
cooked: <p>Has anybody implemented time series forecasting using pytorch_forecasting.models.nhits or TFT ?<br>
I have two issues</p>
<ol>
<li>
<p>prediction = best_tft.predict(val_dataloader, return_x=True,return_y=True)<br>
how do i interprete the preidction?<br>
I want to convert it back to pandas dataframe.</p>
</li>
<li>
<p>for pytorch_forecasting.models.nhits<br>
I am getting error<br>
mat1 and mat2 shapes cannot be multiplied (1x18516 and 24036x64)<br>
I am not getting how to resolve this?</p>
</li>
</ol>
Pytorch implementation of Depthwise Convolution

username: Rituraj_19_Dutta_100
cooked: <pre><code class="lang-auto">tf.keras.layers.DepthwiseConv2D(
    kernel_size,
    strides=(1, 1),
    padding="valid",
    depth_multiplier=1,
    data_format=None,
    dilation_rate=(1, 1),
    activation=None,
    use_bias=True,
    depthwise_initializer="glorot_uniform",
    bias_initializer="zeros",
    depthwise_regularizer=None,
    bias_regularizer=None,
    activity_regularizer=None,
    depthwise_constraint=None,
    bias_constraint=None,
    **kwargs
)
</code></pre>
<p>What is the Pytorch’s implementation of the above Keras equivalent of Depthwise Convolution?</p>

username: Mazhar_Shaikh
cooked: <p>Hi Rituraj,</p>
<p>The depthwise convolutions are implemented in pytorch in the <a href="https://pytorch.org/docs/stable/_modules/torch/nn/modules/conv.html#Conv2d" rel="noopener nofollow ugc">Conv</a> modules with the group parameter.<br>
For an input of c channels, and depth multiplier of d, the nn.Conv2d parameters become<br>
in_channels = c<br>
out_channels = d*c<br>
groups = c</p>
In the case of multiple networks, when torch.backends.cudnn.benchmark = True, will the benchmark be repeated?

username: Wang-MieMie
cooked: <p>When I have two networks that need to be trained alternately, for example, GAN network as a typical case (generator A, discriminator B).<br>
I train A, B alternately, for example, A-&gt;B-&gt;A-&gt;B…. At this point, will the benchmark be run every time, or only the first time A is executed and the first time B is executed?</p>
<p>In fact, I’d rather know what conditions would trigger the benchmark, or re-benchmark.<br>
Thanks!</p>

username: ptrblck
cooked: <p>The benchmark will be executed once per workload (input size, data layout, dtype, compute capability, etc.) and the selected algorithm will be cached.</p>

username: Wang-MieMie
cooked: <p>Thank you very much for your answer, I understand.<br>
The benchmark is independent of other networks.</p>
Why torch.unique() so slow

username: ysj-xuanyuan
cooked: <pre data-code-wrap="python"><code class="lang-python">seg = nnunet.predict(data)
old_seg = seg
# print(old_seg.equal(seg)) # True
lable = torch.unique(seg)
</code></pre>
<p>When running the above code, a problem was encountered:<br>
Without adding the third line of code, the torch.unique function takes 100ms to run. after adding the third line of code, it runs in only 10ms, but the equal judgement takes 100ms. what is the cause of this, and how should I improve my code to speed up the time.<br>
Where: seg is the segmentation result by nnunet inference, data type is tensor, on cuda:0, int8</p>

username: ptrblck
cooked: <p>CUDA operations are executed asynchronously and accessing results of these operations will synchronize your code. Either manually synchronize the code before starting and stopping the host timers or use <code>torch.utils.benchmark</code> which will synchronize the code for you and add warmup iterations.</p>
Not able to install pytorch/torch on mac M2 Air

username: Pooja_Harihar
cooked: <p>pip install torch ERROR: Could not find a version that satisfies the requirement torch (from versions: none) ERROR: No matching distribution found for torch</p>
<p>my python and pip version are as follows: Python 3.12.0 pip 23.3.2</p>
<p>Looking for help to solve this issue. I am using venv on vs code, also working on llm models and need to use it.</p>
<p>At first i tried installing requirements.txt using pip installl -r requirements.txt It contains the following:</p>
<p>pypdf langchain torch accelerate bitsandbytes transformers sentence_transformer faiss_cpu chainlit huggingface_hub</p>
<p>It is throwing error</p>