Incubator-mxnet: All tutorials are in python. Is there tutorials in C++?

Created on 22 Apr 2017  路  7Comments  路  Source: apache/incubator-mxnet

I didn't find how to using MXNET in C++? I am using VS2015 and windows10. The cpppackage seems not support for MSVC.

Most helpful comment

@wguo68 @NiklasTreutner @II-Matto A new patch (#6033) that makes cpp-package support MSVC will be soon merged, which makes it easier to create and build project in MSVC with cpp-package.

All 7 comments

There is one example for image prediction in

example/image-classification/predict-cpp

however, i agree: it is difficult to get started in c++. i didn't yet manage to get the cpp-package running under windows10/vs2015 either.

i don't have a op.h in the appropriate folder. i guess it's supposed to be built from the mxnetlib using the pythonWrapper (as indicated in the cmake and mk-files). however, this didn't work and an older op.h i found online seems to be deprecated. it would be great if someone could point me in the right direction.

@lx75249

I can write a short tutorials:

  1. Install python 2 (if you have already installed py3 it will be fine) and git

  2. Download windows nightly build or build it yourself and download "vc14 base package". Please use the lastest build, there are some bugs fixed. (There are some char encoding issues)

  3. Read the README.txt and follow the instruction. DO NOT RUN THE setupenv.cmd because it will destory your %PATH% and can not do its job. Add the %PATH% yourself. You need to make sure libmxnet.dll and the 3rdpart' Dlls are in the %PATH%. Use where libmxnet.dll to check.

set %MXNET_HOME% to the folder contains setupenv.cmd

  1. Install the python package. You might need to install numpy first.
cd %MXNET_HOME%\python
py -2 setup.py install
  1. Download the cpp-package. Put the include and src folder to %MXNET_HOME%.
cd %MXNET_HOME%\src\OpWrapperGenerator
py -2 OpWrapperGenerator.py libmxnet.dll

If you have some problem, you can change OpWrapperGenerator.py

os.system('./move-if-change.sh ' + temp_file_name + ' ' + output_file)

to

os.system('move-if-change.sh ' + temp_file_name + ' ' + output_file)
  1. Check if there is a op.h file. If not, you might need to check all the things above.

  2. Create a new msvc project. Set include folder to %MXNET_HOME%\include and library folder to %MXNET_HOME%\lib.

  3. Use this example to test if it is working.
    https://github.com/dmlc/mxnet/blob/master/cpp-package/example/mlp.cpp

I think you need to change the include in order to let the complier to find the header.

You can use Python API doc to help you coding. But there are only SGD optimizer available, you need to ues lower level API (C interface) to use other optimizers.

@kice Hi, many thanks for your guidelines. They help a lot. These indeed should be written into the MXNet documents.

As for the move-if-change.sh, it does not seem to be executable even with the './' removed. Currently I manually did the file copy. But can it be resolved in a better way?

BTW, the Python installation does not seem to be necessary if one only wants to use the C/C++ interface.

Yeah, thanks from me too. However, i still couldn't get it to work (yet).
i'll try again, but in the meantime: is there a way to make this step easier/optional?
maybe check in a version of the op.h that people can update using the wrapperGenerator (if necessary)? or do you think it would be a good idea to try and generate the op.h using c(++)? i haven't really looked into it much, but since the wrapper is for c++, it might be a good idea to have the wrapper generator in c as well.

@wguo68 @NiklasTreutner @II-Matto A new patch (#6033) that makes cpp-package support MSVC will be soon merged, which makes it easier to create and build project in MSVC with cpp-package.

This issue is closed due to lack of activity in the last 90 days. Feel free to ping me to reopen if this is still an active issue. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seongkyun picture seongkyun  路  3Comments

ranti-iitg picture ranti-iitg  路  3Comments

dushoufu picture dushoufu  路  3Comments

dmadeka picture dmadeka  路  3Comments

Zhaoyang-XU picture Zhaoyang-XU  路  3Comments