The caffe module needs to be on the Python path

I’m not sure where this post should go, so please feel free to move it!

I’m trying to do some tutorials with Jetson TX2 and so far have done Digits and now trying to use Caffe via Jupyter notebook.

The notebook is installed and working.

On cell number 2:

The caffe module needs to be on the Python path;

we’ll add it here explicitly.

import sys
caffe_root = ‘…/home/nvidia/caffe/python/caffe’ # this file should be run from {caffe_root}/examples (otherwise change this line)
sys.path.insert(0, caffe_root + ‘python’)

import caffe

If you get “No module named _caffe”, either you have not built pycaffe or you have the wrong path.

I’ve tried all kinds of permutations for the path, but none seem to work. Error is as below:

ImportError Traceback (most recent call last)
in ()
5 sys.path.insert(0, caffe_root + ‘python’)
6
----> 7 import caffe
8 # If you get “No module named _caffe”, either you have not built pycaffe or you have the wrong path.

ImportError: No module named caffe

Anybody know what the path should be? … Thanks!

Your ‘caffe_root’ doesn’t seem to point to the right path. Assuming you have your caffe source code installed at ‘/home/nvidia/caffe’, try the following:

import sys
caffe_root = '/home/nvidia/caffe/' # this file should be run from {caffe_root}/examples (otherwise change this line)
sys.path.insert(0, caffe_root + 'python')

import caffe

That works thanks … I think i understand the path system better now.

A video walkthrough of natively installing NVIDIA DIGITS on Ubuntu 18.04 LTS is available here:

https://cudaeducation.com/nvidiadigits/

-Cuda Education
cudaeducation.com