An interesting discussion: Raising cuda environment errors after modifying the training batch

username: nobody
cooked: <p>I was training a large model using a multi-machine distribution, and it worked fine when micro-batch=4 and gradient accumulation=16. But when I changed the configuration to micro-batch=2 and gradient accumulation =32, I got the following error:<br>
<code>RuntimeError: NCCL error in: … / torch / / distributed/CSRC c10d/ProcessGroupNCCL CPP: 47, unhandled cuda error, NCCL version 21.0.3</code></p>
<p>My environment is:</p>
<pre><code class="lang-auto">Python3.8.16
Torch1.10.0 + cu111
Cuda - 11.1
Driver Version: 470.94
CUDA Version: 11.4
</code></pre>
<p>I guess it is because the original cuda method called is compatible although the cuda version does not match, but the larger gradient accumulation execution of different cuda methods, this cuda method happens to be incompatible?</p>
<p>Is that right? Can anyone familiar with the subject confirm my guess?</p>

username: ptrblck
cooked: <aside class="quote no-group" data-username="nobody" data-post="1" data-topic="181682">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/n/94ad74/48.png" class="avatar"> nobody:</div>
<blockquote>
<p>I guess it is because the original cuda method called is compatible although the cuda version does not match, but the larger gradient accumulation execution of different cuda methods, this cuda method happens to be incompatible?</p>
</blockquote>
</aside>
<p>I don’t completely understand where exactly you are seeing a mismatch and what kind of compatibility seems to be affected.<br>
In any case, I would recommend updating PyTorch to the latest stable or nightly release and to check if you would still run into the same issue.</p>

username: nobody
cooked: <p>I think Torch1.10.0 + cu111 and CUDA Version: 11.4 are incompatible.</p>
<p>But amazingly, it doesn’t report errors when micro-batch=4, gradient accumulation=16, my training has been normal, After I adjusted it to micro-batch=2 and gradient accumulation =32, it told me cuda error.</p>
<p>I’m not trying to report any bugs, because the bug has been resolved when I upgraded it to Torch1.11.0 + cu113. I just want to explore why is that?</p>

username: ptrblck
cooked: <aside class="quote no-group" data-username="nobody" data-post="3" data-topic="181682">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/n/94ad74/48.png" class="avatar"> nobody:</div>
<blockquote>
<p>I think Torch1.10.0 + cu111 and CUDA Version: 11.4 are incompatible.</p>
</blockquote>
</aside>
<p>No, that’s not that case as the locally installed CUDA toolkit won’t be used unless you build PyTorch from source or custom CUDA extensions since the PyTorch binaries ship with their own CUDA runtime dependencies.</p>

username: nobody
cooked: <p>My code does involve the cuda extension build, so do you think the environmental incompatibilities caused by modifying batch are mainly due to the cuda extension code? The built-in operations in pytorch doesn’t have like this, right?</p>

username: ptrblck
cooked: <p>This might be the case even though unexpected. You could install the matching CUDA version and see if this would fix the issue.</p>