Help installing 1.3

Chris_Palmer: <p>I am trying to install the latest Pytorch using the conda installation on my Windows 10 machine. I get the following error - can anyone help me understand what I should do to fix this? I have previously installed cuda 10.1 and it’s in the PATH, but I do have other versions of CUDA available in my NVIDIA GPU Computing Toolkit\CUDA folder.</p>
<pre><code class="lang-auto">conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
Collecting package metadata (current_repodata.json): done
Solving environment: failed
Collecting package metadata (repodata.json): done
Solving environment: failed

UnsatisfiableError: The following specifications were found to be incompatible with each other:

  - conda-forge/noarch::bleach==3.1.0=py_0
  - conda-forge/noarch::nbconvert==5.5.0=py_0 -&gt; bleach
  - conda-forge/win-64::arrow-cpp==0.14.0=py36h1b0c03e_0 -&gt; boost-cpp[version='&gt;=1.70.0,&lt;1.70.1.0a0'] -&gt; libboost[version='&lt;0']
  - conda-forge/win-64::astroid==2.2.5=py36_0 -&gt; wrapt
  - conda-forge/win-64::boost-cpp==1.70.0=h6a4c333_0 -&gt; libboost[version='&lt;0']
  - conda-forge/win-64::bzip2==1.0.6=hfa6e2cd_1002
  - conda-forge/win-64::conda-package-handling==1.3.10=py36_0 -&gt; libarchive[version='&gt;=3.3.3'] -&gt; bzip2[version='&gt;=1.0.8,&lt;2.0a0']
  - conda-forge/win-64::libarchive==3.3.3=h4890af2_1005 -&gt; bzip2[version='&gt;=1.0.6,&lt;2.0a0']
  - conda-forge/win-64::libkml==1.3.0=h4ece8bf_1010 -&gt; boost-cpp[version='&gt;=1.70.0,&lt;1.70.1.0a0'] -&gt; libboost[version='&lt;0']
  - conda-forge/win-64::libnetcdf==4.6.2=h396784b_1001 -&gt; bzip2[version='&gt;=1.0.6,&lt;2.0a0']
  - conda-forge/win-64::pyarrow==0.14.0=py36h803c963_0 -&gt; arrow-cpp[version='&gt;=0.14.0,&lt;0.15.0a0,&gt;=0.14.0,&lt;1.0a0'] -&gt; boost-cpp[version='&gt;=1.70.0,&lt;1.70.1.0a0'] -&gt; libboost[version='&lt;0']
  - conda-forge/win-64::pyarrow==0.14.0=py36h803c963_0 -&gt; arrow-cpp[version='&gt;=0.14.0,&lt;0.15.0a0,&gt;=0.14.0,&lt;1.0a0'] -&gt; bzip2[version='&gt;=1.0.8,&lt;2.0a0']
  - conda-forge/win-64::pylint==2.3.1=py36_0 -&gt; astroid[version='&gt;=2.2.0'] -&gt; wrapt
  - conda-forge/win-64::python-libarchive-c==2.8=py36_1004 -&gt; libarchive -&gt; bzip2[version='&gt;=1.0.8,&lt;2.0a0']
  - conda-forge/win-64::spyder==3.3.5=py36_0 -&gt; pylint -&gt; astroid[version='&gt;=2.3.0,&lt;2.4'] -&gt; wrapt
  - conda-forge/win-64::thrift-cpp==0.12.0=hd042d19_1004 -&gt; boost-cpp[version='&gt;=1.70.0,&lt;1.70.1.0a0'] -&gt; libboost[version='&lt;0']
  - conda-forge/win-64::wrapt==1.11.2=py36hfa6e2cd_0
  - cudatoolkit=10.1
  - cudnn -&gt; cudatoolkit=9.0
  - cupy -&gt; cudatoolkit=9.0
</code></pre>
<p>I also tried with CUDA 9.2 compatibility - but the same sort of thing happens:</p>
<pre><code class="lang-auto">conda install pytorch torchvision cudatoolkit=9.2 -c pytorch -c defaults -c numba/label/dev
Collecting package metadata (current_repodata.json): done
Solving environment: failed
Collecting package metadata (repodata.json): done
Solving environment: failed

