Check which tensors are on cpu

username: bkh6722
cooked: <p>I am using hugging face library in order to fine tune recogniton for a local dialect. Before it was working very well, but since yesterday I am becoming error:</p>
<p><code>RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument weight in method wrapper___slow_conv2d_forward)</code></p>
<p>The model is downloaded from hugging face hub and I made sure, that all input data is on cuda:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/7/4/74a8ade3c6b4078954974b3675cf755698af7f7f.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/74a8ade3c6b4078954974b3675cf755698af7f7f" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/7/4/74a8ade3c6b4078954974b3675cf755698af7f7f_2_517x367.jpeg" alt="image" data-base62-sha1="gE0Mn8DthZvxiAFVHzIuDJLCEx1" width="517" height="367" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/7/4/74a8ade3c6b4078954974b3675cf755698af7f7f_2_517x367.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/7/4/74a8ade3c6b4078954974b3675cf755698af7f7f_2_775x550.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/7/4/74a8ade3c6b4078954974b3675cf755698af7f7f_2_1034x734.jpeg 2x" data-dominant-color="FCFBFC"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1920×1364 70.7 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/f/a/fae3a2432bbf0bbcdd96b20b703abc4814cf231a.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/fae3a2432bbf0bbcdd96b20b703abc4814cf231a" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/f/a/fae3a2432bbf0bbcdd96b20b703abc4814cf231a_2_517x157.jpeg" alt="image" data-base62-sha1="zNt4onR9ZYqAQJqBjHnlio8cFKO" width="517" height="157" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/f/a/fae3a2432bbf0bbcdd96b20b703abc4814cf231a_2_517x157.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/f/a/fae3a2432bbf0bbcdd96b20b703abc4814cf231a_2_775x235.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/f/a/fae3a2432bbf0bbcdd96b20b703abc4814cf231a_2_1034x314.jpeg 2x" data-dominant-color="F2F1F2"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1552×474 113 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
From the screenshots above you may see, that input values are on cuda.</p>
<p>As a standard I also moved whole model to the cuda:</p>
<pre><code class="lang-auto">from transformers import Wav2Vec2ForCTC

model_name = "jonatasgrosman/wav2vec2-large-xlsr-53-german"

model = Wav2Vec2ForCTC.from_pretrained(model_name).cuda()
</code></pre>
<p>In case of my runtime error I’d like to know what exactly is still on cpu and how possibly could I solve that problem <img src="https://discuss.pytorch.org/images/emoji/apple/pleading_face.png?v=12" title=":pleading_face:" class="emoji" alt=":pleading_face:" loading="lazy" width="20" height="20"></p>

username: ptrblck
cooked: <p>Based on the stacktrace a conv layer seems to run into the device mismatch error.<br>
Check where the <code>.device</code> attribute of all parameters of all conv layers and make sure they are also on the device.</p>

username: bkh6722
cooked: <p>Thanks for reply. I have gave up and started following <a href="https://huggingface.co/blog/fine-tune-xlsr-wav2vec2" rel="noopener nofollow ugc">tutorial</a> again. Now it’s working perfect xD</p>