ModuleNotFoundError: No module named 'torchvision.transforms.functional_tensor'
Sumail2020 opened this issue · comments
System Info / 系統信息
transformers 4.42.3
xformers 0.0.27
torch 2.3.1+cu121
torchaudio 2.3.1
torchvision 0.18.1
(CogVLM2-video) ➜ ~/Workspace/LargeLanguageModelProject/LLMprojects/CogVLM2-video/CogVLM2/video_demo git:(main) ✗ CUDA_VISIBLE_DEVICES=0 python cli_vedeo_demo.py
python: can't open file '/home/sumail/Workspace/LargeLanguageModelProject/LLMprojects/CogVLM2-video/CogVLM2/video_demo/cli_vedeo_demo.py': [Errno 2] No such file or directory
(CogVLM2-video) ➜ ~/Workspace/LargeLanguageModelProject/LLMprojects/CogVLM2-video/CogVLM2/video_demo git:(main) ✗ CUDA_VISIBLE_DEVICES=0 python cli_video_demo.py
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
GPU memory is less than 48GB. Please use cli_demo_multi_gpus.py or pass --quant 4
or --quant 8
.
(CogVLM2-video) ➜ ~/Workspace/LargeLanguageModelProject/LLMprojects/CogVLM2-video/CogVLM2/video_demo git:(main) ✗ CUDA_VISIBLE_DEVICES=0 python cli_video_demo.py --quant 4
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
/home/sumail/anaconda3/envs/CogVLM2-video/lib/python3.10/site-packages/torchvision/transforms/_functional_video.py:6: UserWarning: The 'torchvision.transforms._functional_video' module is deprecated since 0.12 and will be removed in the future. Please use the 'torchvision.transforms.functional' module instead.
warnings.warn(
/home/sumail/anaconda3/envs/CogVLM2-video/lib/python3.10/site-packages/torchvision/transforms/_transforms_video.py:22: UserWarning: The 'torchvision.transforms._transforms_video' module is deprecated since 0.12 and will be removed in the future. Please use the 'torchvision.transforms' module instead.
warnings.warn(
Traceback (most recent call last):
File "/home/sumail/Workspace/LargeLanguageModelProject/LLMprojects/CogVLM2-video/CogVLM2/video_demo/cli_video_demo.py", line 71, in
model = AutoModelForCausalLM.from_pretrained(
File "/home/sumail/anaconda3/envs/CogVLM2-video/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py", line 551, in from_pretrained
model_class = get_class_from_dynamic_module(
File "/home/sumail/anaconda3/envs/CogVLM2-video/lib/python3.10/site-packages/transformers/dynamic_module_utils.py", line 514, in get_class_from_dynamic_module
return get_class_in_module(class_name, final_module)
File "/home/sumail/anaconda3/envs/CogVLM2-video/lib/python3.10/site-packages/transformers/dynamic_module_utils.py", line 212, in get_class_in_module
module_spec.loader.exec_module(module)
File "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "/home/sumail/.cache/huggingface/modules/transformers_modules/modeling_cogvlm.py", line 24, in
from pytorchvideo.transforms import ApplyTransformToKey, ShortSideScale
File "/home/sumail/anaconda3/envs/CogVLM2-video/lib/python3.10/site-packages/pytorchvideo/transforms/init.py", line 3, in
from .augmix import AugMix # noqa
File "/home/sumail/anaconda3/envs/CogVLM2-video/lib/python3.10/site-packages/pytorchvideo/transforms/augmix.py", line 6, in
from pytorchvideo.transforms.augmentations import (
File "/home/sumail/anaconda3/envs/CogVLM2-video/lib/python3.10/site-packages/pytorchvideo/transforms/augmentations.py", line 9, in
import torchvision.transforms.functional_tensor as F_t
ModuleNotFoundError: No module named 'torchvision.transforms.functional_tensor'
Who can help? / 谁可以帮助到您?
No response
Information / 问题信息
- The official example scripts / 官方的示例脚本
- My own modified scripts / 我自己修改的脚本和任务
Reproduction / 复现过程
1.cd video_demo
2. CUDA_VISIBLE_DEVICES=0 python cli_video_demo.py --quant 4
Expected behavior / 期待表现
期待video程序正常运行
functional_tensor 这个应该是pytorchvideo引用的torchvision更新了,你google一下这个解决方案,这个错误事torchvision的,确实不在这个项目内能解决
functional_tensor 这个应该是pytorchvideo引用的torchvision更新了,你google一下这个解决方案,这个错误事torchvision的,确实不在这个项目内能解决
已解决,把augmentations.py文件中的import torchvision.transforms.functional_tensor as F_t 替换成 import torchvision.transforms.functional as F_t 就能正常运行了。
(其中,augmentations.py在这个路径下,File "/home/sumail/anaconda3/envs/CogVLM2-video/lib/python3.10/site-packages/pytorchvideo/transforms/augmentations.py", line 9, in
import torchvision.transforms.functional_tensor as F_t)
This issue can be solved by
poetry add git+https://github.com/facebookresearch/pytorchvideo.git
referred from facebookresearch/pytorchvideo#251