Do I need torch for pytorch?

I run Pycharm on Windows 10 and experience problems with torch, as it suddenly fails to import after I install a new version of pytorch and what not. I’ve googled a bit, and others seem to have similar problems. I’ll probably be able to solve them if I must, but my question now is: “Do I have to?”. Can I run pytorch nn-models without torch? I have some torch.nn models lying around; can I port them to pytorch easily? I notice that pytorch tutorials tend to use torch, but this is maybe for historic reasons?

Fredrik Dahl

Could you please provide some detailed logs?

Do you mean you want to comment out import torch.nn in your code to workground this problem? It won’t work because in Python, torch refers to PyTorch.

Well, maybe it is because pytorch is already registered in PyPI before the release of the PyTorch.

try using jupiter notebook and if the problem exists

Thanks for the advice, but it didn’t really answer my question, so I suspect my question is silly or ill defined. Some sources say that they stopped developing torch in 2018, and that the same kind of neural net functionality is implemented independently in pytorch.

My question is: If I (for some odd reason) never succeed in importing torch, can I still make neural net models in pytorch?
Can I use pytorch without torch?

Fredrik

Yes. You can build neural-networks in PyTorch without manually installing torch.

Check out the installation page for PyTorch => https://pytorch.org/get-started/locally/

I’m not sure if about porting torch models into Pytorch. Maybe look into ONNX.

Sorry guys, I think I get it now. Since the conda install command refers to ‘pytorch’ and my Python code goes ‘import torch’ (rather than ‘import pytorch’), I assumed the import statement referred to (a Python wrapped) Lua torch. I guess the ‘py’ of ‘pytorch’ is skipped since we all know we’re writing Python :-). This is what happens to you (i.e. me) when you copy sample code blindly.

I now think my problem may be with Conda. When I install a package, it giver this warning:

==> WARNING: A newer version of conda exists. <==
current version: 4.5.11
latest version: 4.8.3
Please update conda by running
$ conda update -n base -c defaults conda

But when I run the suggested command, it reproduces the warning, and claims all is installed:
==> WARNING: A newer version of conda exists. <==
current version: 4.5.11
latest version: 4.8.3
Please update conda by running
$ conda update -n base -c defaults conda
# All requested packages already installed.

I guess I should reinstall (Ana)conda?

Apparently my problem was that pytorch required Python 3.5, while I had upgraded to 3.6.