caffe icon indicating copy to clipboard operation
caffe copied to clipboard

python import caffe ImportError: No module named 'caffe._caffe'

Open chenyuan1994 opened this issue 7 years ago • 2 comments

Please use the caffe-users list for usage, installation, or modeling questions, or other requests for help. Do not post such requests to Issues. Doing so interferes with the development of Caffe.

Please read the guidelines for contributing before submitting this issue.

Issue summary

python

import caffe Traceback (most recent call last): File "", line 1, in ImportError: No module named 'caffe' import sys sys.path.append('/opt/caffe-master/python') import caffe Traceback (most recent call last): File "", line 1, in File "/opt/caffe-master/python/caffe/init.py", line 1, in from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver,
File "/opt/caffe-master/python/caffe/pycaffe.py", line 13, in from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver,
ImportError: No module named 'caffe._caffe'

while I make pycaffe , make: *** No rule to make target /usr/include/opencv2/core/core.hpp', needed by .build_release/cuda/src/caffe/data_transformer.o'. Stop.

Steps to reproduce

If you are having difficulty building Caffe or training a model, please ask the caffe-users mailing list. If you are reporting a build error that seems to be due to a bug in Caffe, please attach your build configuration (either Makefile.config or CMakeCache.txt) and the output of the make (or cmake) command.

Your system configuration

Operating system:#32~14.04.1-Ubuntu Compiler: CUDA version (if applicable): CUDNN version (if applicable): BLAS: Python or MATLAB version (for pycaffe and matcaffe respectively):Python 3.5.3

chenyuan1994 avatar Jan 16 '18 03:01 chenyuan1994

Issue summary

Similar report:

python generate_tsv.py
Traceback (most recent call last):
  File "generate_tsv.py", line 15, in <module>
    from fast_rcnn.test import im_detect,_get_blobs
  File "/root/github/bottom-up-attention/tools/../lib/fast_rcnn/test.py", line 16, in <module>
    import caffe
  File "/root/github/bottom-up-attention/tools/../caffe/python/caffe/__init__.py", line 1, in <module>
    from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
  File "/root/github/bottom-up-attention/tools/../caffe/python/caffe/pycaffe.py", line 13, in <module>
    from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
ModuleNotFoundError: No module named 'caffe._caffe'

Steps to reproduce

(1) Use docker image airsplay/bottom-up-attention (2) download and install Miniconda from this version. (if skip this step, we are trying python27; otherwise we are trying python38) (3) Install caffe for Ubuntu 16.04 according to tutorial: sudo apt-get install python-dev

sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler sudo apt-get install --no-install-recommends libboost-all-dev

BLAS sudo apt-get install libatlas-base-dev and sudo apt-get install libopenblas-dev

(4) run generate_tsv.py from bottom-up-attention.

Tried solutions

System configuration

  • Operating system:

lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16.04.6 LTS Release: 16.04 Codename: xenial

  • Compiler:
  • CUDA version (if applicable): No
  • CUDNN version (if applicable): No
  • BLAS: following installation instruction as mentioned above
  • Python version (if using pycaffe): python27, python38
  • MATLAB version (if using matcaffe): No

Issue checklist

  • [v] read the guidelines and removed the first paragraph
  • [v] written a short summary and detailed steps to reproduce
  • [ ] explained how solutions to related problems failed (tick if found none)
  • [ ] filled system configuration
  • [v] attached relevant logs/config files (tick if not applicable)

yezhengli-Mr9 avatar Jan 06 '21 02:01 yezhengli-Mr9

Hi @chenyuan1994 , how do you figure this out? Is that true that caffe is better run on python27? Furtherly, in case of cpu-only, I investigate that Makefile.config might need get changed.

yezhengli-Mr9 avatar Jan 06 '21 05:01 yezhengli-Mr9