Reputation: 11
Can anyone please help me? I am trying to run a .py script for which I need an older pytorch version, because a function I am using is deprecated in later torch versions. But I seem not to be able to install it correctly.
I installed torch into my virtual environment using
conda create -n my_env python=3.6.2
source activate my_env
conda install pytorch==1.7.0 torchvision==0.8.0 torchaudio==0.7.0 cudatoolkit=10.2 -c pytorch
Then I have a python file (myfile.py) that I start using a shell file (start.sh). The files are on a SLURM-cluster, so I start start.sh with sbatch start.sh
.
start.sh
source activate my_env
srun --unbuffered python myfile.py
myfile.py
import torch
print(torch.__version__)
The print command from myfile.py still returns "1.8.0", but using conda list
in my environment shows "1.7.0" for pytorch version.
Even when I type python -c "import torch; print(torch.__version__)"
directly into terminal, it will return "1.8.0" (rather than "1.7.0" from conda list
)
Am I doing something very obvious wrong possibly? Did I install in a wrong way, or is somehow my environment not properly loaded in the python file?
Best regards and thanks a lot in advance
Upvotes: 0
Views: 636
Reputation: 11
It turned out that installing the environment as described added a link to another python installation to my PYTHONPATH (a link to /.local/python) and that directory was added to PYTHONPATH in a higher order than the python used in my environment (/anaconda/env/my_env/python/...) . Therefore, the local version of python was used instead.
I could not delete it from PYTHONPATH either, but changing the directory name to /.local/_python did the trick.
It's not pretty, but it works.
Thanks everyone for the contributions!
Upvotes: 1