Skip to content

CNTK Library Evaluation on Linux

Zhou Wang edited this page May 22, 2017 · 20 revisions

The CNTK Library on Linux is available in C++, Python and Java.

Using C++

The usage pattern on Linux is the same as that on Windows.

The evaluation library, libCntk.Core-<Version>.so, can be found under cntk/lib in the CNTK binary package. If you build CNTK from source code, the libCntk.Core-<Version>.so is available in the lib folder of the build directory.

Any program using the evaluation library needs to link the libraries libCntk.Core and libCntk.Math, e.g.

-lCntk.Core-<VERSION> -lCntk.Math-<VERSION>

, and set the appropriate search path for these libraries. Please use the same build flavor (Debug/Release) and the same compiler version as the one used to create the libraries.

The Examples/Evaluation/CNTKLibraryCPPEvalCPUOnlyExamples and Examples/Evaluation/CNTKLibraryCPPEvalGPUExamples in the CNTK source code illustrates the usage pattern in Linux. The Makefile contains the target CNTKLIBRARY_CPP_EVAL_EXAMPLES showing how to build the example.

Please refer to the CNTK Library C++ Evaluation Interface page for APIs in the CNTK C++ Library.

Using Python

You can use Python to evaluate a pre-trained model. Examples can be found here.

Using Java

CNTK also provides APIs for evaluating model in Java application. Please note that the CNTK Java API is still experimental and subject to change.

The Java example shows how to evaluate a CNN model using the Java API.

For using CNTK Java Library, add the cntk.jar file to the classpath of your Java project. If you are working with an IDE you should add this as an unmanaged jar. The cntk.jar file can be found in the CNTK binary release package (in the folder cntk\cntk\java). You can also build cntk.jar from CNTK source. Please also set java.library.path to the directory containing libCntk.Core.JavaBinding-.so, and make sure that the directory containing CNTK binary dlls is in the LD_LIBRARY_PATH. If you get UnsatisfiedLinkErrors in Java, it is typically because that the directory is not on the LD_LIBRARY_PATH or the version of the C++ runtime library on the system is not compatiable with the version used to build CNTK libaraies.

The Java library is currently tested with 64-bit OpenJDK 7.

Clone this wiki locally