-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Onnx error when saving model. #6115
Comments
pip install onnx |
I also trying to install on M1 Mac ml agents release 21. I have issue with onnx on the this step(python -m pip install ./ml-agents). can you help me to fix it. |
Not recognizing the package. I even tried installing it through brew and no luck |
This issue is stale because it has been open for 30 days with no activity. |
This issue was closed because it has been inactive for 14 days since being marked as stale. Please open a new issue for related bugs. |
Describe the bug
I was following the initial example tutorial and managed to train a model. When I stop the training it cannot save the model because of issues with onnx. It looks like torch is unable to find onnx? But I have it installed and which the correct version.
Console logs / stack traces
^C[INFO] Learning was interrupted. Please wait while the graph is generated.
Traceback (most recent call last):
File "/Users/haradai/miniconda3/envs/mlagents/lib/python3.10/site-packages/torch/onnx/_internal/onnx_proto_utils.py", line 219, in _add_onnxscript_fn
import onnx
File "/Users/haradai/miniconda3/envs/mlagents/lib/python3.10/site-packages/onnx/init.py", line 6, in
from onnx.external_data_helper import load_external_data_for_model, write_external_data_tensors, convert_model_to_external_data
File "/Users/haradai/miniconda3/envs/mlagents/lib/python3.10/site-packages/onnx/external_data_helper.py", line 9, in
from .onnx_pb import TensorProto, ModelProto, AttributeProto, GraphProto
File "/Users/haradai/miniconda3/envs/mlagents/lib/python3.10/site-packages/onnx/onnx_pb.py", line 4, in
from .onnx_ml_pb2 import * # noqa
File "/Users/haradai/miniconda3/envs/mlagents/lib/python3.10/site-packages/onnx/onnx_ml_pb2.py", line 5, in
from google.protobuf.internal import builder as _builder
ImportError: cannot import name 'builder' from 'google.protobuf.internal' (/Users/haradai/miniconda3/envs/mlagents/lib/python3.10/site-packages/google/protobuf/internal/init.py)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/haradai/miniconda3/envs/mlagents/bin/mlagents-learn", line 8, in
sys.exit(main())
File "/Users/haradai/miniconda3/envs/mlagents/lib/python3.10/site-packages/mlagents/trainers/learn.py", line 267, in main
run_cli(parse_command_line())
File "/Users/haradai/miniconda3/envs/mlagents/lib/python3.10/site-packages/mlagents/trainers/learn.py", line 263, in run_cli
run_training(run_seed, options, num_areas)
File "/Users/haradai/miniconda3/envs/mlagents/lib/python3.10/site-packages/mlagents/trainers/learn.py", line 137, in run_training
tc.start_learning(env_manager)
File "/Users/haradai/miniconda3/envs/mlagents/lib/python3.10/site-packages/mlagents_envs/timers.py", line 305, in wrapped
return func(*args, **kwargs)
File "/Users/haradai/miniconda3/envs/mlagents/lib/python3.10/site-packages/mlagents/trainers/trainer_controller.py", line 200, in start_learning
self._save_models()
File "/Users/haradai/miniconda3/envs/mlagents/lib/python3.10/site-packages/mlagents_envs/timers.py", line 305, in wrapped
return func(*args, **kwargs)
File "/Users/haradai/miniconda3/envs/mlagents/lib/python3.10/site-packages/mlagents/trainers/trainer_controller.py", line 80, in _save_models
self.trainers[brain_name].save_model()
File "/Users/haradai/miniconda3/envs/mlagents/lib/python3.10/site-packages/mlagents/trainers/trainer/rl_trainer.py", line 172, in save_model
model_checkpoint = self._checkpoint()
File "/Users/haradai/miniconda3/envs/mlagents/lib/python3.10/site-packages/mlagents_envs/timers.py", line 305, in wrapped
return func(*args, **kwargs)
File "/Users/haradai/miniconda3/envs/mlagents/lib/python3.10/site-packages/mlagents/trainers/trainer/rl_trainer.py", line 144, in _checkpoint
export_path, auxillary_paths = self.model_saver.save_checkpoint(
File "/Users/haradai/miniconda3/envs/mlagents/lib/python3.10/site-packages/mlagents/trainers/model_saver/torch_model_saver.py", line 60, in save_checkpoint
self.export(checkpoint_path, behavior_name)
File "/Users/haradai/miniconda3/envs/mlagents/lib/python3.10/site-packages/mlagents/trainers/model_saver/torch_model_saver.py", line 65, in export
self.exporter.export_policy_model(output_filepath)
File "/Users/haradai/miniconda3/envs/mlagents/lib/python3.10/site-packages/mlagents/trainers/torch_entities/model_serialization.py", line 164, in export_policy_model
torch.onnx.export(
File "/Users/haradai/miniconda3/envs/mlagents/lib/python3.10/site-packages/torch/onnx/utils.py", line 516, in export
_export(
File "/Users/haradai/miniconda3/envs/mlagents/lib/python3.10/site-packages/torch/onnx/utils.py", line 1686, in _export
proto = onnx_proto_utils._add_onnxscript_fn(
File "/Users/haradai/miniconda3/envs/mlagents/lib/python3.10/site-packages/torch/onnx/_internal/onnx_proto_utils.py", line 221, in _add_onnxscript_fn
raise errors.OnnxExporterError("Module onnx is not installed!") from e
torch.onnx.errors.OnnxExporterError: Module onnx is not installed!
Environment (please complete the following information):
NOTE:
I found this issue where seems that in newer versions of onnx the error has been fixed but I cannot upgrade as mlagents needs onnx==1.12.0.
The text was updated successfully, but these errors were encountered: