Python 安装package 问题汇总
1. pip 命令使用国内源安装
pip install torch==1.8.1 -i https://mirrors.aliyun.com/pypi/simple/
腾讯云:https://mirrors.cloud.tencent.com/pypi/simple/
2. ChatGLM2-6B出错汇总
File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1128, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1142, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'transformers_modules.THUDM/chatglm2-6b'
解决方法:
tokenizer = AutoTokenizer.from_pretrained("THUDM\\chatglm2-6b", trust_remote_code=True) (Windows)
tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm2-6b", trust_remote_code=True) (Linux)
3. 报错 AssertionError: Torch not compiled with CUDA enabled
原因是 你试图用GPU跑,但是你安装的 Torch 不支持CUDA,是仅支持CPU的版本
先执行命令:
python -c "import torch; print(torch.cuda.is_available())"
如果返回的是False,说明安装的PyTorch不支持CUDA,是仅支持CPU的,需要执行了下面的命令安装支持cuda的版本:
pip install torch==2.0.0+cu117 torchvision==0.15.1+cu117 -f https://download.pytorch.org/whl/cu117/torch_stable.html
手动下载地址:https://download.pytorch.org/whl/torch_stable.html
5. ChatGLM2 从GPU 换成CPU,执行ChatGLM2 起码也需要16G内存,再小的话就没必要执行了;
model = AutoModel.from_pretrained("THUDM/chatglm2-6b", trust_remote_code=True).float() (CPU) , 参考: https://www.tjsky.net/tutorial/701
TaskMatrix\visual_chatgpt.py", line 1570, in <module>
txt = gr.Textbox(show_label=False, placeholder="Enter text and press enter, or upload an image").style(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Textbox' object has no attribute 'style'. Did you mean: 'scale'?
问题解决:gradio 版本太高了,所以执行: pip uninstall gradio, pip install gradio==3.39.0
或者: 最新版本的gradio 弃用了style, 修改为"user_input = gr.Textbox(show_label=False, placeholder="Input...", lines=10, container=False)"
参考内容:
1.大模型文件下载地址:https://huggingface.co/runwayml/stable-diffusion-v1-5/tree/main/unet