tencent-ailab / V-Express

V-Express aims to generate a talking head video under the control of a reference image, an audio, and a sequence of V-Kps images.
2.03k stars 250 forks source link

module 'torch' has no attribute 'compiler' #24

Open zachysaur opened 1 month ago

zachysaur commented 1 month ago

(venv) D:\talkingface\V-Express>python inference.py --reference_image_path "./test_samples/short_case/10/ref.jpg" --audio_path "./test_samples/short_case/10/aud.mp3" --kps_path "./test_samples/short_case/10/kps.pth" --output_path "./output/short_case/talk_10_no_retarget.mp4" --retarget_strategy "no_retarget" --num_inference_steps 25 D:\talkingface\V-Express\venv\lib\site-packages\torchaudio\backend\utils.py:74: UserWarning: No audio backend is available. warnings.warn("No audio backend is available.") WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. xFormers was built for: PyTorch 2.3.0+cu121 with CUDA 1201 (you have 2.0.1+cpu) Python 3.10.11 (you have 3.10.9) Please reinstall xformers (see https://github.com/facebookresearch/xformers#installing-xformers) Memory-efficient attention, SwiGLU, sparse and more won't be available. Set XFORMERS_MORE_DETAILS=1 for more details Traceback (most recent call last): File "D:\talkingface\V-Express\venv\lib\site-packages\diffusers\utils\import_utils.py", line 710, in _get_module return importlib.import_module("." + module_name, self.name) File "D:\talkingface\V-Express\python\lib\importlib__init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "D:\talkingface\V-Express\venv\lib\site-packages\diffusers\models\autoencoder_kl.py", line 22, in from .attention_processor import ( File "D:\talkingface\V-Express\venv\lib\site-packages\diffusers\models\attention_processor.py", line 31, in import xformers File "D:\talkingface\V-Express\venv\lib\site-packages\xformers\init__.py", line 12, in from .checkpoint import ( # noqa: E402, F401 File "D:\talkingface\V-Express\venv\lib\site-packages\xformers\checkpoint.py", line 464, in class SelectiveCheckpointWrapper(ActivationWrapper): File "D:\talkingface\V-Express\venv\lib\site-packages\xformers\checkpoint.py", line 481, in SelectiveCheckpointWrapper @torch.compiler.disable AttributeError: module 'torch' has no attribute 'compiler'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "D:\talkingface\V-Express\inference.py", line 10, in from diffusers import AutoencoderKL, DDIMScheduler File "", line 1075, in _handle_fromlist File "D:\talkingface\V-Express\venv\lib\site-packages\diffusers\utils\import_utils.py", line 701, in getattr value = getattr(module, name) File "D:\talkingface\V-Express\venv\lib\site-packages\diffusers\utils\import_utils.py", line 700, in getattr module = self._get_module(self._class_to_module[name]) File "D:\talkingface\V-Express\venv\lib\site-packages\diffusers\utils\import_utils.py", line 712, in _get_module raise RuntimeError( RuntimeError: Failed to import diffusers.models.autoencoder_kl because of the following error (look up to see its traceback): module 'torch' has no attribute 'compiler'

tiankuan93 commented 1 month ago

It looks like an incompatibility between your xformer and the torch version is causing the problem. You can try not using xformer by commenting out a few lines of inference.py.

image
zachysaur commented 1 month ago

(venv) D:\talkingface\V-Express>python inference.py --reference_image_path "./test_samples/short_case/tys/ref.jpg" --audio_path "./test_samples/short_case/tys/aud.mp3" --output_path "./output/short_case/talk_tys_fix_face.mp4" --retarget_strategy "fix_face" --num_inference_steps 25 D:\talkingface\V-Express\venv\lib\site-packages\torchaudio\backend\utils.py:74: UserWarning: No audio backend is available. warnings.warn("No audio backend is available.") Traceback (most recent call last): File "D:\talkingface\V-Express\inference.py", line 275, in main() File "D:\talkingface\V-Express\inference.py", line 141, in main vae = AutoencoderKL.from_pretrained(vae_path).to(dtype=dtype, device=device) File "D:\talkingface\V-Express\venv\lib\site-packages\torch\nn\modules\module.py", line 1145, in to return self._apply(convert) File "D:\talkingface\V-Express\venv\lib\site-packages\torch\nn\modules\module.py", line 797, in _apply module._apply(fn) File "D:\talkingface\V-Express\venv\lib\site-packages\torch\nn\modules\module.py", line 797, in _apply module._apply(fn) File "D:\talkingface\V-Express\venv\lib\site-packages\torch\nn\modules\module.py", line 820, in _apply param_applied = fn(param) File "D:\talkingface\V-Express\venv\lib\site-packages\torch\nn\modules\module.py", line 1143, in convert return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking) File "D:\talkingface\V-Express\venv\lib\site-packages\torch\cuda__init__.py", line 239, in _lazy_init raise AssertionError("Torch not compiled with CUDA enabled") AssertionError: Torch not compiled with CUDA enabled

