TorchData performance

username: BlueskyFR
cooked: <p>Hi there!</p>
<p>I was just looking for informations.<br>
TensorFlow has a tf.data API which compiles to static graphs, thus building highly optimized compiled data pipelines, because Python is slow.</p>
<p>What does TorchData do? Is it simply a Python wrapper or is there really an interest in terms of performances, compared to TensorFlow?</p>
<p>What about a comparison with NVIDIA Dali?</p>
<p>Thanks!</p>

username: JuanFMontesinos
cooked: <p>Nvidia Dali is faster. Basically has queues, runs everything in the background etc…<br>
Also they optimized typicall data pipelines (like gpu-decoding, cropping, resizing).<br>
It’s limited but if it fits your necessities it’s the fastest.</p>
<p>On the other hand, pytorch has its policy of “be flexible”. Pytorch dataloader just lauch multiprocessing (at least the last time i checked) and relies on user’s skills to improve the speed. Basically provides boilerplate code to make batches, convert stuff to tensors and so on.  You can debug the code as it’s pure python.</p>
<p>What is better?<br>
Well that’s very user dependent. I tried to use dali and it’s wonderful when your pipeline is straight-forward. It’s painful when you would like to inspect inner ops or do your own.</p>
<p>But in the end, benchmarks doesn’t show TF is faster than Pytorch despite everything is compiled, thus, I wouldn’t say it’s better atm.</p>

username: BlueskyFR
cooked: <p>Thanks for the reply!<br>
It is true that Dali has a huge performance boost over TF.<br>
I guess it is possible to implement custom augmentation after converting the Dali Dataset to a TF Dataset, by calling .map() on it.<br>
Do you have any source for the benchmarks you were talking about?</p>

username: JuanFMontesinos
cooked: <p>It’s difficult to keep track of the 2022 results.<br>
For example here you can check the results:</p><aside class="onebox allowlistedgeneric" data-onebox-src="https://medium.com/huggingface/benchmarking-transformers-pytorch-and-tensorflow-e2917fb891c2">
  <header class="source">
      <img src="https://miro.medium.com/1*m-R_BkNf1Qjr1YbyOIJY2w.png" class="site-icon" width="32" height="32">

      <a href="https://medium.com/huggingface/benchmarking-transformers-pytorch-and-tensorflow-e2917fb891c2" target="_blank" rel="noopener nofollow ugc" title="02:19PM - 02 September 2020">Medium – 2 Sep 20</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/258;"><img src="https://miro.medium.com/max/870/1*9TuA4ymG0bUqi_t4j3zZCw.png" class="thumbnail" width="690" height="258"></div>

<h3><a href="https://medium.com/huggingface/benchmarking-transformers-pytorch-and-tensorflow-e2917fb891c2" target="_blank" rel="noopener nofollow ugc">Benchmarking Transformers: PyTorch and TensorFlow</a></h3>

  <p>Our Transformers library implements several state-of-the-art transformer architectures used for NLP tasks like text classification…</p>

  <p>
    <span class="label1">Reading time: 6 min read</span>
  </p>

  </article>

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

  <div style="clear: both"></div>
</aside>
<p>
and both forward times are the same roughly.</p>
<p>So in the end it’s about the dataloaders and I don’t really thing pytorch is much worse on that side. Tensorflow just provides tools which are optimized for people who is not expert in a given field. To achieve the same performance with pytorch you do need to get into different libraries and understand which one to use in which case.  For example using librosa is much slower than scipy, but more versatile. Loading video is not straight-forward and you need to get very good libraries not to bottleneck the dataloading.</p>
<p>In that sense, PyTorch has always been a bit greenish as it provide less tools. In the end that side relies on the programmer. A good one will do a good job.</p>

username: mikatsukons
cooked: <p>hello, I want to use Nvidia Dali for a video dataset. is there any implementation as a “template”/guide?<br>
thanks</p>