当前位置: 代码迷 >> 综合 >> pycharm mxnet src/base.cc:49: GPU context requested, but no GPUs found.
  详细解决方案

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

热度:40   发布时间:2023-12-15 16:11:48.0

报错:
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 _execpydev_imports.execfile(file, globals, locals)  # execute the scriptFile "/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 maintrain_net()File "/home/user1/pjs/frvt/arcface_Siamese_offline/recognition/train_0305.py", line 438, in train_netepoch_end_callback=epoch_cb)File "/home/user1/pjs/frvt/arcface_Siamese_offline/recognition/parall_module.py", line 599, in fitfor_training=True, force_rebind=force_rebind)File "/home/user1/pjs/frvt/arcface_Siamese_offline/recognition/parall_module.py", line 231, in bindforce_rebind=False, shared_module=None)File "/home/user1/miniconda3/envs/hardsample/lib/python2.7/site-packages/mxnet/module/module.py", line 429, in bindstate_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_execshared_group))File "/home/user1/miniconda3/envs/hardsample/lib/python2.7/site-packages/mxnet/module/executor_group.py", line 662, in _bind_ith_execshared_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_bindraise 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'
  相关解决方案