gpt4 book ai didi

python - 将 GPU 与 python 包 bert_embeddings 和 mxnet 一起使用失败

转载 作者:行者123 更新时间:2023-12-01 07:46:23 26 4
gpt4 key购买 nike

我使用下面的代码来启用 GPU,使用 mxnet 包来使用 bert_embeddings 包提取 Bert 嵌入:

from bert_embedding import BertEmbedding
import mxnet as mx
ctx = mx.gpu()

bert_embedding = BertEmbedding(ctx=ctx)

结果错误如下:

MXNetError: [13:51:52] src/ndarray/ndarray.cc:1280: GPU is not enabled
Stack trace:
[bt] (0) /user/anaconda3/lib/python3.7/site-packages/mxnet/libmxnet.so(+0x259c2b) [0x7fbf015d3c2b]
[bt] (1) /user/anaconda3/lib/python3.7/site-packages/mxnet/libmxnet.so(mxnet::CopyFromTo(mxnet::NDArray const&, mxnet::NDArray const&, int, bool)+0x6db) [0x7fbf0395234b]
[bt] (2) /user/anaconda3/lib/python3.7/site-packages/mxnet/libmxnet.so(mxnet::imperative::PushFComputeEx(std::function<void (nnvm::NodeAttrs const&, mxnet::OpContext const&, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> > const&, std::vector<mxnet::OpReqType, std::allocator<mxnet::OpReqType> > const&, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> > const&)> const&, nnvm::Op const*, nnvm::NodeAttrs const&, mxnet::Context const&, std::vector<mxnet::engine::Var*, std::allocator<mxnet::engine::Var*> > const&, std::vector<mxnet::engine::Var*, std::allocator<mxnet::engine::Var*> > const&, std::vector<mxnet::Resource, std::allocator<mxnet::Resource> > const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::OpReqType, std::allocator<mxnet::OpReqType> > const&)::{lambda(mxnet::RunContext)#1}::operator()(mxnet::RunContext) const+0x128) [0x7fbf03807668]
[bt] (3) /user/anaconda3/lib/python3.7/site-packages/mxnet/libmxnet.so(mxnet::imperative::PushFComputeEx(std::function<void (nnvm::NodeAttrs const&, mxnet::OpContext const&, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> > const&, std::vector<mxnet::OpReqType, std::allocator<mxnet::OpReqType> > const&, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> > const&)> const&, nnvm::Op const*, nnvm::NodeAttrs const&, mxnet::Context const&, std::vector<mxnet::engine::Var*, std::allocator<mxnet::engine::Var*> > const&, std::vector<mxnet::engine::Var*, std::allocator<mxnet::engine::Var*> > const&, std::vector<mxnet::Resource, std::allocator<mxnet::Resource> > const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::OpReqType, std::allocator<mxnet::OpReqType> > const&)+0x4bb) [0x7fbf03813ceb]
[bt] (4) /user/anaconda3/lib/python3.7/site-packages/mxnet/libmxnet.so(mxnet::Imperative::InvokeOp(mxnet::Context const&, nnvm::NodeAttrs const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::OpReqType, std::allocator<mxnet::OpReqType> > const&, mxnet::DispatchMode, mxnet::OpStatePtr)+0x961) [0x7fbf03819511]
[bt] (5) /user/anaconda3/lib/python3.7/site-packages/mxnet/libmxnet.so(mxnet::Imperative::Invoke(mxnet::Context const&, nnvm::NodeAttrs const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&)+0x25b) [0x7fbf03819c5b]
[bt] (6) /user/anaconda3/lib/python3.7/site-packages/mxnet/libmxnet.so(+0x23a9879) [0x7fbf03723879]
[bt] (7) /user/anaconda3/lib/python3.7/site-packages/mxnet/libmxnet.so(MXImperativeInvokeEx+0x6f) [0x7fbf03723e6f]
[bt] (8) /user/anaconda3/lib/python3.7/lib-dynload/../../libffi.so.6(ffi_call_unix64+0x4c) [0x7fbf9d1d8ec0]

其他详细信息:

操作系统:Ubuntu 18.04GPU:NVIDIA

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 410.48 Driver Version: 410.48 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 1080 Off | 00000000:65:00.0 On | N/A |
| 34% 50C P2 38W / 180W | 592MiB / 8110MiB | 0% Default |
+-------------------------------+----------------------+----------------------+

最佳答案

您需要安装GPU版本的mxnet

例如:

pip install mxnet-cu92

完整说明可在此处获取:http://mxnet.incubator.apache.org/versions/master/install/index.html?platform=Linux&language=Python&processor=GPU

关于python - 将 GPU 与 python 包 bert_embeddings 和 mxnet 一起使用失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56443504/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com