File "/home/nvidia/caffe/python/caffe/", line 13, in <module> from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \ ImportError: dynamic module does not define module export function (PyInit__caffe)

Hi, I tried to solve that error but I can not, it seems to be all right but I do not find that it is failing, you could help me thanks.

Traceback (most recent call last):
File “”, line 22, in
import caffe
File “/home/nvidia/caffe/python/caffe/”, line 1, in
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
File “/home/nvidia/caffe/python/caffe/”, line 13, in
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver,
ImportError: dynamic module does not define module export function (PyInit__caffe)

Here is the Makefile.config

Refer to

Contributions simplifying and improving our build system are welcome!

cuDNN acceleration switch (uncomment to build with cuDNN).


CPU-only switch (uncomment to build without GPU support).


uncomment to disable IO dependencies and corresponding data layers




This code is taken from

USE_HDF5 := 0

uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)

You should not set this flag if you will be reading LMDBs with any

possibility of simultaneous read and write


Uncomment if you’re using OpenCV 3


To customize your choice of compiler, uncomment and set the following.

N.B. the default for Linux is g++ and the default for OSX is clang++


CUDA directory contains bin/ and lib/ directories that we need.

CUDA_DIR := /usr/local/cuda

On Ubuntu 14.04, if cuda tools are installed via

“sudo apt-get install nvidia-cuda-toolkit” then use this instead:

CUDA_DIR := /usr

CUDA architecture setting: going with all of them.

For CUDA < 6.0, comment the *_50 through *_61 lines for compatibility.

For CUDA < 8.0, comment the *_60 and *_61 lines for compatibility.

For CUDA >= 9.0, comment the *_20 and *_21 lines for compatibility.

CUDA_ARCH := -gencode arch=compute_20,code=sm_20
-gencode arch=compute_20,code=sm_21
-gencode arch=compute_30,code=sm_30
-gencode arch=compute_35,code=sm_35
-gencode arch=compute_50,code=sm_50
-gencode arch=compute_52,code=sm_52
-gencode arch=compute_60,code=sm_60
-gencode arch=compute_61,code=sm_61
-gencode arch=compute_61,code=compute_61

BLAS choice:

atlas for ATLAS (default)

mkl for MKL

open for OpenBlas

BLAS := atlas

Custom (MKL/ATLAS/OpenBLAS) include and lib directories.

Leave commented to accept the defaults for your choice of BLAS

(which should work)!

BLAS_INCLUDE := /path/to/your/blas

BLAS_LIB := /path/to/your/blas

Homebrew puts openblas in a directory that is not on the standard search path

BLAS_INCLUDE := $(shell brew --prefix openblas)/include

BLAS_LIB := $(shell brew --prefix openblas)/lib

This is required only if you will compile the matlab interface.

MATLAB directory should contain the mex binary in /bin.

MATLAB_DIR := /usr/local

MATLAB_DIR := /Applications/

NOTE: this is required only if you will compile the python interface.

We need to be able to find Python.h and numpy/arrayobject.h.

#PYTHON_INCLUDE := /usr/include/python2.7 \


Anaconda Python distribution is quite popular. Include path:

Verify anaconda location, sometimes it’s in root.

