frame

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Setting up API, getting "Caffe Import Error"

I'm trying to setup the SDK, the toolkit installed fine and now I'm getting an error setting up the API.

karl@karl-Lenovo-YOGA-710-15IKB:~/Downloads/ncapi$ ./setup.sh 
[sudo] password for karl: 
Selecting previously unselected package mvnc.
(Reading database ... 235173 files and directories currently installed.)
Preparing to unpack redist/mvnc_1.07_amd64.deb ...
Unpacking mvnc (0.0.36+0~20170713190651.36~1.gbpef8e6c) ...
Selecting previously unselected package mvnc-dev.
Preparing to unpack redist/mvnc-dev_1.07_amd64.deb ...
Unpacking mvnc-dev (0.0.36+0~20170713190651.36~1.gbpef8e6c) ...
Selecting previously unselected package python3-mvnc.
Preparing to unpack .../python3-mvnc_1.07_all.deb ...
Unpacking python3-mvnc (0.0.36+0~20170713190651.36~1.gbpef8e6c) ...
Setting up mvnc (0.0.36+0~20170713190651.36~1.gbpef8e6c) ...
Setting up mvnc-dev (0.0.36+0~20170713190651.36~1.gbpef8e6c) ...
Setting up python3-mvnc (0.0.36+0~20170713190651.36~1.gbpef8e6c) ...
Processing triggers for libc-bin (2.23-0ubuntu9) ...
--2017-08-24 11:33:38--  http://dl.caffe.berkeleyvision.org/bvlc_googlenet.caffemodel
Resolving dl.caffe.berkeleyvision.org (dl.caffe.berkeleyvision.org)... 169.229.222.251
Connecting to dl.caffe.berkeleyvision.org (dl.caffe.berkeleyvision.org)|169.229.222.251|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 53533754 (51M) [application/octet-stream]
Saving to: ‘../networks/GoogLeNet/bvlc_googlenet.caffemodel’

bvlc_googlenet.caffemodel     100%[==============================================>]  51.05M   277KB/s    in 65s     

2017-08-24 11:34:43 (808 KB/s) - ‘../networks/GoogLeNet/bvlc_googlenet.caffemodel’ saved [53533754/53533754]

--2017-08-24 11:34:43--  http://dl.caffe.berkeleyvision.org/bvlc_alexnet.caffemodel
Resolving dl.caffe.berkeleyvision.org (dl.caffe.berkeleyvision.org)... 169.229.222.251
Connecting to dl.caffe.berkeleyvision.org (dl.caffe.berkeleyvision.org)|169.229.222.251|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 243862414 (233M) [application/octet-stream]
Saving to: ‘../networks/AlexNet/bvlc_alexnet.caffemodel’

bvlc_alexnet.caffemodel       100%[==============================================>] 232.56M  1.17MB/s    in 3m 42s  

2017-08-24 11:38:25 (1.05 MB/s) - ‘../networks/AlexNet/bvlc_alexnet.caffemodel’ saved [243862414/243862414]

--2017-08-24 11:38:25--  https://github.com/DeepScale/SqueezeNet/raw/master/SqueezeNet_v1.0/squeezenet_v1.0.caffemodel
Resolving github.com (github.com)... 192.30.255.113, 192.30.255.112
Connecting to github.com (github.com)|192.30.255.113|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://raw.githubusercontent.com/DeepScale/SqueezeNet/master/SqueezeNet_v1.0/squeezenet_v1.0.caffemodel [following]
--2017-08-24 11:38:25--  https://raw.githubusercontent.com/DeepScale/SqueezeNet/master/SqueezeNet_v1.0/squeezenet_v1.0.caffemodel
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.0.133, 151.101.64.133, 151.101.128.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5001403 (4.8M) [application/octet-stream]
Saving to: ‘../networks/SqueezeNet/squeezenet_v1.0.caffemodel’

