Unable to use correctly the new torch.fft module

Azerus: <p>Hello,</p>
<p>I’m working with pytorch 1.7 within docker (based on the image: <a href="http://nvcr.io/nvidia/pytorch" rel="noopener nofollow ugc">nvcr.io/nvidia/pytorch</a>  20.10-py3 in case it matter), I’m using Ubuntu LTS 18.04 with CUDA 11.1.</p>
<pre><code class="lang-auto">&gt;&gt;&gt; torch.__version__
'1.7.0a0+7036e91'
</code></pre>
<p>I can use the fft functions of pytorch but I want to use the fft module as advised in the documentation.</p>
<p>The problem is I can’t reproduce the examples given in the doc:</p>
<p>Using <code>torch.fft.fft</code> according to the doc:</p>
<pre><code class="lang-auto">&gt;&gt;&gt; import torch.fft
&gt;&gt;&gt; t = torch.arange(4)
&gt;&gt;&gt; t
tensor([0, 1, 2, 3])
&gt;&gt;&gt; torch.fft.fft(t)
tensor([ 6.+0.j, -2.+2.j, -2.+0.j, -2.-2.j])
</code></pre>
<p>What I get when I try to reproduce it:</p>
<pre><code class="lang-auto">&gt;&gt;&gt; import torch.fft
&gt;&gt;&gt; t = torch.arange(4)
&gt;&gt;&gt; t
tensor([0, 1, 2, 3])
&gt;&gt;&gt; torch.fft.fft(t)
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
RuntimeError: Expected a complex tensor.
</code></pre>
<p>Using <code>torch.fft.rfft</code> according to the doc:</p>
<pre><code class="lang-auto">&gt;&gt;&gt; import torch.fft
&gt;&gt;&gt; t = torch.arange(4)
&gt;&gt;&gt; t
tensor([0, 1, 2, 3])
&gt;&gt;&gt; torch.fft.rfft(t)
tensor([ 6.+0.j, -2.+2.j, -2.+0.j])
</code></pre>
<p>What I get when I try to reproduce it:</p>
<pre><code class="lang-auto">&gt;&gt;&gt; import torch.fft
&gt;&gt;&gt; t = torch.arange(4)
&gt;&gt;&gt; t
tensor([0, 1, 2, 3])
&gt;&gt;&gt; torch.fft.rfft(t)
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
AttributeError: module 'torch.fft' has no attribute 'rfft'
</code></pre>
<p>So I’ve got 2 questions ::<br>
1)Am I doing something wrong, or is there a problem with my pytorch installation (I had no problem so far)? How can I reproduce successfully the doc examples?</p>
<p>2)Is it possible to use half datatype with torch.fft module? (it’s discouraged in the torch.fft functions)</p>
<p>Thanks in advance for any help <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"><br>
Thomas</p>

Azerus: <p>I still have the same issue.<br>
That would be really great if someone with a pytorch version 1.7 could try the above examples, at least to know if the <a href="https://pytorch.org/docs/stable/fft.html#torch-fft-module" rel="noopener nofollow ugc">torch.fft module</a> is actually working or not. I’ve search on google and couldn’t find any example of the use of this module yet, as this module is quite recent maybe the documentation is wrong ?</p>
<p>Best regards,<br>
Thomas</p>

Nikronic: <p>Hi,</p>
<p>On my machine with latest <em><strong>stable</strong></em> build of PyTorch (1.7.0) I can reproduce all examples you have mentioned. Maybe you should make sure you are using correct build of PyTorch. Unfortunately I cannot test docker edition.</p>
<p>Bests</p>

Azerus: <p>Hi,<br>
Thanks for testing. I will investigate, maybe test an other docker image or simply go for a workaround. In case I found something interesting I’ll let a message here.</p>

ptrblck: <p>As <a class="mention" href="/u/nikronic">@Nikronic</a> said, update to the latest container, as <code>1.7.0a0+7036e91</code> is a pre-1.7.0 release and might thus be missing the methods.</p>

Azerus: <p>Ok, thanks for the confirmation.</p>
<p>I started using Docker quite recently and I found interesting the way it can create and manage separated environments, and it is also a good tool to share an app with all its environment. So I searched for Docker image of pytorch, and I found the nvidia deep learning frameworks (free of access, only need to register your email). This catalog seems quite useful, all the release are described <a href="https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes/rel_20-11.html#rel_20-11" rel="noopener nofollow ugc">here</a>. The only sad thing is it seems all the images described there seems to be build with pre-release versions of pytorch (like for example the pytorch V1.7 image you can found are based on: 1.7.0a0+7036e91 or 1.7.0a0+8deb4fe or 1.7.0a0+6392713). They did the same with the pre-release of v1.8 (1.8.0a0+17f8c32).</p>
<p>Maybe the simplest solution would be to switch to anaconda?</p>
<p>Anyways, thanks <a class="mention" href="/u/ptrblck">@ptrblck</a> and <a class="mention" href="/u/nikronic">@Nikronic</a> for your answers. I will put this thread to solved has you pointed to the root cause of the problem, but don’t hesitate to let a message if you have any further remarks.</p>

ptrblck: <p>You can always install the latest stable or nightly binaries from <code>conda</code> or <code>pip</code>.<br>
We are building the NGC container with the latest PyTorch master for this release. Since the containers go through our QA, the commit is delayed by approx. a month.</p>