(venv) D:\talkingface\V-Express>

tiankuan93 commented 1 month ago

I see in your previous log there is a line (you have 2.0.1+cpu). I think you don't have the gpu version of torch installed. you can try to set the device to cpu, as follows.

python inference.py \
    --reference_image_path "./test_samples/short_case/AOC/ref.jpg" \
    --audio_path "./test_samples/short_case/AOC/chattts.mp3" \
    --output_path "./output/short_case/talk_AOC_chattts_fix_face.mp4" \
    --retarget_strategy "fix_face" \
    --num_inference_steps 25 \
    --device "cpu"
zachysaur commented 1 month ago

i followed your instructions about pip install packages for cuda how i can install?

zachysaur commented 1 month ago

(venv) D:\talkingface\V-Express>python inference.py --reference_image_path "./test_samples/short_case/tys/ref.jpg" --audio_path "./test_samples/short_case/tys/aud.mp3" --output_path "./output/short_case/talk_tys_fix_face.mp4" --retarget_strategy "fix_face" --num_inference_steps 25 --device "cpu" Some weights of the model checkpoint at ./model_ckpts/wav2vec2-base-960h/ were not used when initializing Wav2Vec2Model: ['lm_head.bias', 'lm_head.weight']

(venv) D:\talkingface\V-Express>

tiankuan93 commented 1 month ago
  1. I'm not sure if your machine has a GPU, if it does you need to install the GPU version of the torch.
  2. Under cpu, you also have to set the dtype to fp32. Add --dtype fp32. Mind you, the CPU will be running very, very slow.
zachysaur commented 1 month ago

atleast it will work then i will know only thing i need is pytorch not torch

zachysaur commented 1 month ago

what is gpu version of torch?

zachysaur commented 1 month ago

(venv) D:\Talking Pictures\V-Express>python inference.py --reference_image_path "./test_samples/short_case/10/ref.jpg" --audio_path "./test_samples/short_case/10/aud.mp3" --output_path "./output/short_case/talk_AOC_chattts_fix_face.mp4" --retarget_strategy "fix_face" --num_inference_steps 25 --device "cpu" --dtype fp32 D:\Talking Pictures\V-Express\venv\lib\site-packages\torchaudio\backend\utils.py:74: UserWarning: No audio backend is available. warnings.warn("No audio backend is available.") WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. xFormers was built for: PyTorch 2.0.1+cu118 with CUDA 1108 (you have 2.0.1+cpu) Python 3.10.11 (you have 3.10.11) Please reinstall xformers (see https://github.com/facebookresearch/xformers#installing-xformers) Memory-efficient attention, SwiGLU, sparse and more won't be available. Set XFORMERS_MORE_DETAILS=1 for more details Some weights of the model checkpoint at ./model_ckpts/wav2vec2-base-960h/ were not used when initializing Wav2Vec2Model: ['lm_head.bias', 'lm_head.weight']

(venv) D:\Talking Pictures\V-Express>

FurkanGozukara commented 1 month ago

i made a full tutorial if you still couldn't make

works with python 3.10, cuda 11.8, venv

https://github.com/tencent-ailab/V-Express/issues/27

tiankuan93 commented 1 month ago

what is gpu version of torch?

You can find information about it at here.

image
nitinmukesh commented 4 weeks ago

@zachysaur

Here is completely free tutorial for Windows https://youtu.be/OFt6a2rR8GY

Let me know if you are still facing the issues