UnsatisfiableError: The following specifications were found to be incompatible with each other:

  - conda-forge/noarch::bleach==3.1.0=py_0
  - conda-forge/noarch::nbconvert==5.5.0=py_0 -&gt; bleach
  - conda-forge/win-64::arrow-cpp==0.14.0=py36h1b0c03e_0 -&gt; boost-cpp[version='&gt;=1.70.0,&lt;1.70.1.0a0'] -&gt; libboost[version='&lt;0']
  - conda-forge/win-64::astroid==2.2.5=py36_0 -&gt; wrapt
  - conda-forge/win-64::boost-cpp==1.70.0=h6a4c333_0 -&gt; libboost[version='&lt;0']
  - conda-forge/win-64::bzip2==1.0.6=hfa6e2cd_1002
  - conda-forge/win-64::conda-package-handling==1.3.10=py36_0 -&gt; libarchive[version='&gt;=3.3.3'] -&gt; bzip2[version='&gt;=1.0.8,&lt;2.0a0']
  - conda-forge/win-64::libarchive==3.3.3=h4890af2_1005 -&gt; bzip2[version='&gt;=1.0.6,&lt;2.0a0']
  - conda-forge/win-64::libkml==1.3.0=h4ece8bf_1010 -&gt; boost-cpp[version='&gt;=1.70.0,&lt;1.70.1.0a0'] -&gt; libboost[version='&lt;0']
  - conda-forge/win-64::libnetcdf==4.6.2=h396784b_1001 -&gt; bzip2[version='&gt;=1.0.6,&lt;2.0a0']
  - conda-forge/win-64::pyarrow==0.14.0=py36h803c963_0 -&gt; arrow-cpp[version='&gt;=0.14.0,&lt;0.15.0a0,&gt;=0.14.0,&lt;1.0a0'] -&gt; boost-cpp[version='&gt;=1.70.0,&lt;1.70.1.0a0'] -&gt; libboost[version='&lt;0']
  - conda-forge/win-64::pyarrow==0.14.0=py36h803c963_0 -&gt; arrow-cpp[version='&gt;=0.14.0,&lt;0.15.0a0,&gt;=0.14.0,&lt;1.0a0'] -&gt; bzip2[version='&gt;=1.0.8,&lt;2.0a0']
  - conda-forge/win-64::pylint==2.3.1=py36_0 -&gt; astroid[version='&gt;=2.2.0'] -&gt; wrapt
  - conda-forge/win-64::python-libarchive-c==2.8=py36_1004 -&gt; libarchive -&gt; bzip2[version='&gt;=1.0.8,&lt;2.0a0']
  - conda-forge/win-64::spyder==3.3.5=py36_0 -&gt; pylint -&gt; astroid[version='&gt;=2.3.0,&lt;2.4'] -&gt; wrapt
  - conda-forge/win-64::thrift-cpp==0.12.0=hd042d19_1004 -&gt; boost-cpp[version='&gt;=1.70.0,&lt;1.70.1.0a0'] -&gt; libboost[version='&lt;0']
  - conda-forge/win-64::wrapt==1.11.2=py36hfa6e2cd_0
  - cudatoolkit=9.2
  - cudnn -&gt; cudatoolkit[version='&gt;=9.0,&lt;9.1']
  - cupy -&gt; cudatoolkit[version='&gt;=9.0,&lt;9.1.0a0']
</code></pre>

albanD: <p>cc <a class="mention" href="/u/smth">@smth</a> maybe you know where this comes from?</p>

Chris_Palmer: <p>I suspect I just have too much going on in this environment, and can of course start from scratch with a new one, but this is something I would like to solve without having to do that, if possible…</p>

albanD: <p>Just with respect to cuda, it seems that cudnn and cupy require cuda 9.0 and so you cannot install the newer versions. Maybe you want to remove these.</p>

Chris_Palmer: <p>Hmm… tried uninstalling CUDNN and see now inconsistencies re other packages. Should I remove these first?</p>
<pre><code class="lang-auto">conda uninstall cudnn
Collecting package metadata (repodata.json): done
Solving environment: \
The environment is inconsistent, please check the package plan carefully
The following packages are causing the inconsistency:

  - conda-forge/noarch::tensorboardx==1.6=py_0
  - conda-forge/win-64::tensorflow-estimator==1.13.0=py36h39e3cac_0
  - conda-forge/win-64::tensorflow==1.13.1=py36h21ff451_1
  - defaults/win-64::tensorflow-gpu==1.13.1=h0d30ee6_0
  - conda-forge/noarch::tensorflow-hub==0.6.0=pyhe1b5a44_0
  - anaconda/win-64::keras-gpu==2.2.4=0
