Using torch <=1.5.0 with CUDA 11

akskuchi: <p>I need to use torch version <code>&lt;=1.5.0</code> on a system that only has CUDA drivers <code>&gt;=11</code>.</p>
<p>Does this mean I have to follow the steps under <a href="https://github.com/pytorch/pytorch#get-the-pytorch-source" rel="noopener nofollow ugc">build from source</a>, by cloning the pytorch repo at respective version tags - e.g., <a href="https://github.com/pytorch/pytorch/tree/v1.5.0" rel="noopener nofollow ugc">1.5.0</a>?</p>
<p>P.s: I’ve looked up the discussion threads and could not find a directly related discussion. Apologies if I missed an existing FAQ-response.</p>

ptrblck: <p>You can install any 1.5.0 release with the supported CUDA version. Your CUDA driver will work as it can be newer than the CUDA runtime packages with the PyTorch binaries.</p>

akskuchi: <p>Hello, thank you for the clarification.<br>
I installed torch v1.5.0 (<a href="https://pytorch.org/get-started/previous-versions/#v150" rel="noopener nofollow ugc">cudatoolkit 10.2</a>) and checked with several CUDA/11.* drivers. However, this error kept popping up for all combinations (torch v1.5.0 [cudatoolkit 9.2 or 10.1 or 10.2]):</p>
<pre><code class="lang-auto">RuntimeError: CUDA error: CUBLAS_STATUS_EXECUTION_FAILED when calling `cublasSgemm( handle, opa, opb, m, n, k, &amp;alpha, a, lda, b, ldb, &amp;beta, c, ldc)
</code></pre>
<p>In the end, I installed the oldest torch version that is built for CUDA/11.* drivers - v1.7.1 with cudatoolkit 11.0 and managed to get it working. <img src="https://discuss.pytorch.org/images/emoji/apple/expressionless.png?v=12" title=":expressionless:" class="emoji" alt=":expressionless:" loading="lazy" width="20" height="20"></p>

ptrblck: <p>I don’t know which GPU you are using but Ampere+ requires CUDA11+ and will fail with older releases.</p>

akskuchi: <p>Aah okay! I’m using NVIDIA A100 (Ampere arch indeed).</p>
<p>So, if I’d have to use older torch versions (not built for CUDA11+), could I conclude that the only option is to <a href="https://github.com/pytorch/pytorch#get-the-pytorch-source" rel="noopener nofollow ugc">build from source</a>?</p>

ptrblck: <p>Not necessarily, since older PyTorch versions might not even support newer CUDA versions. In this case you would need to backport all needed changes enabling the desired CUDA version (if possible) to the older PyTorch release and then build from source. I’m still unsure why you won’t just install the latest stable or nightly release instead.</p>

akskuchi: <p>Okay, thank you!</p>
<p>Oh, regarding not using the latest torch: I’m currently working with a codebase (implemented in 2019 using torch v1.3.0, besides older versions of other libraries such as <code>transformers, pytorch-pretrained-bert, pytorch-ignite...</code> etc).<br>
Simply upgrading torch to the latest version resulted in a galore of errors and conflicts which might not be fixable individually. So, without changing the code or the versions of other libraries, I wanted to check if a torch version (closer to the original version) would work.</p>
<p>As mentioned, v1.7.1 with cudatoolkit 11.0 worked <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>