(ANACONDA_HOME)/include/python2.7 \ (ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include

Uncomment to use Python 3 (default is Python 2)

PYTHON_LIBRARIES := boost_python3 python3.5m

PYTHON_INCLUDE := /usr/include/python3.5m \


We need to be able to find or .dylib.

#PYTHON_LIB := /usr/lib

Homebrew installs numpy in a non standard path (keg only)

PYTHON_INCLUDE += (dir (shell python -c ‘import numpy.core; print(numpy.core.file)’))/include

PYTHON_LIB += $(shell brew --prefix numpy)/lib

Uncomment to support layers written in Python (will link against Python libs)


Whatever else you find you need goes here.

INCLUDE_DIRS := (PYTHON_INCLUDE) /usr/local/include LIBRARY_DIRS := (PYTHON_LIB) /usr/local/lib /usr/lib

If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies

INCLUDE_DIRS += $(shell brew --prefix)/include

LIBRARY_DIRS += $(shell brew --prefix)/lib

NCCL acceleration switch (uncomment to build with NCCL) (last tested version: v1.2.3-1+cuda8.0)


Uncomment to use pkg-config to specify OpenCV library paths.

(Usually not necessary – OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)


N.B. both build and distribute dirs are cleared on make clean

BUILD_DIR := build
DISTRIBUTE_DIR := distribute

Uncomment for debugging. Does not work on OSX due to

DEBUG := 1

The ID of the GPU that ‘make runtest’ will use to run unit tests.


enable pretty build (comment to see full commands)

Q ?= @

Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

General configuration for OpenCV 3.4.0 =====================================
– Version control: unknown

– Platform:
– Timestamp: 2018-09-14T03:55:30Z
– Host: Linux 4.4.38-tegra aarch64
– CMake: 3.5.1
– CMake generator: Unix Makefiles
– CMake build tool: /usr/bin/make
– Configuration: RELEASE

– CPU/HW features:
– Baseline: NEON FP16
– required: NEON
– disabled: VFPV3

– C/C++:
– Built as dynamic libs?: YES
– C++ Compiler: /usr/bin/c++ (ver 5.4.0)
– C++ flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
– C++ flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
– C Compiler: /usr/bin/cc
– C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
– C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
– Linker flags (Release):
– Linker flags (Debug):
– ccache: NO
– Precompiled headers: YES
– Extra dependencies: dl m pthread rt /usr/lib/aarch64-linux-gnu/ /usr/lib/aarch64-linux-gnu/ cudart nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cufft -L/usr/local/cuda-9.0/lib64
– 3rdparty dependencies:

– OpenCV modules:
– To be built: calib3d core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev dnn features2d flann highgui imgcodecs imgproc ml objdetect photo python2 python3 python_bindings_generator shape stitching superres video videoio videostab
– Disabled: js world
– Disabled by dependency: -
– Unavailable: java ts viz
– Applications: apps
– Documentation: NO
– Non-free algorithms: NO

– GUI:
– QT: YES (ver 5.5.1)
– QT OpenGL support: YES (Qt5::OpenGL 5.5.1)
– GTK+: NO
– OpenGL support: YES (/usr/lib/aarch64-linux-gnu/ /usr/lib/aarch64-linux-gnu/
– VTK support: NO

– Media I/O:
– ZLib: /usr/lib/aarch64-linux-gnu/ (ver 1.2.8)
– JPEG: /usr/lib/aarch64-linux-gnu/ (ver )
– WEBP: build (ver encoder: 0x020e)
– PNG: /usr/lib/aarch64-linux-gnu/ (ver 1.2.54)
– TIFF: /usr/lib/aarch64-linux-gnu/ (ver 42 / 4.0.6)
– JPEG 2000: /usr/lib/aarch64-linux-gnu/ (ver 1.900.1)
– OpenEXR: build (ver 1.7.1)

– Video I/O:
– DC1394: YES (ver 2.2.4)
– avcodec: YES (ver 56.60.100)
– avformat: YES (ver 56.40.101)
– avutil: YES (ver 54.31.100)
– swscale: YES (ver 3.1.101)
– avresample: NO
– GStreamer:
– base: YES (ver 1.8.3)
– video: YES (ver 1.8.3)
– app: YES (ver 1.8.3)
– riff: YES (ver 1.8.3)
– pbutils: YES (ver 1.8.3)
– libv4l/libv4l2: 1.10.0 / 1.10.0
– v4l/v4l2: linux/videodev2.h
– gPhoto2: NO

– Parallel framework: pthreads

– Trace: YES (built-in)

– Other third-party libraries:
– Lapack: YES (/usr/lib/ /usr/lib/ /usr/lib/
– Eigen: YES (ver 3.2.92)
– Custom HAL: YES (carotene (ver 0.0.1))

– NVIDIA GPU arch: 62
– NVIDIA PTX archs:

– OpenCL: YES (no extra features)
– Include path: /home/nvidia/src/opencv-3.4.0/3rdparty/include/opencl/1.2
– Link libraries: Dynamic load

– Python 2:
– Interpreter: /usr/bin/python2.7 (ver 2.7.12)
– Libraries: /usr/lib/aarch64-linux-gnu/ (ver 2.7.12)
– numpy: /usr/local/lib/python2.7/dist-packages/numpy/core/include (ver 1.15.1)
– packages path: lib/python2.7/dist-packages

– Python 3:
– Interpreter: /usr/bin/python3 (ver 3.5.2)
– Libraries: /usr/lib/aarch64-linux-gnu/ (ver 3.5.2)
– numpy: /usr/local/lib/python3.5/dist-packages/numpy/core/include (ver 1.15.1)
– packages path: lib/python3.5/dist-packages

– Python (for build): /usr/bin/python2.7

– Java:
– ant: NO
– Java wrappers: NO
– Java tests: NO

– Matlab: NO

– Install to: /usr/local

– Configuring done
– Generating done
– Build files have been written to: /home/nvidia/src/opencv-3.4.0/build


Have you added the Caffe folder into python path?

export PYTHONPATH=$HOME/caffe/python:$PYTHONPATH