How do I know the current version of pytorch?
import torch
print(torch.__version__)
Just for the record:
to check it from terminal in linux:
python -c "import torch; print(torch.__version__)"
So quick question here. When I check from Jupyter, I’m able to see the version printed but when I do the same from terminal, I get import error: no module named torch. Can you please help me out here?
Thanks.
I’m guessing jupyter is running in a different python environment than your default one.
The first thing to try would be to see what happens if you replace ‘python’ with ‘python3’ at the start of that command.
Thank you. That was it.
Thank you. It was very helpful!
with torch.version it gives
module ‘torch’ has no attribute ‘version’
Did you use the two underscores in the command as it’s working fine:
>>> import torch
>>> torch.__version__
'1.9.0a0+df837d0'
This is quite an old post but I’ll answer it in case someone else needs it
You’d have to install the Torch either globally or change your source to match the one ran on Jupyter. I’d assume you are using conda with jupyter.
You can find out the name of the environment from anaconda GUI or from the Jupyter notebook where it says ipykernel. Then you’d have to run:
conda activate <enviroment-name>
Now, you have access to the environment where pytorch is installed, and should match the version in jupyter.