akankshakshurai/cuda-error-resolution-analysis huggingface dataset:
Error in My Kaldi-Torch CMakeLists.txt (Very Important)

krrishabh: <p><strong>My Kaldi CMakeLists.txt</strong> get an error please help me as soon as possible…<br>
It is for lattice rescoring pytorch in kaldi</p>
<pre><code class="lang-auto">cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
set(PUBLIC_HEADERS
    pytorch-rnnlm.h
)

add_library(kaldi-pyrnnlm
    pytorch-rnnlm.cc
)

#find_package(Torch REQUIRED)

#target_include_directories(kaldi-pyrnnlm PUBLIC 
#    ${PYTORCH_DIR}
#    ${PYTORCH_DIR}/bin
#    ${PYTORCH_DIR}/include
#    ${PYTORCH_DIR}/share
#
#)

target_include_directories(kaldi-pyrnnlm PUBLIC 
     $&lt;BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..&gt;
     $&lt;INSTALL_INTERFACE:include/kaldi&gt;
)

target_link_libraries(kaldi-pyrnnlm PUBLIC
    kaldi-lm
    kaldi-util
    kaldi-matrix
    kaldi-base
    -lz
    -ldl
    -fPIC
    -L"/home/rakesh/rishabh_workspace/ASR/kaldi_old/tools/libtorch"
)

#target_link_libraries(kaldi-pyrnnlm "${TORCH_LIBRARIES}")
set_property(TARGET kaldi-pyrnnlm PROPERTY CXX_STANDARD 14)

