caffe icon indicating copy to clipboard operation
caffe copied to clipboard

Docker installation - no module name _caffe - How to I make pycaffe?

Open yonatanbitton opened this issue 3 years ago • 1 comments

Hello.

I am trying to use the Docker installation.

I follow the instructions here (GPU): https://github.com/BVLC/caffe/tree/master/docker

These commands work, but I dont have _caffe:

(cc) (base) [ec2-user@ip-172-31-46-120 bottom-up-attention]$ nvidia-docker run -ti bvlc/caffe:gpu caffe --version
caffe version 1.0.0
In [1]: import caffe

In [2]: caffe.__version__
Out[2]: '1.0.0'
In [4]: import _caffe
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-4-4b3165da92f9> in <module>()
----> 1 import _caffe

ImportError: No module named _caffe

Next, I enter the docker: docker run --runtime=nvidia -ti -v $data_path:/workspace/data:ro -v $code_path/bottom-up-attention:/workspace/code bvlc/caffe:gpu So when I run my code for code/tools/generate_tsv_v2.py I receive:

root@0cd34d53d7fe:/workspace# python code/tools/generate_tsv_v2.py --gpu 3,4,6 --cfg code/experiments/cfgs/faster_rcnn_end2end_resnet.yml --def code/models/vg/ResNet-101/faster_rcnn_end2end_final/test.prototxt --net code/data/faster_rcnn_models/resnet101_faster_rcnn_final.caffemodel --split conceptual_captions_val --data_root data --out data/val_frcnn/

Traceback (most recent call last):
  File "code/tools/generate_tsv_v2.py", line 15, in <module>
    from fast_rcnn.test import im_detect,_get_blobs
  File "/workspace/code/tools/../lib/fast_rcnn/test.py", line 16, in <module>
    import caffe
  File "/workspace/code/tools/../caffe/python/caffe/__init__.py", line 1, in <module>
    from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
  File "/workspace/code/tools/../caffe/python/caffe/pycaffe.py", line 13, in <module>
    from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
ImportError: No module named _caffe

I know I am suppose to make -j8 && make pycaffe, but where?

I've trying going to /opt/caffe and:

root@0cd34d53d7fe:/opt/caffe# cd /opt/caffe/
root@0cd34d53d7fe:/opt/caffe# ls
CMakeLists.txt   CONTRIBUTORS.md  LICENSE   Makefile.config          README.md  caffe.cloc  data        docker  examples  matlab  python   src
CONTRIBUTING.md  INSTALL.md       Makefile  Makefile.config.example  build      cmake       distribute  docs    include   models  scripts  tools
root@0cd34d53d7fe:/opt/caffe# cp Makefile.config.example Makefile.config
root@0cd34d53d7fe:/opt/caffe# make -j8

But it fails.

How can I fix it?

I believe your current instructions are not complete. I would be glad for help. Thank you!

yonatanbitton avatar Apr 29 '21 08:04 yonatanbitton

I added built and make:

cd /opt/caffe/build
make runtest
make -j8
make pycaffe

It worked

[100%] Built target pycaffe
root@e9234b09a03f:/opt/caffe/build# ls

But still when activating the code I receive ImportError: No module named _caffe

yonatanbitton avatar Apr 29 '21 16:04 yonatanbitton