sceneReco icon indicating copy to clipboard operation
sceneReco copied to clipboard

how to run the demo.py with cpu

Open WLswert opened this issue 7 years ago • 3 comments

hi,i want to run the demo.py with CPU ?what should i do ? I change the ctpnport.py like this:

caffe.set_mode_cpu()
# caffe.set_device(cfg.TEST_GPU_ID)

and the ctpn works,but I change the crnnport.py with cpu model ,output the error:

Traceback (most recent call last):
  File "demo.py", line 14, in <module>
    model,converter = crnnSource()
  File "/data/sceneReco/crnnport.py", line 47, in crnnSource
    model.load_state_dict(torch.load(path))
  File "/usr/lib64/python2.7/site-packages/torch/serialization.py", line 229, in load
    return _load(f, map_location, pickle_module)
  File "/usr/lib64/python2.7/site-packages/torch/serialization.py", line 377, in _load
    result = unpickler.load()
  File "/usr/lib64/python2.7/site-packages/torch/serialization.py", line 348, in persistent_load
    data_type(size), location)
  File "/usr/lib64/python2.7/site-packages/torch/serialization.py", line 85, in default_restore_location
    result = fn(storage, location)
  File "/usr/lib64/python2.7/site-packages/torch/serialization.py", line 67, in _cuda_deserialize
    return obj.cuda(device_id)
  File "/usr/lib64/python2.7/site-packages/torch/_utils.py", line 57, in _cuda
    with torch.cuda.device(device):
  File "/usr/lib64/python2.7/site-packages/torch/cuda/__init__.py", line 124, in __enter__
    _lazy_init()
  File "/usr/lib64/python2.7/site-packages/torch/cuda/__init__.py", line 84, in _lazy_init
    _check_driver()
  File "/usr/lib64/python2.7/site-packages/torch/cuda/__init__.py", line 58, in _check_driver
    http://www.nvidia.com/Download/index.aspx""")
AssertionError: 
Found no NVIDIA driver on your system. Please check that you
have an NVIDIA GPU and installed a driver from
http://www.nvidia.com/Download/index.aspx

I write the demo code:

model = crnn.CRNN(32, 1, len(alphabet)+1, 256)
if torch.cuda.is_available():
    model = model.cuda()
print('loading pretrained model from %s' % model_path)
model.load_state_dict(torch.load(model_path))
print(model)

When I load other .pth model files from https://github.com/meijieru/crnn.pytorch, not output error. can you provide the CPU models files for crnn?

WLswert avatar Jul 28 '17 02:07 WLswert

https://pan.baidu.com/s/1c2lc2Co
cpu model

bear63 avatar Jul 28 '17 07:07 bear63

great! thank you!

WLswert avatar Jul 28 '17 08:07 WLswert

my caffe is CPU-ONLY and no cuda . I also change the ctpnport.py like this: caffe.set_mode_cpu() and change the crnnport.py like this: model = crnn.CRNN(32, 1, len(alphabet) + 1, 256) if torch.cuda.is_available(): model = model.cuda() path = './crnn/samples/netCRNNcpu.pth'

when I run python demo.py WARNING: Logging before InitGoogleLogging() is written to STDERR F1017 09:46:06.274271 61345 common.cpp:66] Cannot use GPU in CPU-only Caffe: check mode. *** Check failure stack trace: *** 已放弃 (核心已转储)

ZhangZoffy avatar Oct 17 '17 01:10 ZhangZoffy