squeezenet_v1.0.caffemodel    100%[==============================================>]   4.77M  1.81MB/s    in 2.6s    

Last-modified header missing -- time-stamps turned off.
2017-08-24 11:38:28 (1.81 MB/s) - ‘../networks/SqueezeNet/squeezenet_v1.0.caffemodel’ saved [5001403/5001403]

Downloading...
--2017-08-24 11:38:28--  http://dl.caffe.berkeleyvision.org/caffe_ilsvrc12.tar.gz
Resolving dl.caffe.berkeleyvision.org (dl.caffe.berkeleyvision.org)... 169.229.222.251
Connecting to dl.caffe.berkeleyvision.org (dl.caffe.berkeleyvision.org)|169.229.222.251|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 17858008 (17M) [application/octet-stream]
Saving to: ‘caffe_ilsvrc12.tar.gz’

caffe_ilsvrc12.tar.gz         100%[==============================================>]  17.03M  1.56MB/s    in 12s     

2017-08-24 11:38:41 (1.38 MB/s) - ‘caffe_ilsvrc12.tar.gz’ saved [17858008/17858008]

Unzipping...
Done.
--2017-08-24 11:38:41--  https://dl.dropboxusercontent.com/u/38822310/gender_net.caffemodel
Resolving dl.dropboxusercontent.com (dl.dropboxusercontent.com)... 162.125.2.6
Connecting to dl.dropboxusercontent.com (dl.dropboxusercontent.com)|162.125.2.6|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 45649168 (44M) [application/octet-stream]
Saving to: ‘../networks/Gender/gender_net.caffemodel’

gender_net.caffemodel         100%[==============================================>]  43.53M  1.00MB/s    in 41s     

Last-modified header missing -- time-stamps turned off.
2017-08-24 11:39:23 (1.06 MB/s) - ‘../networks/Gender/gender_net.caffemodel’ saved [45649168/45649168]

--2017-08-24 11:39:23--  https://dl.dropboxusercontent.com/u/38822310/age_net.caffemodel
Resolving dl.dropboxusercontent.com (dl.dropboxusercontent.com)... 162.125.2.6
Connecting to dl.dropboxusercontent.com (dl.dropboxusercontent.com)|162.125.2.6|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 45661480 (44M) [application/octet-stream]
Saving to: ‘../networks/Age/age_net.caffemodel’

age_net.caffemodel            100%[==============================================>]  43.55M  1.46MB/s    in 27s     

Last-modified header missing -- time-stamps turned off.
2017-08-24 11:39:51 (1.63 MB/s) - ‘../networks/Age/age_net.caffemodel’ saved [45661480/45661480]

--2017-08-24 11:39:51--  https://dl.dropboxusercontent.com/u/38822310/mean.binaryproto
Resolving dl.dropboxusercontent.com (dl.dropboxusercontent.com)... 162.125.2.6
Connecting to dl.dropboxusercontent.com (dl.dropboxusercontent.com)|162.125.2.6|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 786446 (768K) [application/octet-stream]
Saving to: ‘../mean/age_gender/mean.binaryproto’

mean.binaryproto              100%[==============================================>] 768.01K   942KB/s    in 0.8s    

Last-modified header missing -- time-stamps turned off.
2017-08-24 11:39:52 (942 KB/s) - ‘../mean/age_gender/mean.binaryproto’ saved [786446/786446]

Traceback (most recent call last):
  File "convert_mean.py", line 1, in <module>
    import caffe
ImportError: No module named 'caffe'
--2017-08-24 11:39:52--  https://github.com/BVLC/caffe/raw/master/examples/images/cat.jpg
Resolving github.com (github.com)... 192.30.255.113, 192.30.255.112
Connecting to github.com (github.com)|192.30.255.113|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://raw.githubusercontent.com/BVLC/caffe/master/examples/images/cat.jpg [following]
--2017-08-24 11:39:53--  https://raw.githubusercontent.com/BVLC/caffe/master/examples/images/cat.jpg
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.0.133, 151.101.64.133, 151.101.128.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 140391 (137K) [image/jpeg]
Saving to: ‘../images/cat.jpg’

