Two different Cudatoolkit version and PyTorch version for same Conda environment

Conda list returned the following configuration:

# packages in environment at /home/user/anaconda3/envs/experiment2:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
_openmp_mutex             5.1                       1_gnu  
asttokens                 2.0.5              pyhd3eb1b0_0  
backcall                  0.2.0              pyhd3eb1b0_0  
blas                      1.0                         mkl  
ca-certificates           2024.3.11            h06a4308_0  
comm                      0.2.1            py38h06a4308_0  
cudatoolkit               9.2                           0  
debugpy                   1.6.7            py38h6a678d5_0  
decorator                 5.1.1              pyhd3eb1b0_0  
executing                 0.8.3              pyhd3eb1b0_0  
freetype                  2.12.1               h4a9f257_0  
importlib-metadata        7.0.1            py38h06a4308_0  
importlib_metadata        7.0.1                hd3eb1b0_0  
intel-openmp              2023.1.0         hdb19cb5_46306  
ipykernel                 6.28.0           py38h06a4308_0  
ipython                   8.12.2           py38h06a4308_0  
jedi                      0.18.1           py38h06a4308_1  
jpeg                      9b                   h024ee3a_2  
jupyter_client            8.6.0            py38h06a4308_0  
jupyter_core              5.5.0            py38h06a4308_0  
lcms2                     2.12                 h3be6417_0  
ld_impl_linux-64          2.38                 h1181459_1  
lerc                      3.0                  h295c915_0  
libdeflate                1.17                 h5eee18b_1  
libffi                    3.4.4                h6a678d5_0  
libgcc-ng                 11.2.0               h1234567_1  
libgomp                   11.2.0               h1234567_1  
libpng                    1.6.39               h5eee18b_0  
libsodium                 1.0.18               h7b6447c_0  
libstdcxx-ng              11.2.0               h1234567_1  
libtiff                   4.2.0                h85742a9_0  
libuv                     1.44.2               h5eee18b_0  
libwebp-base              1.3.2                h5eee18b_0  
lz4-c                     1.9.4                h6a678d5_0  
matplotlib-inline         0.1.6            py38h06a4308_0  
mkl                       2023.1.0         h213fc3f_46344  
mkl-service               2.4.0            py38h5eee18b_1  
mkl_fft                   1.3.8            py38h5eee18b_0  
mkl_random                1.2.4            py38hdb19cb5_0  
ncurses                   6.4                  h6a678d5_0  
nest-asyncio              1.6.0            py38h06a4308_0  
ninja                     1.10.2               h06a4308_5  
ninja-base                1.10.2               hd09550d_5  
numpy                     1.24.3           py38hf6e8229_1  
numpy-base                1.24.3           py38h060ed82_1  
olefile                   0.46               pyhd3eb1b0_0  
openjpeg                  2.4.0                h3ad879b_0  
openssl                   3.0.13               h7f8727e_0  
packaging                 23.2             py38h06a4308_0  
parso                     0.8.3              pyhd3eb1b0_0  
pexpect                   4.8.0              pyhd3eb1b0_3  
pickleshare               0.7.5           pyhd3eb1b0_1003  
pillow                    8.3.1            py38h2c7a002_0  
pip                       23.3.1           py38h06a4308_0  
platformdirs              3.10.0           py38h06a4308_0  
prompt-toolkit            3.0.43           py38h06a4308_0  
psutil                    5.9.0            py38h5eee18b_0  
ptyprocess                0.7.0              pyhd3eb1b0_2  
pure_eval                 0.2.2              pyhd3eb1b0_0  
pygments                  2.15.1           py38h06a4308_1  
python                    3.8.19               h955ad1f_0  
python-dateutil           2.8.2              pyhd3eb1b0_0  
pytorch                   1.7.0           py3.8_cuda9.2.148_cudnn7.6.3_0    pytorch
pyzmq                     25.1.2           py38h6a678d5_0  
readline                  8.2                  h5eee18b_0  
setuptools                68.2.2           py38h06a4308_0  
six                       1.16.0             pyhd3eb1b0_1  
sqlite                    3.41.2               h5eee18b_0  
stack_data                0.2.0              pyhd3eb1b0_0  
tbb                       2021.8.0             hdb19cb5_0  
tk                        8.6.12               h1ccaba5_0  
torchaudio                0.7.0                      py38    pytorch
torchvision               0.8.0                 py38_cu92    pytorch
tornado                   6.3.3            py38h5eee18b_0  
traitlets                 5.7.1            py38h06a4308_0  
typing_extensions         4.9.0            py38h06a4308_1  
wcwidth                   0.2.5              pyhd3eb1b0_0  
wheel                     0.41.2           py38h06a4308_0  
xz                        5.4.6                h5eee18b_0  
zeromq                    4.3.5                h6a678d5_0  
zipp                      3.17.0           py38h06a4308_0  
zlib                      1.2.13               h5eee18b_0  
zstd                      1.4.9                haebb681_0

conda list | grep "torch" returned

pytorch                   1.7.0           py3.8_cuda9.2.148_cudnn7.6.3_0    pytorch
torchaudio                0.7.0                      py38    pytorch
torchvision               0.8.0                 py38_cu92    pytorch

python3 -c "import torch; print(torch.__version__)" returned 2.2.1+cu121

All outputs are in the same conda environment.

I can not understand why I get two different version of PyTorch(2.2.1 and 1.7.0) and two different version of CUDA toolkit (cu121 / 9.2)?

You have most likely installed another PyTorch version into your base environment, which is now conflicting with your other environments.

I uninstall all other environments.

conda info --envs

conda environments:

base * /home/user/anaconda3
tf-gpu /home/user/anaconda3/envs/tf-gpu

From my base environment I get the torch version

Python 3.8.18 (default, Sep 11 2023, 13:40:15) 
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.__version__
'2.2.1+cu121'
>>> torch.version.cuda
'12.1'

However conda list return

pytorch                   1.7.0           py3.8_cuda9.2.148_cudnn7.6.3_0    pyto
python                    3.8.18               h955ad1f_0    anaconda

My created environment tf -gpu returned

>>> import torch
>>> torch.version.cuda
'10.1'

If I used conda list in tf -gpu environment, it returns,

torchaudio                0.7.2                      py36    pytorch
torchvision               0.8.2                py36_cu101    pytorch
python                    3.6.15          hb7a2778_0_cpython    conda-forge
cudatoolkit               10.1.243             h6bb024c_0

Conda list did not return cudatoolkit version on the base environment.

I also downgraded the base the environment in CUDA 10.1. I don’t know why it is not showing?