#8674 Qwen3-TTS(Built-in): Expected all tensors to be on the same device, but found at least two devices, cuda:2 and cuda:0!,T

31.175**5 Posted at: 2 hours ago

Qwen3-TTS(Built-in): Expected all tensors to be on the same device, but found at least two devices, cuda:2 and cuda:0!,Traceback (most recent call last):
File "videotrans\process\qwen_tts.py", line 91, in qwen3tts_fun
File "D:\AI\win-pyvideotrans\_internal\torch\utils\_contextlib.py", line 116, in decorate_context

return func(*args, **kwargs)

File "qwen_tts\inference\qwen3_tts_model.py", line 829, in generate_custom_voice

talker_codes_list, _ = self.model.generate(

File "D:\AI\win-pyvideotrans\_internal\torch\utils\_contextlib.py", line 116, in decorate_context

return func(*args, **kwargs)

File "qwen_tts\core\models\modeling_qwen3_tts.py", line 2272, in generate

talker_result = self.talker.generate(

File "D:\AI\win-pyvideotrans\_internal\torch\utils\_contextlib.py", line 116, in decorate_context

return func(*args, **kwargs)

File "D:\AI\win-pyvideotrans\_internal\transformers4576\generation\utils.py", line 2566, in generate

result = dec

......
nsformers4576\generation\utils.py", line 2786, in _sample

outputs = self(**model_inputs, return_dict=True)

File "D:\AI\win-pyvideotrans\_internal\torch\nn\modules\module.py", line 1751, in _wrapped_call_impl

return self._call_impl(*args, **kwargs)

File "D:\AI\win-pyvideotrans\_internal\torch\nn\modules\module.py", line 1762, in _call_impl

return forward_call(*args, **kwargs)

File "D:\AI\win-pyvideotrans\_internal\transformers4576\utils\generic.py", line 918, in wrapper

output = func(self, *args, **kwargs)

File "qwen_tts\core\models\modeling_qwen3_tts.py", line 1713, in forward

outputs: BaseModelOutputWithPast = self.model(

File "D:\AI\win-pyvideotrans\_internal\torch\nn\modules\module.py", line 1751, in _wrapped_call_impl

return self._call_impl(*args, **kwargs)

File "D:\AI\win-pyvideotrans\_internal\torch\nn\modules\module.py", line 1762, in _call_impl

return forward_call(*args, **kwargs)

File "D:\AI\win-pyvideotrans\_internal\transformers4576\utils\generic.py", line 918, in wrapper

output = func(self, *args, **kwargs)

File "qwen_tts\core\models\modeling_qwen3_tts.py", line 1533, in forward

layer_outputs = decoder_layer(

File "D:\AI\win-pyvideotrans\_internal\transformers4576\modeling_layers.py", line 94, in call

return super().__call__(*args, **kwargs)

File "D:\AI\win-pyvideotrans\_internal\torch\nn\modules\module.py", line 1751, in _wrapped_call_impl

return self._call_impl(*args, **kwargs)

File "D:\AI\win-pyvideotrans\_internal\torch\nn\modules\module.py", line 1762, in _call_impl

return forward_call(*args, **kwargs)

File "qwen_tts\core\models\modeling_qwen3_tts.py", line 1409, in forward

hidden_states = residual + hidden_states

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:2 and cuda:0!


=
system:Windows-10-10.0.26300-SP0
version:v4.17
frozen:True
language:en_US
root_dir:D:/AI/win-pyvideotrans

1 Replies

#1 DeepSeek reply at 2 hours ago

This is a PyTorch multi-GPU device mismatch: Qwen3-TTS loads its model on cuda:0, but part of the tensors/submodules are created on cuda:2, so the forward pass fails at residual + hidden_states. It occurs even when only previewing a voice (ListenVoice), so it is not a problem with the text or the voice you chose — it is caused by how the GPU is assigned in a multi-GPU environment.

Handling steps:

  1. Menu → Tools/Options → Advanced Options → General Settings, set Max Concurrent GPU Tasks [Restart Required] to 1, save, then restart the software.
  2. In the same panel, check Force Compute Device for Heavy Tasks: if it points to a different card from the one the model is actually loaded on, the mismatch appears. Do not leave it as an arbitrary value; set it to a single specific GPU (preferably the card with the most free VRAM), save and restart.
  3. If a clone voice is used, make sure Advanced Options → Speech Recognition (ASR) → Min Speech Duration (ms) is ≥ 3000, that the reference audio is 3–10 s long, and that there is enough free VRAM (Qwen3-TTS fails with device/OOM errors when VRAM is tight). You may also enable Enable 8-bit Quantization for Qwen3-TTS in General Settings to reduce VRAM usage.
  4. If you only need one GPU for this task, limit the visible device before starting sp.exe (e.g. set CUDA_VISIBLE_DEVICES=0), so all tensors stay on one device, then start the software again.
  5. Upgrade to the latest version (v4.18 is current; you are on v4.17) — several Qwen3-TTS fixes are included in v4.16–v4.18.

If the error still occurs after steps 1–5, the exact cause cannot be determined from the current information. Please provide the last ~30 lines of the newest log file in the logs/ folder under D:/AI/win-pyvideotrans, together with your GPU model, GPU count and VRAM, so it can be analyzed.

Please refer to the related documentation:

Thinking...
Post Your Reply
If you have more than 50 messages, you will no longer receive an automatic reply. Please ask a new question!
Open source and free maintenance is not easy. If this project is helpful to you, please consider making a small donation to help the project continue to maintain and update.

Dondate via ko-fi.com

Related resource