欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

pycharm mxnet src/base.cc:49: GPU context requested, but no GPUs found.

程序员文章站 2022-05-27 10:32:59
...

报错:
src/base.cc:49: GPU context requested, but no GPUs found.
src/storage/storage.cc???? Check failed: e == cudaSuccess || e == cudaErrorCudartUnloading: CUDA: no CUDA-capable device is detected

[14:07:55] src/base.cc:49: GPU context requested, but no GPUs found.
Traceback (most recent call last):
  File "/home/user1/.pycharm_helpers/pydev/pydevd.py", line 1448, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/home/user1/pjs/frvt/arcface_Siamese_offline/recognition/train_0305.py", line 448, in <module>
    main()
  File "/home/user1/pjs/frvt/arcface_Siamese_offline/recognition/train_0305.py", line 444, in main
    train_net()
  File "/home/user1/pjs/frvt/arcface_Siamese_offline/recognition/train_0305.py", line 438, in train_net
    epoch_end_callback=epoch_cb)
  File "/home/user1/pjs/frvt/arcface_Siamese_offline/recognition/parall_module.py", line 599, in fit
    for_training=True, force_rebind=force_rebind)
  File "/home/user1/pjs/frvt/arcface_Siamese_offline/recognition/parall_module.py", line 231, in bind
    force_rebind=False, shared_module=None)
  File "/home/user1/miniconda3/envs/hardsample/lib/python2.7/site-packages/mxnet/module/module.py", line 429, in bind
    state_names=self._state_names)
  File "/home/user1/miniconda3/envs/hardsample/lib/python2.7/site-packages/mxnet/module/executor_group.py", line 279, in __init__
    self.bind_exec(data_shapes, label_shapes, shared_group)
  File "/home/user1/miniconda3/envs/hardsample/lib/python2.7/site-packages/mxnet/module/executor_group.py", line 375, in bind_exec
    shared_group))
  File "/home/user1/miniconda3/envs/hardsample/lib/python2.7/site-packages/mxnet/module/executor_group.py", line 662, in _bind_ith_exec
    shared_buffer=shared_data_arrays, **input_shapes)
  File "/home/user1/miniconda3/envs/hardsample/lib/python2.7/site-packages/mxnet/symbol/symbol.py", line 1629, in simple_bind
    raise RuntimeError(error_msg)
RuntimeError: simple_bind error. Arguments:
data: (280, 3, 112, 112)
softmax_label: (280,)
[09:44:48] src/storage/storage.cc:100: Check failed: e == cudaSuccess || e == cudaErrorCudartUnloading: CUDA: no CUDA-capable device is detected
Stack trace:
  [bt] (0) /home/user1/miniconda3/envs/hardsample/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x4b04cb) [0x7f1a941664cb]
  [bt] (1) /home/user1/miniconda3/envs/hardsample/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x2e65bc6) [0x7f1a96b1bbc6]
  [bt] (2) /home/user1/miniconda3/envs/hardsample/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x2e68838) [0x7f1a96b1e838]
  [bt] (3) /home/user1/miniconda3/envs/hardsample/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x2e6af02) [0x7f1a96b20f02]
  [bt] (4) /home/user1/miniconda3/envs/hardsample/lib/python2.7/site-packages/mxnet/libmxnet.so(mxnet::NDArray::NDArray(mxnet::TShape const&, mxnet::Context, bool, int)+0x5d0) [0x7f1a961e76d0]
  [bt] (5) /home/user1/miniconda3/envs/hardsample/lib/python2.7/site-packages/mxnet/libmxnet.so(mxnet::common::InitZeros(mxnet::NDArrayStorageType, mxnet::TShape const&, mxnet::Context const&, int)+0x5c) [0x7f1a9629b8ac]
  [bt] (6) /home/user1/miniconda3/envs/hardsample/lib/python2.7/site-packages/mxnet/libmxnet.so(mxnet::common::ReshapeOrCreate(std::string const&, mxnet::TShape const&, int, mxnet::NDArrayStorageType, mxnet::Context const&, std::unordered_map<std::string, mxnet::NDArray, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, mxnet::NDArray> > >*, bool)+0x3a1) [0x7f1a962aef91]
  [bt] (7) /home/user1/miniconda3/envs/hardsample/lib/python2.7/site-packages/mxnet/libmxnet.so(mxnet::exec::GraphExecutor::InitArguments(nnvm::IndexedGraph const&, std::vector<mxnet::TShape, std::allocator<mxnet::TShape> > const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&, std::vector<mxnet::Context, std::allocator<mxnet::Context> > const&, std::vector<mxnet::Context, std::allocator<mxnet::Context> > const&, std::vector<mxnet::Context, std::allocator<mxnet::Context> > const&, std::vector<mxnet::OpReqType, std::allocator<mxnet::OpReqType> > const&, std::unordered_set<std::string, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::string> > const&, mxnet::Executor const*, std::unordered_map<std::string, mxnet::NDArray, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, mxnet::NDArray> > >*, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> >*, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> >*, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> >*)+0xb10) [0x7f1a962b6f60]
  [bt] (8) /home/user1/miniconda3/envs/hardsample/lib/python2.7/site-packages/mxnet/libmxnet.so(mxnet::exec::GraphExecutor::Init(nnvm::Symbol, mxnet::Context const&, std::map<std::string, mxnet::Context, std::less<std::string>, std::allocator<std::pair<std::string const, mxnet::Context> > > const&, std::vector<mxnet::Context, std::allocator<mxnet::Context> > const&, std::vector<mxnet::Context, std::allocator<mxnet::Context> > const&, std::vector<mxnet::Context, std::allocator<mxnet::Context> > const&, std::unordered_map<std::string, mxnet::TShape, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, mxnet::TShape> > > const&, std::unordered_map<std::string, int, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, int> > > const&, std::unordered_map<std::string, int, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, int> > > const&, std::vector<mxnet::OpReqType, std::allocator<mxnet::OpReqType> > const&, std::unordered_set<std::string, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::string> > const&, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> >*, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> >*, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> >*, std::unordered_map<std::string, mxnet::NDArray, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, mxnet::NDArray> > >*, mxnet::Executor*, std::unordered_map<nnvm::NodeEntry, mxnet::NDArray, nnvm::NodeEntryHash, nnvm::NodeEntryEqual, std::allocator<std::pair<nnvm::NodeEntry const, mxnet::NDArray> > > const&)+0x6bc) [0x7f1a962c532c]

原因:Pycharm中的GPU环境变量设置没起作用,或者设置不对
解决:
直接在代码中加入GPU设置

import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0,1'
相关标签: MxNet # DL-报错