install(TARGETS kaldi-pyrnnlm
    EXPORT kaldi-targets
    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

install(FILES ${PUBLIC_HEADERS} DESTINATION include/kaldi/pyrnnlm)

</code></pre>
<p>It is being called from another CMakeLists.txt . So, Can’t use the standard CMakeLists.txt</p>
<p>Error:</p>
<pre><code class="lang-auto">In file included from /home/rakesh/rishabh_workspace/ASR/kaldi_old/src/pyrnnlm/pytorch-rnnlm.cc:24:0:
/home/rakesh/rishabh_workspace/ASR/kaldi_old/src/pyrnnlm/../pyrnnlm/pytorch-rnnlm.h:31:10: fatal error: torch/torch.h: No such file or directory
 #include &lt;torch/torch.h&gt;
          ^~~~~~~~~~~~~~~
compilation terminated.
src/pyrnnlm/CMakeFiles/kaldi-pyrnnlm.dir/build.make:62: recipe for target 'src/pyrnnlm/CMakeFiles/kaldi-pyrnnlm.dir/pytorch-rnnlm.cc.o' failed
make[2]: *** [src/pyrnnlm/CMakeFiles/kaldi-pyrnnlm.dir/pytorch-rnnlm.cc.o] Error 1
CMakeFiles/Makefile2:7423: recipe for target 'src/pyrnnlm/CMakeFiles/kaldi-pyrnnlm.dir/all' failed
make[1]: *** [src/pyrnnlm/CMakeFiles/kaldi-pyrnnlm.dir/all] Error 2
</code></pre>
Batch in nn.LSTM

arjun_pukale: <p>I have doubt in nn.LSTM, what does batch mean here?<br>
for eg if my seque<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/e/9/e978ec4f955d5294b0ce7128970a29a16372ef89.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/e978ec4f955d5294b0ce7128970a29a16372ef89" title="lstm doubt"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/e/9/e978ec4f955d5294b0ce7128970a29a16372ef89_2_690x430.jpeg" alt="lstm doubt" data-base62-sha1="xjokhwjsyej2xhpdJfc5TIsCZCh" width="690" height="430" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/e/9/e978ec4f955d5294b0ce7128970a29a16372ef89_2_690x430.jpeg, https://discuss.pytorch.org/uploads/default/original/3X/e/9/e978ec4f955d5294b0ce7128970a29a16372ef89.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/e/9/e978ec4f955d5294b0ce7128970a29a16372ef89.jpeg 2x" data-dominant-color="EEEEEF"><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">lstm doubt</span><span class="informations">986×615 84.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> nce is sequence of characters then what does this batch means?</p>

ptrblck: <p>A batch is a collection of samples, i.e. instead of passing a single sample with a specified sequence length and the number of features, you can pass multiple samples as once, which will be processed in one go.<br>
All modules accept batched data, as this will usually speed up your training.</p>

arjun_pukale: <p>does it defines the batch size? or no of batches?</p>

ptrblck: <p>The <code>batch</code> dimension in <code>input</code> defines the batch size.</p>
Does PyTorch ignore zero weights during forward?

andrea_bragagnolo: <p>As title says, does PyTorch perform some kind of under-the-hood optimizations for zeroed-out parameters in a network’s layers? I.e., would the forward() method of a normal network be slower than the same architecture but with some of its weights set to 0?</p>

albanD: <p>Hi,</p>
<p>No we don’t <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"><br>
Checking for the content of a Tensor is usually more expensive in most cases than the potential gain you could get from it here.</p>

andrea_bragagnolo: <p>Thank you very much!</p>
PyTorch with Clutser or MicroCloud

Abhinandan1414: <p>Hello,<br>
I have three laptops with Ubuntu on all of them. Configuration as follows:<br>
Laptop1 : i5 processor with Intel GPU 16GB RAM<br>
Laptop2:  i3 processor with Intel GPU 12GB RAM<br>
Laptop3:  i7 processor with Intel GPU 6GB RAM.</p>
<p>** Now I want to pool the resources viz. CPU+GPU+RAM ** Not so keen on <strong>pooling the secondary memory</strong> i.e storage space.</p>
<p>Dear Members, Please let me know what do you suggest Cluster or Micro Cloud. Which option suites PyTorch. I am not keen on Spark or Yarn solution using Pyspark. Later I intend to add Jetson nano graphics card to this cluster or cloud whichever you suggest. Any suggestions in this regard would be highly appreciated. Already I am seeing 1.6X improvement in speed with PyTorch for Convolution Neural Network with MNIST data set visa vis TensorFlow without Mother board getting heated on single node. Back bone for the Nodes is Wireless Local Area Network with practical speed of 5 Mega B(b)its per second. Any suggestions in this regard would be highly appreciated. Thanks in advance</p>
Embed Co-ordinate Tensor in Array Tensor

Jack_Rolph: <p>Suppose I have a PyTorch tensor that represents a list of 1000 coordinates, where indices 0-2 are independent x-y-z co-ordinates and index 3 is a value associated with the coordinate.</p>
<p>I want to produce a ‘graph’ of those co-ordinates: an I x J x K grid, with the value from the coordinates at each index.</p>
<p>For example:</p>
<pre><code>batch_size=10
channels = 2
n_coords = 1000

len_coords = 4
low = 0
high=10
some_limit = 5

coords = torch.zeros(batch_size, channels, n_coords, len_coords).random_(low, high) # a set of coordinates
#SOME OPERATION YIELDS -&gt;
image = torch.zeros(batch_size, channels, high, high, high) #The 'space' I want to embed the coo-ordinates in
</code></pre>
<p>I have a solution involving loops that I have developed that produces the desired result:</p>
<pre><code>coords_shape = torch.Tensor([*data.shape][0:2]).int()
axis_shape = torch.Tensor([high,high,high]).int()    
image_shape = torch.cat((coords_shape, axis_shape), axis=0)
image = torch.zeros(*image_shape)

    
for b in range(coords.shape[0]):
    for c in range(coords.shape[1]):
        for v in range(coords.shape[2]):
                elem = coords[b, c, v]
                if(elem[3]&gt;some_limit):
                    image[batch_elem, channel, int(elem[0]), int(elem[1]), int(elem[2])]=elem[3]
</code></pre>
<p>I know this is suboptimal because of the loops.</p>
<p>Is there a smarter way of implementing this?</p>
Forward tensor to module in a Modulelist efficently?

HappyPants: <p>Given some <code>nn.Modulelist</code> object that contains K modules and a pair of tensors where the first tensor contains the data to send and the second the indices of the module in the <code>nn.Modulelist</code> object, how to forward the tensor to its associated module efficiently ?</p>
<p>The only way I’ve been able to do it is by forwarding tensor in batch to each module  of the <code>nn.Modulelist</code> object. Is there another way that is faster?</p>
<pre><code class="lang-auto">import torch
import torch.nn as nn

input_size = 40
output_size = 40
batch_size=1024
number_of_module=10
device=torch.device('cpu')

module_list = nn.ModuleList([nn.Linear(input_size, output_size) for _ in range(number_of_module)])
t_idx = torch.LongTensor(batch_size).random_(0, number_of_module) #indice of the Modulelist oject
data = torch.rand(batch_size, input_size)

next_state = torch.rand((t_idx.size(0), output_size)).to(device)
for ixx in set(t_idx.tolist()):
    ixs = torch.where(t_idx == ixx)
    next_state[ixs] = module_list[ixx](data[ixs])
</code></pre>
Problem with FasterRCNN

Seo: <p>I have implemented a FasterRCNN and I want to use it on COCO dataset but there is a problem inside the implementation of the PyTorch module. Whenever I pass to the model an image without objects (bboxes is an empy list) the model crashes when it tries to unpack the boxes coordinates.</p>
<p>The model I have used:</p>
<pre><code class="lang-auto">    model = torchvision.models.detection.fasterrcnn_resnet50_fpn(pretrained=True)
    in_features = model.roi_heads.box_predictor.cls_score.in_features
    model.roi_heads.box_predictor = FastRCNNPredictor(in_features, num_classes)
</code></pre>
<p>The lines of code with the error in <a href="https://github.com/pytorch/vision/blob/master/torchvision/models/detection/transform.py#L262" rel="nofollow noopener">torchvision/models/detection/transform.py</a> line 220:</p>
<pre><code class="lang-auto">    xmin, ymin, xmax, ymax = boxes.unbind(1)

    xmin = xmin * ratio_width
    xmax = xmax * ratio_width
    ymin = ymin * ratio_height
    ymax = ymax * ratio_height
    return torch.stack((xmin, ymin, xmax, ymax), dim=1)
</code></pre>
<p>here boxes is an empty list and so the unbind() fails to unpack. Someone can help me? For what I can see it seems to be a bad implementation of the module</p>
Pytorch on windows with python 32bits

alexandreCameron: <p>Hi,</p>
<p>Is there a way to use pytorch on a windows machine with 32bits ?</p>
<p>More precisely, my project requires to generate predictions (training is not mandatory) for a windows machine on python 3.8 32 bits. I was not able to build onnxruntime for python 32bits even if the current documents says it’s possible.</p>
<p>Any method to make predictions from an existing model on a windows python 32bits machine would help.</p>
<p>Thank you,.</p>
Some questions about torch.utils.tensorboard add_graph

jo9sie: <p>Hi , my dear friend, I have some questions about torch.utils.tensorboard.</p>
<ol>
<li>Does TensorFlow tensorboard support more functions than PyTorch tensorboard?</li>
<li>I noticed in Tutorials  Visualizing Models, Data, and Training with TensorBoard,  part 3: nspect the model using TensorBoard.  In the picture the button “xla cluter” “memory” “compute time” is grey, it this function available in PyTorch and how can I use them?</li>
</ol>
<p>Thank you so much!!</p>
How to get the input and output information of a network

lee64456546: <pre><code class="lang-auto">class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.Conv2d(3, 6, 5)
        self.pool = nn.MaxPool2d(2, 2)
        self.conv2 = nn.Conv2d(6, 16, 5)
        self.fc1 = nn.Linear(16 * 5 * 5, 120)
        self.fc2 = nn.Linear(120, 84)
        self.fc3 = nn.Linear(84, 10)

    def forward(self, x):
        x = self.pool(F.relu(self.conv1(x)))
        x = self.pool(F.relu(self.conv2(x)))
        x = x.view(-1, 16 * 5 * 5)
        x = F.relu(self.fc1(x))
        x = F.relu(self.fc2(x))
        x = self.fc3(x)
        return x
</code></pre>
<p>I have a simple network, but having trouble when trying to get the input and output information like the name and the size, is there a way i can get those information? Thanks.</p>
<p>like netron does, it shows the input and the output.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/8/f/8f2f439016977e69c14279bdaddb8671ba4ba713.png" data-download-href="https://discuss.pytorch.org/uploads/default/8f2f439016977e69c14279bdaddb8671ba4ba713" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/8/f/8f2f439016977e69c14279bdaddb8671ba4ba713_2_412x500.png" alt="image" data-base62-sha1="kqFxwDTQf0J9YsNbEMCFLzJ0ZLd" width="412" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/8/f/8f2f439016977e69c14279bdaddb8671ba4ba713_2_412x500.png, https://discuss.pytorch.org/uploads/default/optimized/3X/8/f/8f2f439016977e69c14279bdaddb8671ba4ba713_2_618x750.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/8/f/8f2f439016977e69c14279bdaddb8671ba4ba713.png 2x" data-dominant-color="E8E7E9"><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">661×802 28.3 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>

chetan06: <p>Input is indeoendent quantity. You feed in the input and you will get the output. First make the object of the class net and pass input tensor to the net which will process that into the output. Was I able to interpret your question correctly?</p>

lee64456546: <p>i updated the question, sorry for not expressing myself clearly.</p>
How to improve accuracy in pytorch?

thaingi: <p>I am trying a pytorch program.The accuracy of my program is very low.Its about 30%.So,how can I improve the accuracy of my pytorch program.Please guide me any suggestion.Thanks a lot in advance!</p>

emcp: <p>this depends on a multitude of factors… maybe it is easier to explain to you if you share the program… but more likely you should go take some ML basic courses to understand what ML and Deep Learning are all about…</p>
<ol>
<li>could be your training data is poor</li>
<li>you could have bad hyper parameters</li>
<li>there could be a bug in the code</li>
</ol>
<p>the list goes on… first step is to check what you are doing with your program</p>

thaingi: <aside class="quote no-group quote-modified" data-username="emcp" data-post="2" data-topic="80733">
<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/e/db5fbb/48.png" class="avatar"> emcp:</div>
<blockquote></blockquote>
</aside>
<p>Thanks a lot for explaining.</p>

Lisa_McCoy: <p>thank you, this is really useful</p>
How to Cut Tiff files into Tiles

Jaideep_Valani: <ol>
<li>Is there any efficient way to cut big tiff layer file into tiles</li>
<li>How to discard the extracted tiles whose large portion is empty …</li>
</ol>

ptrblck: <p>Would you create these tiles as a preprocessing step or would you like to process the image tensor?<br>
In the latter case you could use <code>tensor.unfold</code> to create these patches.<br>
Once you have the patches, you could check each patch, if it’s “empty” based on your condition and remove it.</p>