Reputation: 795
I have used anaconda3 for a few projects recently, and every time I create a virtual environment for a project, it seems that anaconda is re-downloading the same packages (pytorch, for instance).
Have I misconfigured something or this behavior is OK?
for clerification, I am doing the Stanford CS224n course and for the assignments I use:
conda env create --file env.yml
Where env.yml is of the form:
name: local_nmt
channels:
- pytorch
- defaults
dependencies:
- python=3.5
- numpy
- scipy
- tqdm
- docopt
- pytorch
- nltk
- torchvision
I couldn't fine an explanation in the anaconda documentation. Thanks in advance!
Upvotes: 3
Views: 1637
Reputation: 76750
If only the package name or version is specified, then Conda will default to grabbing the latest versions that are consistent with constraints. Hence, any packages that have newer builds available will result in downloading.
There is an --offline
flag to only use what is available in the package cache.
However, that may not always be feasible (e.g., you've added some non-cached packages to the YAML). In that case, one could additionally specify the build (which sort of serves as a unique identifier) to correspond to the already cached versions.
Not sure the cleanest way to do that, but one approach would be to first export a YAML from your existing environments where the packages exist (e.g., conda export env > env.yaml
), and then use the specifications in there to fill in the details for the environment YAML you are trying to create.
It is likely also worth mentioning that one can also clone existing environments:
conda create --clone old_env --name new_env
Upvotes: 3