</code></pre>
<p>The main reason I want to stick with this (base) environment is to keep using Open AI Gym with Pytorch, which was an ordeal to install under Windows 10. I suspect that some of these dependencies are due to the installation of Gym.</p>
<p>More on my Conda environment - BTW I have not updated conda as the latest version on another PC completely screwed up my conda so I am reluctant to have to start again from scratch should it happen here…:</p>
<pre><code class="lang-auto">     active environment : base
    active env location : G:\Anaconda3
            shell level : 1
       user config file : C:\Users\User\.condarc
 populated config files : C:\Users\User\.condarc
          conda version : 4.7.5
    conda-build version : 3.18.6
         python version : 3.6.6.final.0
       virtual packages : __cuda=10.1
       base environment : G:\Anaconda3  (writable)
           channel URLs : https://conda.anaconda.org/conda-forge/win-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://conda.anaconda.org/ostrokach-forge/win-64
                          https://conda.anaconda.org/ostrokach-forge/noarch
                          https://conda.anaconda.org/anaconda-fusion/win-64
                          https://conda.anaconda.org/anaconda-fusion/noarch
                          https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : G:\Anaconda3\pkgs
                          C:\Users\User\.conda\pkgs
                          C:\Users\User\AppData\Local\conda\conda\pkgs
       envs directories : G:\Anaconda3\envs
                          C:\Users\User\.conda\envs
                          C:\Users\User\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.7.5 requests/2.22.0 CPython/3.6.6 Windows/10 Windows/10.0.17134
          administrator : False
             netrc file : None
           offline mode : False
</code></pre>

albanD: <p>I don’t usually use conda or windows so I’m not sure how to help you here <img src="https://discuss.pytorch.org/images/emoji/apple/confused.png?v=9" title=":confused:" class="emoji" alt=":confused:"><br>
I can’t see the inconsistency in the new package list this time. But tensorflow/keras install seems to be problematic.</p>

Chris_Palmer: <p>Thanks for looking anyway <a class="mention" href="/u/alband">@albanD</a> - I appreciate it. I looks like I will need to stay with my current Pytorch 1.1 in order to keep compatibility with the requirements / dependencies of Open AI Gym, Unity Agents etc. that I am using for the Udacity Deep Reinforcement Learning Nanodegree.</p>
<p>One of the reasons I was wanting to upgrade to 1.3 was that I am encountering what might be a bug in using nn.SELU (showing up in functional.py). Perhaps you could help me to fix this without having to upgrade - is it a bug or something wrong with how I’m using SELU?</p>
<pre><code class="lang-auto">G:\Anaconda3\lib\site-packages\torch\nn\modules\linear.py in forward(self, input)
     90     @weak_script_method
     91     def forward(self, input):
---&gt; 92         return F.linear(input, self.weight, self.bias)
     93 
     94     def extra_repr(self):

