I have python file with lines:
import argparse
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms
from torch.autograd import Variable
It generates errors:
File "C:\gdrive\python\a.py", line 5, in <module>
import torch.nn.functional as F
ModuleNotFoundError: No module named 'torch.nn.functional'
How to fix that error?
I have installed pytorch by using command:
conda install pytorch-cpu torchvision-cpu -c pytorch
It looks like you have an outdated version of PyTorch. Conda - pytorch-cpu was last published over a year ago and its latest version of PyTorch is 1.1.0, whereas PyTorch is currently at version 1.5.0. That packages has been abandoned.
You should install PyTorch with the official instructions given on PyTorch - Get Started locally, by selecting the version you want. In your case that would be Conda with CUDA None (to get the CPU only version).
The resulting command is:
conda install pytorch torchvision cpuonly -c pytorch
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With