Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's the next step after build the onnxruntime from source code #359

Closed
rayeh5 opened this issue Jan 22, 2019 · 7 comments
Closed

What's the next step after build the onnxruntime from source code #359

rayeh5 opened this issue Jan 22, 2019 · 7 comments

Comments

@rayeh5
Copy link

rayeh5 commented Jan 22, 2019

I follow the "Build ONNX Runtime" on Ubuntu 16.04 environment with the following commands:
git clone --recursive https://github.com/Microsoft/onnxruntime
cd onnxruntime
./build.sh --config RelWithDebInfo --build_wheel
The build is successful, and start to run the tests.
Since the tests stay for a long time, so I use CTRL-C to break it.

Now, I am trying to use the pre-trained model to run this onnx runtime.
But I can't find any useful information to run it.

The example is using Python to import the onnx_runtime.
I have no idea which file and where is needed for the Python program to import it.
Where can I find the related information?

Thanks for your time.

@rayeh5
Copy link
Author

rayeh5 commented Jan 22, 2019

It seems that "CTRL-C" will break the build process, cause incomplete build.
I modify the test program to pass the "long" test, and can build to complete.
Will try again to learn how to run the onnx_runtime.

@rayeh5
Copy link
Author

rayeh5 commented Jan 22, 2019

Under the build/Linux/RelWithDebInfo/dist, there are two whl files: onnxruntime-0.1.5-cp35-cp35m-linux_x86_64.whl and onnxruntime-0.1.5-cp35-cp35m-manylinuxlinux1_x86_64.whl.
I use the command: pip3 install xxx.whl

After type python3

import onnxruntime.backend as backend
I got error message:
ImportError: No module named 'onnx'

Is something wrong for the building or install process?

Thanks for your time.

@snnn
Copy link
Member

snnn commented Jan 22, 2019

In order to use onnxruntime python package, you need to install onnx python package first.

@rayeh5
Copy link
Author

rayeh5 commented Jan 24, 2019

Thanks!
Now "import onnxruntime.backend as backend" is successful.
I also download the mnist model.

But I can't find any useful python code to run this model.
Could someone help to let me know where I can find the example code to run a model via python or C, etc.

Thanks for your time.

@pranavsharma
Copy link
Contributor

Here's one example from this page

# Compute the prediction with ONNX Runtime
import onnxruntime as rt
import numpy
sess = rt.InferenceSession("rf_iris.onnx")
input_name = sess.get_inputs()[0].name
label_name = sess.get_outputs()[0].name
pred_onx = sess.run([label_name], {input_name: X_test.astype(numpy.float32)})[0]

@hoaquocphan
Copy link

hi @pranavsharma @snnn
after building onnx successfully, I still can not import onnxruntime as below error:
ImportError: No module named 'onnxruntime'

could you check and give me your comment

@normandyr
Copy link

normandyr commented Jul 15, 2020

I did pip3 install onnxruntime (if you are on a different OS it might be different i.e. linux flavor). Then I get an error "cannot import name 'get_all_providers' from 'onnxruntime.capi._pybind_state"

Which will take you to here: #4196

I have not completed the steps to see if it will solve the issue or not yet but putting this here in case others end up here eventually. In the issue template the user mentions System Information as: OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10. So if you are in those OS you might look into the above link if your issue is as mine.

I have same issue as @hoaquocphan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants