Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to run the demo.py with cpu #13

Open
WLswert opened this issue Jul 28, 2017 · 3 comments
Open

how to run the demo.py with cpu #13

WLswert opened this issue Jul 28, 2017 · 3 comments

Comments

@WLswert
Copy link

WLswert commented Jul 28, 2017

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?

@bear63
Copy link
Owner

bear63 commented Jul 28, 2017

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

@WLswert
Copy link
Author

WLswert commented Jul 28, 2017

great!
thank you!

@ZhangZoffy
Copy link

ZhangZoffy commented Oct 17, 2017

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: ***
已放弃 (核心已转储)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants