源自github用户softsweetengineer:
使用erine 快速开始中提供的代码,在windows环境下加载预训练模型出错
代码:
import numpy as np
import paddle as P
from ernie.tokenizing_ernie import ErnieTokenizer
from ernie.modeling_ernie import ErnieModel
model = ErnieModel.from_pretrained('ernie-1.0') # Try to get pretrained model from server, make sure you have network connection
model.eval()
tokenizer = ErnieTokenizer.from_pretrained('ernie-1.0')
ids, _ = tokenizer.encode('hello world')
ids = P.to_tensor(np.expand_dims(ids, 0)) # insert extra `batch` dimension
pooled, encoded = model(ids) # eager execution
print(pooled.numpy()) # convert results to numpy
打印信息:
C:\ProgramData\Anaconda3\lib\site-packages\socks.py:58: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
from collections import Callable
C:\ProgramData\Anaconda3\lib\site-packages\win32\lib\pywintypes.py:2: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp, sys, os
W0108 00:24:50.315569 18852 device_context.cc:447] Please NOTE: device: 0, GPU Compute Capability: 8.6, Driver API Version: 11.5, Runtime API Version: 11.1
W0108 00:24:50.327234 18852 device_context.cc:465] device: 0, cuDNN Version: 8.1.
Traceback (most recent call last):
File ".\topic_main.py", line 6, in
model = ErnieModel.from_pretrained('ernie-1.0') # Try to get pretrained model from server, make sure you have network connection
File "C:\ProgramData\Anaconda3\lib\site-packages\ernie\modeling_ernie.py", line 293, in from_pretrained
m = P.load(state_dict_path)
File "C:\ProgramData\Anaconda3\lib\site-packages\paddle\framework\io.py", line 928, in load
with _open_file_buffer(path, 'rb') as f:
File "C:\ProgramData\Anaconda3\lib\site-packages\paddle\fluid\io.py", line 111, in _open_file_buffer
return _buffer_reader(path_or_buffer)
File "C:\ProgramData\Anaconda3\lib\site-packages\paddle\fluid\io.py", line 86, in init
self.initial_tell = self.buffer.tell()
AttributeError: 'WindowsPath' object has no attribute 'tell'
环境:
windows 10
python3.7
paddle 2.2
源自github用户softsweetengineer:
this bug was created by erine.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
请问这个问题解决了吗?我现在还是遇到了同样的问题
登录 后才可以发表评论