micromamba-docker icon indicating copy to clipboard operation
micromamba-docker copied to clipboard

Question: can we pass extra-url to the env.yaml?

Open LumenYoung opened this issue 1 year ago • 3 comments

Hi, thanks for this great development environment.

I would like to ask a question regarding the pip install supported in the env.yaml, this a thing because the pip and conda way of installing pytorch sometimes lead to undesired cpu version. So I use the following way to enforce a pytorch vision suitable for my need as following: pip install torch==2.1.2+cu121 torchvision==0.17.1+cu121 --extra-index-url https://download.pytorch.org/whl/cu121

In the normal micromamba, I can just use command line interface, but since micromamba way of installing only support env.yaml. I would like to ask whether I have a way to pass that to a pip field?

Something like:

name: robodiff
channels:
  - pytorch
  - nvidia
  - conda-forge
dependencies:
  - python=3.9
  - pip=22.2.2
  - pip:
    - torch==2.1.2+cu121 --extra-index-url https://download.pytorch.org/whl/cu121

I've looked at the docs and find no mention of this question, please correct me if I'm wrong. Thanks for all the help in advance!

LumenYoung avatar Mar 20 '24 09:03 LumenYoung

Hello @LumenYoung,

I was able to create your environment using this:

name: robodiff
channels:
  - pytorch
  - nvidia
  - conda-forge
dependencies:
  - python=3.9
  - pip=22.2.2
  - pip:
    - torch==2.1.2+cu121
    - --extra-index-url=https://download.pytorch.org/whl/cu121

If those are the only things going into your environment, then there is no need to have the channels pytorch and nvidia, but maybe you want them for a later step?

wholtz avatar Mar 20 '24 15:03 wholtz

Hello @LumenYoung,

I was able to create your environment using this:

name: robodiff
channels:
  - pytorch
  - nvidia
  - conda-forge
dependencies:
  - python=3.9
  - pip=22.2.2
  - pip:
    - torch==2.1.2+cu121
    - --extra-index-url=https://download.pytorch.org/whl/cu121

If those are the only things going into your environment, then there is no need to have the channels pytorch and nvidia, but maybe you want them for a later step?

Hi, thanks for the reply Will! I'm actually surprised that this works.

I was just cutting this config short to make an illustration. I'm actually very curious on how this pip field is parsed, because there are other packages that will be installed by pip, they not necessarily want to be affected by the --extra-index-url flag. Is it possible to have multiple pip field or to confine its affect field?

LumenYoung avatar Mar 20 '24 15:03 LumenYoung

When instantiating a environment from a yaml file with a - pip: section, pip will be executed only once.

You can do this:

name: robodiff
channels:
  - pytorch
  - nvidia
  - conda-forge
dependencies:
  - python=3.9
  - pip=22.2.2
  - pip:
    - https://download.pytorch.org/whl/cu121/torch-2.1.2%2Bcu121-cp39-cp39-linux_x86_64.whl

But I understand that isn't as nice, as it is specific to the CPU architecture and you must pin to an exact version.

You don't have to use a YAML file to define your environment (documentation). Or your can use a YAML file to install your conda packages and then call pip directly multiple times from within your activated conda environment.

wholtz avatar Mar 20 '24 16:03 wholtz

Closing due to lack of activity and no answered questions.

wholtz avatar Jul 05 '24 21:07 wholtz