G:\Anaconda3\lib\site-packages\torch\nn\functional.py in linear(input, weight, bias)
   1402         - Output: :math:`(N, *, out\_features)`
   1403     """
-&gt; 1404     if input.dim() == 2 and bias is not None:
   1405         # fused op is marginally faster
   1406         ret = torch.addmm(bias, input, weight.t())

G:\Anaconda3\lib\site-packages\torch\nn\modules\module.py in __getattr__(self, name)
    537                 return modules[name]
    538         raise AttributeError("'{}' object has no attribute '{}'".format(
--&gt; 539             type(self).__name__, name))
    540 
    541     def __setattr__(self, name, value):

AttributeError: 'SELU' object has no attribute 'dim'
</code></pre>

albanD: <p>This error is weird. Are you use you dont try and forward a module into another?the input to your linear here seems to be a SELU layer .</p>

Chris_Palmer: <p>Hi <a class="mention" href="/u/alband">@albanD</a>. Sorry, I don’t understand your question. Can you ask another way?</p>

Chris_Palmer: <p>My forward function…</p>
<p><img src="https://discuss.pytorch.org/uploads/default/original/3X/6/b/6b81959905744f7dce758258cb496b68c6d2af16.png" alt="image" data-base62-sha1="fl2INwMUHZLU5FleEVJEUrnmSN0" width="572" height="160"></p>

albanD: <p>Exactly. nn.Module are first created, then forwarded by calling them.<br>
x here contains an nn.Module, not the output of the SELU <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>

Chris_Palmer: <p>Hmmm. The commented code uses relu, and it worked. I was trying to substitute instead SELU. They look to me to be the same syntax but that doesn’t work with SELU? Can you please rewrite this the way that would work? Should I use it from the functional module rather than from nn?</p>
<pre><code class="lang-auto">    def forward(self, state):
        """Build an actor (policy) network that maps states -&gt; actions."""
        # x = F.relu(self.bn1(self.fc1(state)))
        # x = F.relu(self.fc2(x))
        x = nn.SELU(self.bn1(self.fc1(state)))
        x = nn.SELU(self.fc2(x))
        return torch.tanh(self.fc3(x))
</code></pre>

albanD: <p>Functions from the functional module (called F in your example) are functions (hence the module name)<br>
The other elements in nn are Modules. So you need to first create an instance of it: <code>self.my_selu_instance = nn.SELU(inplace=False)</code> and then you can use it <code>x = self.my_selu_instance(self.fc2(x))</code>.</p>
<p>So the updated code would be:</p>
<pre><code class="lang-auto">    def forward(self, state):
        """Build an actor (policy) network that maps states -&gt; actions."""
        # x = F.relu(self.bn1(self.fc1(state)))
        # x = F.relu(self.fc2(x))
        x = nn.SELU()(self.bn1(self.fc1(state)))
        x = nn.SELU()(self.fc2(x))
        return torch.tanh(self.fc3(x))
</code></pre>
<p>Or even nicer:</p>
<pre><code class="lang-auto">    def __init__():
        # Original code
        self.selu = nn.SELU()

    def forward(self, state):
        """Build an actor (policy) network that maps states -&gt; actions."""
        # x = F.relu(self.bn1(self.fc1(state)))
        # x = F.relu(self.fc2(x))
        x = self.selu(self.bn1(self.fc1(state)))
        x = self.selu(self.fc2(x))
        return torch.tanh(self.fc3(x))
</code></pre>

Chris_Palmer: <p>Oh, I see - that’s a really elementary mistake of mine. I have been used to using the functional module for activation functions and hadn’t realized the difference between using F and nn. But of course it makes sense now - I don’t use any other instances of nn objects in my code as if they were function calls!</p>
<p>Is there any “best practice” around the use of nn rather than F?</p>
<p>Really appreciate your help!</p>

albanD: <p>nn vs F is really a matter of personal preference. We actually provide both because some people really prefer the Module version to be able to put things in <code>nn.Sequential()</code>s, other prefer writing the forward fully by hand with a functional interface.</p>

Chris_Palmer: <p>OK, thanks - I am very grateful for your attention to this!</p>

Chris_Palmer: <p>Another thing I wanted to use from 1.3 was AdamW - is there any way I can get that working from within 1.1?</p>

albanD: <p>The implementation in master seems self contained. You should be able to copy/paste <a href="https://github.com/pytorch/pytorch/blob/86e7e872bfdf5e884afaae8ef31d164a1c6c0733/torch/optim/adamw.py" rel="nofollow noopener">this file</a> and chang the import of Optimizer to <code>from torch.optim import Optimizer</code>. That will most likely work <img src="https://discuss.pytorch.org/images/emoji/apple/smiley.png?v=9" title=":smiley:" class="emoji" alt=":smiley:"></p>

Chris_Palmer: <p>Awesome - by importing from torch.optim I am effectively chaining this to the end of everything we have avaliable in torch.optim?</p>

dejanbatanjac: <p>Hi, <a href="https://discuss.pytorch.org/u/Chris_Palmer">Chris_Palmer</a>,</p>
<p>What <a class="mention" href="/u/alband">@albanD</a> wanted to point is to <a href="https://github.com/pytorch/pytorch/blob/86e7e872bfdf5e884afaae8ef31d164a1c6c0733/torch/optim/adamw.py" rel="nofollow noopener">copy</a> the AdamW optimizer since it is just a single PyTorch file.</p>
<p>You can create your own optimizers in PyTorch with no C++ hassle inside.<br>
And the point is you don’t need to migrate to PyTorch 1.3 if you only wanted to use AdamW.</p>
<p>BTW, based on your line:</p>
<pre><code class="lang-auto">conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
</code></pre>
<p>I installed PyTorch 1.3.0 using Conda on Windows and it just works fine. Thank you so much.</p>