<p dir="auto">The tagline of PyTorch is:</p>
<blockquote>
<p dir="auto">PyTorch is a deep learning framework that puts Python first.</p>
</blockquote>
<p dir="auto">Pip and Pipenv are the quintessential Python package manager tools for Python...</p>
<p dir="auto">However, upon following the Pip (Python 3.6, OS X) instructions on <a href="http://pytorch.org/" rel="nofollow">http://pytorch.org/</a>, I was met with an error informing me I needed Conda. If I don't intend on using R, Fortran, etc. directly in my app, is Conda still an intrinsic requirement of projects like PyTorch that e.g., use Fortran, or could PyTorch be made to install via Pip alone?</p>
<p dir="auto">If there are low-level system requirements, I (and I think I speak for more than myself) don't mind e.g., brew installing CUDA. IOW, I'd like to be told "look, you need to install Go and CUDA to use this library", and then be given the choice of how I want to install those low-level system requirements and / or tools. Anything else could then be easily installed via e.g., Pipenv, rather than having to install some monolithic system like Conda, which is the antithesis of <code class="notranslate">Python first</code>.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import this"><pre class="notranslate"><code class="notranslate">import this
</code></pre></div>
<blockquote>
<p dir="auto">...<br>
There should be one-- and preferably only one --obvious way to do it.<br>
...<br>
If the implementation is hard to explain, it's a bad idea.<br>
...</p>
</blockquote>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/ezyang/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/ezyang">@ezyang</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/seemethere/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/seemethere">@seemethere</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/malfet/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/malfet">@malfet</a></p>
<h2 dir="auto"><g-emoji class="g-emoji" alias="bug" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f41b.png">🐛</g-emoji> Bug</h2>
<p dir="auto">Setting PyTorch default tensor type to cuda.FloatTensor on a Colab GPU instance leads pack_sequence to a Runtime error.</p>
<h2 dir="auto">To Reproduce</h2>
<p dir="auto">Steps to reproduce the behavior:</p>
<ol dir="auto">
<li><code class="notranslate">torch.set_default_tensor_type(torch.cuda.FloatTensor)</code></li>
<li><code class="notranslate">torch.nn.utils.rnn.pack_sequence([torch.tensor([1,2,3])])</code></li>
</ol>
<p dir="auto">The second statement will throw the following:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="RuntimeError                              Traceback (most recent call last)
&lt;ipython-input-7-054f3bedf067&gt; in &lt;module&gt;()
      1 torch.set_default_tensor_type(torch.cuda.FloatTensor)
----&gt; 2 torch.nn.utils.rnn.pack_sequence([torch.tensor([1,2,3])])

1 frames
/usr/local/lib/python3.6/dist-packages/torch/nn/utils/rnn.py in pack_sequence(sequences, enforce_sorted)
    377     &quot;&quot;&quot;
    378     lengths = [v.size(0) for v in sequences]
--&gt; 379     return pack_padded_sequence(pad_sequence(sequences), lengths, enforce_sorted=enforce_sorted)

/usr/local/lib/python3.6/dist-packages/torch/nn/utils/rnn.py in pack_padded_sequence(input, lengths, batch_first, enforce_sorted)
    231 
    232     data, batch_sizes = \
--&gt; 233         _VF._pack_padded_sequence(input, lengths, batch_first)
    234     return PackedSequence(data, batch_sizes, sorted_indices, None)
    235 

RuntimeError: 'lengths' argument should be a 1D CPU int64 tensor"><pre class="notranslate"><code class="notranslate">RuntimeError                              Traceback (most recent call last)
&lt;ipython-input-7-054f3bedf067&gt; in &lt;module&gt;()
      1 torch.set_default_tensor_type(torch.cuda.FloatTensor)
----&gt; 2 torch.nn.utils.rnn.pack_sequence([torch.tensor([1,2,3])])

1 frames
/usr/local/lib/python3.6/dist-packages/torch/nn/utils/rnn.py in pack_sequence(sequences, enforce_sorted)
    377     """
    378     lengths = [v.size(0) for v in sequences]
--&gt; 379     return pack_padded_sequence(pad_sequence(sequences), lengths, enforce_sorted=enforce_sorted)

/usr/local/lib/python3.6/dist-packages/torch/nn/utils/rnn.py in pack_padded_sequence(input, lengths, batch_first, enforce_sorted)
    231 
    232     data, batch_sizes = \
--&gt; 233         _VF._pack_padded_sequence(input, lengths, batch_first)
    234     return PackedSequence(data, batch_sizes, sorted_indices, None)
    235 

RuntimeError: 'lengths' argument should be a 1D CPU int64 tensor
</code></pre></div>
<h2 dir="auto">Expected behavior</h2>
<p dir="auto">Return the packed sequence without fail.</p>
<h2 dir="auto">Environment</h2>
<p dir="auto">A Colab GPU instance.</p>
<p dir="auto">PyTorch version: 1.4.0<br>
Is debug build: No<br>
CUDA used to build PyTorch: 10.1</p>
<p dir="auto">OS: Ubuntu 18.04.3 LTS<br>
GCC version: (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0<br>
CMake version: version 3.12.0</p>
<p dir="auto">Python version: 3.6<br>
Is CUDA available: Yes<br>
CUDA runtime version: 10.0.130<br>
GPU models and configuration: GPU 0: Tesla T4<br>
Nvidia driver version: 418.67<br>
cuDNN version: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.5</p>
<p dir="auto">Versions of relevant libraries:<br>
[pip3] numpy==1.17.5<br>
[pip3] torch==1.4.0<br>
[pip3] torchsummary==1.5.1<br>
[pip3] torchtext==0.3.1<br>
[pip3] torchvision==0.5.0<br>
[conda] Could not collect</p>
<h2 dir="auto">Additional context</h2>