Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"torch" and "pytorch" version mismatch in conda

I installed the following in an environment:

cudatoolkit=11.3
pytorch=1.11.0
torchvision=0.12.0

But when asking for the torch/cuda version I get this:

$ python3 -c "import torch; print(torch.__version__)"
1.12.1+cu102 

Which is not what I want (1.12.1 would be fine, but cu102 is too old). Looking further, I see this:

$ conda list torch
# packages in environment at /home/ml/anaconda3/envs/ldm:
#
# Name                    Version                   Build  Channel
pytorch                   1.11.0          py3.8_cuda11.3_cudnn8.2.0_0    pytorch
pytorch-lightning         1.4.2                    pypi_0    pypi
pytorch-mutex             1.0                        cuda    pytorch
torch                     1.12.1                   pypi_0    pypi
torch-fidelity            0.3.0                    pypi_0    pypi
torchdiffeq               0.2.3                    pypi_0    pypi
torchmetrics              0.6.0                    pypi_0    pypi
torchvision               0.12.0               py38_cu113    pytorchcode 

So "pytorch" has the version I want (with cuda11.3), but "torch" is 1.12.1. Why? Moreover, "torch" does not seem to be a conda package (PackagesNotFoundError when trying to install), which is surprising since it appears in "conda list".

There is clearly something I do not understand about conda / pytorch. Can someone please explain it?

like image 348
amstramgram Avatar asked Dec 19 '25 16:12

amstramgram


1 Answers

So in the end that "torch" fake (?) package was my previous install of pytorch and cuda (with pip). The conda install actually made the pip one not work anymore ("import torch" was not working outside of the environment). Which is even weirder since my understanding of virtual environment was that it should at the very least not affect what's outside.

The solution was to reinstall pytorch with pip (outside the environment). After that, "import torch" worked inside the environment. Which again is weird since conda installed his own version of pytorch, apparently not to use it in the end.

I consider this an "answer" as it solves the problem I was having, but I still don't understand why conda behaved this way.

like image 194
amstramgram Avatar answered Dec 21 '25 05:12

amstramgram



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!