title: Can't install GPU-enabled Pytorch in Conda environment from environment.yml
body: <p>I'm on Ubuntu 20.04 LTS with CUDA 11.1 installed (and working, with <code>PATH</code> and <code>LD_LIBRARY_PATH</code> configured correctly), and I'm trying to define a reusable conda environment (i.e., in an <code>environment.yml</code> file) that successfully installs PyTorch with CUDA support.</p>
  <p>However, when I use the environment file, I get a message that Torch wasn't compiled with CUDA support:</p>
  <pre><code>Python 3.8.10 | packaged by conda-forge | (default, May 11 2021, 07:01:05)
  [GCC 9.3.0] on linux
  Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
  &gt;&gt;&gt; import torch
  &gt;&gt;&gt; device = torch.device(&quot;cuda:0&quot;)
  &gt;&gt;&gt; t = torch.tensor(device=device, data=[0,1,2,3])
  Traceback (most recent call last):
    File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
    File &quot;/home/jdr2160/anaconda3/envs/foo/lib/python3.8/site-packages/torch/cuda/__init__.py&quot;, line 166, in _lazy_init
      raise AssertionError(&quot;Torch not compiled with CUDA enabled&quot;)
  AssertionError: Torch not compiled with CUDA enabled
  </code></pre>
  <p>My <code>environment.yml</code> is pretty bare-bones:</p>
  <pre><code>name: foo
  channels:
    - conda-forge
    - nvidia
    - pytorch
  dependencies:
    - cudatoolkit=11.1
    - python=3.8
    - pytorch
  </code></pre>
  <p>When I create an 'empty' python 3.8 environment and install the Conda packages from the command line instead of from an environment file, everything works fine:</p>
  <pre><code>$ conda env create --name bar python=3.8
  ...
  $ conda activate bar
  $ conda install pytorch cudatoolkit=11.1 -c pytorch -c nvidia
  ...
  $ python
  Python 3.8.10 | packaged by conda-forge | (default, May 11 2021, 07:01:05)
  [GCC 9.3.0] on linux
  Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
  &gt;&gt;&gt; import torch
  &gt;&gt;&gt; device = torch.device(&quot;cuda:0&quot;)
  &gt;&gt;&gt; t = torch.tensor(device=device, data=[0,1,2,3])
  &gt;&gt;&gt;
  </code></pre>
  <p>Can anyone tell what's going on here? It seems that Conda doesn't see the <code>cudatoolkit=11.1</code> dependency while installing PyTorch from the environment file, but I have no idea how to fix it.</p>