最近在部署一个向量模型,然后torch一直报错
(D:\Users\Administrator\anaconda3\envs\yolov8\m3e) PS D:\XiaoKong\M3e\m3e-large-api> python localembedding.py
Traceback (most recent call last):
File "D:\XiaoKong\M3e\m3e-large-api\localembedding.py", line 3, in <module>
from sentence_transformers import SentenceTransformer
File "D:\Users\Administrator\anaconda3\envs\yolov8\m3e\Lib\site-packages\sentence_transformers\__init__.py", line 3, in <module>
from .datasets import SentencesDataset, ParallelSentencesDataset
File "D:\Users\Administrator\anaconda3\envs\yolov8\m3e\Lib\site-packages\sentence_transformers\datasets\__init__.py", line 1, in <module>
from .DenoisingAutoEncoderDataset import DenoisingAutoEncoderDataset
File "D:\Users\Administrator\anaconda3\envs\yolov8\m3e\Lib\site-packages\sentence_transformers\datasets\DenoisingAutoEncoderDataset.py", line 1, in <module>
from torch.utils.data import Dataset
File "D:\Users\Administrator\anaconda3\envs\yolov8\m3e\Lib\site-packages\torch\__init__.py", line 148, in <module>
raise err
OSError: [WinError 126] 找不到指定的模块。 Error loading "D:\Users\Administrator\anaconda3\envs\yolov8\m3e\Lib\site-packages\torch\lib\fbgemm.dll" or one of its dependencies.
一开始以为是清华的torch有问题(清华源的torch跑cuda自古以来就有这个臭名昭著的问题),卸了去pytorch那边重新下一遍装了cuda121的的torch
结果发现还是报错这个东西,那么大概就不是torch的毛病了
可以来到https://github.com/lucasg/Dependencies,下载分析dll依赖的工具
下载之后,打开DependenciesGui.exe
顶部菜单 File->Open
直接把日志里的这坨路径复制进去,点打开
D:\Users\Administrator\anaconda3\envs\yolov8\m3e\Lib\site-packages\torch\lib\fbgemm.dll
然后在左侧菜单里就会看到少了libomp140.x86_64.dll这个dll(每个人不同的系统少了的东西可能不一样)
进过谷歌可以得知,这个东西的官网在https://www.dllme.com/dll/files/libomp140_x86_64
我们可以在这里下到它
获取到dll之后,将它放在和fbgemm.dll同个目录下面就行了
我这里是D:\Users\Administrator\anaconda3\envs\yolov8\m3e\Lib\site-packages\torch\lib\
重新启动
(D:\Users\Administrator\anaconda3\envs\yolov8\m3e) PS D:\XiaoKong\M3e\m3e-large-api> python localembedding.py
D:\Users\Administrator\anaconda3\envs\yolov8\m3e\Lib\site-packages\torch\cuda\__init__.py:128: UserWarning: CUDA initialization: The NVIDIA driver on your system is too old (found version 11030). Please update your GPU driver by downloading and installing a new version from the URL: http://www.nvidia.com/Download/index.aspx Alternatively, go to: https://pytorch.org to install a PyTorch version that has been compiled with your version of the CUDA driver. (Triggered internally at C:\actions-runner\_work\pytorch\pytorch\builder\windows\pytorch\c10\cuda\CUDAFunctions.cpp:108.)
return torch._C._cuda_getDeviceCount() > 0
本次加载模型的设备为CPU.
No sentence-transformers model found with name ./moka-ai_m3e-large. Creating a new one with MEAN pooling.
本次加载模型的设备为CPU.
No sentence-transformers model found with name ./moka-ai_m3e-large. Creating a new one with MEAN pooling.
INFO: Started server process [10296]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:6008 (Press CTRL+C to quit)
INFO: 127.0.0.1:56549 - "POST /v1/embeddings HTTP/1.1" 403 Forbidden
可以看到程序正常跑起来了