Can't use `torch.nn.functional.dropout1d` of pytorch

I want to use torch.nn.functional.dropout1d for my code. But when I try to use it, python prompts me:

AttributeError: module 'torch.nn.functional' has no attribute 'dropout1d'. 

Then, I go to the source code of And I find there is no dropout1d function in the script. However, PyTorch has officially provided the source code of dropout1d. The link is pytorch/ at master ยท pytorch/pytorch ( and torch.nn.modules.dropout โ€” PyTorch 1.13 documentation. From the webpage, dropout1d is introduced in torch-1.12.

My torch is installed using pip install torch on ubuntu and the version is โ€˜1.10.1+cu102โ€™. According to the PyTorchโ€™s installation instructions of Linux, the Stable (1.13.1) version should be installed. However, the source code on my computer is different from the official source code.

Now, I think the the question becomes how to install the correct version of torch. But when I want to install the specified version of torch with command-pip install --upgrade torch==1.12, pip prompts me:

ERROR: Could not find a version that satisfies the requirement torch==1.12 (from versions: 1.0.0, 1.0.1, 1.0.1.post2, 1.1.0, 1.2.0, 1.3.0, 1.3.1, 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.8.0, 1.8.1, 1.9.0, 1.9.1, 1.10.0, 1.10.1, 1.10.2)
ERROR: No matching distribution found for torch==1.12

Can anyone help me?

I would recommend to either uninstall all PyTorch binaries in your current environment and then use the install instructions or to create a new and empty virtual environment and install the latest PyTorch release there.

1 Like

Okay, I will try it now.

It works, thank you!