cat.jpg                       100%[==============================================>] 137.10K   519KB/s    in 0.3s    

Last-modified header missing -- time-stamps turned off.
2017-08-24 11:39:53 (519 KB/s) - ‘../images/cat.jpg’ saved [140391/140391]

../../bin
mvNCCompile v02.00, Copyright @ Movidius Ltd 2016

Caffe Import Error
mvNCCompile v02.00, Copyright @ Movidius Ltd 2016

Caffe Import Error
mvNCCompile v02.00, Copyright @ Movidius Ltd 2016

Caffe Import Error
mvNCCompile v02.00, Copyright @ Movidius Ltd 2016

Caffe Import Error
mvNCCompile v02.00, Copyright @ Movidius Ltd 2016

Caffe Import Error

Comments

  • 5 Comments sorted by Votes Date Added
  • I had this issue despite PYTHONPATH being set correctly. Instead of running the setup script again, I just went into ncapi/tools and ran ./get_models.sh then ./convert_models.sh separately.

  • @karl Sounds like your PYTHONPATH variable isn't being set. After running the toolkit setup script, you should begin the API installation by opening a new terminal to refresh the PYTHONPATH environment variable set by the toolkit setup script. If you have already opened a new window after using the toolkit setup script and you are still getting this error, try double checking your bashrc file to make sure your PYTHONPATH environment variable is there and pointing to the directory where you installed Caffe.

    The default PYTHONPATH set by the toolkit is /opt/movidius/caffe/python and in your bashrc file, it should look like this: export PYTHONPATH=$env:"/opt/movidius/caffe/python":$PYTHONPATH. You can also confirm this by typing in: echo $PYTHONPATH in your terminal. Let me know if this works for you. Thanks.

  • It appears that the installation process needs a strange mix of sudo and non-sudo commands. For the toolkit setup, I had to use sudo to get it to work (otherwise it cant get past git lock in Caffe installation), but then Caffe gets installed as root user, leading to Caffe import error when doing the API installation.
    The only combinations that worked for me were
    1. Run Toolkit installation: sudo ./setup.sh
    2. sudo chown -R currentuser /opt/movidius/caffe/
    3. Run API installation: ./setup.sh (or ./get_models.sh and ./convert_models.sh) without sudo, as currentuser

    As dropbox links are broken for some of the models, I commented out the lines related to those models in get_models and convert_models scripts to avoid issues. Similar to @snatch59 I had PYTHONPATH set and displayed correctly throughout the process.

    convert_models.sh also needed updating:

    NCS_TOOLKIT_ROOT='/path_to_ncs_sdk/bin'
    NCS_API_ROOT='/path_to_ncs_sdk/ncapi' 
    python3 $NCS_TOOLKIT_ROOT/mvNCCompile.pyc $NCS_API_ROOT/networks/AlexNet/NetworkConfig.prototxt -w $NCS_API_ROOT/networks/AlexNet/bvlc_alexnet.caffemodel -o $NCS_API_ROOT/networks/AlexNet/graph
    # .... further lines for other models 
    
  • Hello , I've have finished shell like this , however , it does not solve problem , could anyone help?
    echo $PYTHONPATH
    /opt/movidius/caffe/python:/opt/movidius/mvnc/python::/opt/movidius/caffe/python

    python image-classifier.py
    Traceback (most recent call last):
    File "image-classifier.py", line 10, in
    import mvnc.mvncapi as mvnc
    ImportError: No module named mvnc.mvncapi

  • @WaitingForU For my setup, I get a slightly different output.

    tome@mycomputer:~$ echo $PYTHONPATH
    :/opt/movidius/caffe/python
Sign In or Register to comment.