caffe icon indicating copy to clipboard operation
caffe copied to clipboard

classify.py error (no attribute 'set_mode_cpu')

Open alex-pt opened this issue 11 years ago • 10 comments

Hello,

what could be the reason for this error?

python classify.py --pretrained_model=./../models/bvlc_googlenet/bvlc_googlenet_iter_101.caffemodel --model_def=./../models/bvlc_googlenet/deploy.prototxt --mean_file=./../python/out.npy ./../test.jpg ./output.txt
Traceback (most recent call last):
  File "classify.py", line 138, in <module>
    main(sys.argv)
  File "classify.py", line 103, in main
    caffe.set_mode_cpu()
AttributeError: 'module' object has no attribute 'set_mode_cpu'

alex-pt avatar Apr 11 '15 07:04 alex-pt

Solved by recompiling caffe from scratch.

alex-pt avatar Apr 11 '15 17:04 alex-pt

how did you solve it precisely?

ghost avatar May 16 '15 13:05 ghost

help! same error here... i tried recompiling caffe but it did not solve anything

etienne87 avatar May 26 '15 15:05 etienne87

@etienne87 did you recompile pycaffe? make pycaffe?

Hsinfu avatar May 26 '15 15:05 Hsinfu

OK :+1:

here is the list of actions for dumb ppl like me :

  1. search for hours doing stupid check in python path
  2. say "bye bye" to your caffe directory !
  3. edit /etc/bash.bashrc export PATH=/usr/local/cuda-7.0/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda-7.0/lib64:$LD_LIBRARY_PATH export PYTHONPATH=/home/xxx/Desktop/caffe/python:$PYTHONPATH
  4. follow from "Install dependencies" following link on ubuntu 14.04 (if you are under windows...well i'm sorry for you) : https://github.com/BVLC/caffe/wiki/Ubuntu-14.04-VirtualBox-VM (you will re-git clone blvc/caffe.git)
  5. just in case : if you have error importing numpy http://stackoverflow.com/questions/8917977/installing-lapack-for-numpy
  6. try python; import caffe; caffe.set_mode_cpu();

It should work now...

etienne87 avatar May 27 '15 13:05 etienne87

For those of you who do not want to repeat the installation, try changing caffe.set_mode_cpu() to caffe._caffe.set_mode_cpu(). It worked for me.

ShaharKatz avatar Feb 20 '16 20:02 ShaharKatz

Hello, I am getting the same error. I am using Arch linux. I have tried everything mentioned. Still the error not resolved.

sunithak avatar Jan 26 '18 13:01 sunithak

I got the same error, but fixed it with make the /path/caffe/python be the first of the $PYTHONPATH

why702 avatar May 08 '18 07:05 why702

here is the list of actions for dumb ppl like me :

  1. search for hours doing stupid check in python path
  2. say "bye bye" to your caffe directory !

Could you explain for more stupid person these two steps? ))

Zvyozdo4ka avatar Nov 01 '23 02:11 Zvyozdo4ka

I set CPU_ONLY := 1in Makefile.config, then make clean, then make again, but I still have this Error:

    caffe.set_mode_gpu()
AttributeError: module 'caffe' has no attribute 'set_mode_gpu'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/yulduz/Projects/GitHub/3dmm_cnn/demoCode/testBatchModel.py", line 113, in <module>
    caffe.set_mode_cpu()
AttributeError: module 'caffe' has no attribute 'set_mode_cpu'

Zvyozdo4ka avatar Nov 01 '23 02:11 Zvyozdo4ka