Conda pulls pytorch from conda-forge channel instead of pytorch channel

gcerar: <p>Hi everyone,</p>
<p>At our research lab, we use Z2JH v2.0.0, with <code>jupyter/scipy-notebook:hub-3.0.0</code> containers. The container has Python 3.10.8 and conda 22.9.0;</p>
<p>No matter if I set strict channel order or not, conda will always pull Pytorch from conda-forge channel instead of pytorch channel. The plan suggested by conda:</p>
<pre><code class="lang-auto">  + nsight-compute           2022.4.0.15  0                         nvidia/linux-64          801MB
  + pytorch                       1.12.1  cuda112py310he33e0d6_201  conda-forge/linux-64     512MB
  + pytorch-cuda                    11.6  h867d48c_1                pytorch/noarch             3kB
</code></pre>
<p>The <code>environment.yml</code> execute with <code>conda env update -f environment.yml</code> is the following:</p>
<pre data-code-wrap="yaml"><code class="lang-plaintext">name: base

channels:
    - pytorch
    - nvidia
    - conda-forge
    - defaults
    
dependencies:
    - pytorch=1.13.1
    - pytorch-cuda=11.6
</code></pre>
<p>Installing manually with <code>mamba install pytorch==1.13.1 pytorch-cuda==11.6 -c pytorch -c nvidia -c defaults -c conda-forge</code> gives the same result.</p>
<p>The output of conda info:</p>
<pre><code class="lang-auto">jovyan@jupyter-gcerar:~$ conda info

     active environment : None
       user config file : /home/jovyan/.condarc
 populated config files : /opt/conda/.condarc
          conda version : 22.9.0
    conda-build version : not installed
         python version : 3.10.8.final.0
       virtual packages : __cuda=12.0=0
                          __linux=5.15.0=0
                          __glibc=2.35=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /opt/conda  (writable)
      conda av data dir : /opt/conda/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /opt/conda/pkgs
                          /home/jovyan/.conda/pkgs
       envs directories : /opt/conda/envs
                          /home/jovyan/.conda/envs
               platform : linux-64
             user-agent : conda/22.9.0 requests/2.28.1 CPython/3.10.8 Linux/5.15.0-58-generic ubuntu/22.04.1 glibc/2.35
                UID:GID : 1000:100
             netrc file : None
           offline mode : False
</code></pre>
<p>I’m a bit desperate at this point. Even the transition from Z2JH from 1.5 to 2.0 didn’t go without two days of downtime and backup rescue mission.</p>

gcerar: <p>Found the problem. At one point, maintainers of <code>jupyter/*-notebook</code> containers decided to switch from the anaconda to the conda-forge channel as default. The conda could not resolve dependencies with MKL and suggested conda-forge’s PyTorch compiled for CUDA toolkit v11.2.</p>
<p>The solution was to add the anaconda channel explicitly, which resolved the issue. Example:<br>
<code>mamba install pytorch=1.13.1 pytorch-cuda=11.7 -c pytorch -c nvidia -c anaconda -c conda-forge</code></p>