I'm converting a customized Pytorch model to ONNX. However, when loading it with ONNXRuntime, I've encountered an error as follows:
onnxruntime.capi.onnxruntime_pybind11_state.RuntimeException: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Exception during initialization: ...onnxruntime/core/providers/cpu/tensor/transpose.h:46 onnxruntime::TransposeBase::TransposeBase(const onnxruntime::OpKernelInfo &) v >= 0 && static_cast<uint64_t>(v) <= std::numeric_limits<size_t>::max() was false.
I've checked with onnx.checker.check_model() and it's totally fine.
I've also tried to replace transpose() into permute() in forward() function but the error has still remained.
Is anyone familiar with this error?
Environments:
Python 3.7
Pytorch 1.9.0
CUDA 10.2
ONNX 1.10.1
ONNXRuntime 1.8.1
OS Ubuntu 18.04
The perm attribute of node Transpose_52 is [-1, 0, 1] although ONNX Runtime requires that all of them should be positive: onnxruntime/core/providers/cpu/tensor/transpose.h#L46
Related
I wrote an LSTM NLP classifier with PyTorch, in google colab and it worked well. Now, I run it on google colab pro, but I get this error:
RuntimeError: cuDNN version incompatibility: PyTorch was compiled against (8, 3, 2) but found runtime version (8, 0, 5). PyTorch already comes bundled with cuDNN. One option to resolving this error is to ensure PyTorch can find the bundled cuDNN.one possibility is that there is a conflicting cuDNN in LD_LIBRARY_PATH.
I have no idea how to fix this. I'm using GPU on colab pro.
I've tried this link and it didn't work.
How I declared device:
DEVICE = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
Fixed via upgrading cuDNN to 8.4
reference (https://github.com/JaidedAI/EasyOCR/issues/716)
if you are using google colab uae this command
!pip install --upgrade torch torchvision
Here is the model:SMSR
When I try to export the onnx model using torch.onnx.export(self.model, lr, onnx_save_path, verbose=True), the following error occurs:
TyperError: state_dict() takes 1 positional argument but 3 were given
My torch version is: 1.1.0
So, what should I do?
Thank U all!!!
Torch version is quite old, your code would run in version 1.12
I have recently updated my Pytorch version to 1.6.0 on my local machine to use their mixed-precision training, since then I am encountering this issue, I have tried the solution mentioned here, but it is still throwing below error.
RuntimeError: version_ <= kMaxSupportedFileFormatVersion INTERNAL ASSERT FAILED at /opt/conda/conda-bld/pytorch_1591914880026/work/caffe2/serialize/inline_container.cc:132, please report a bug to PyTorch. Attempted to read a PyTorch file with version 4, but the maximum supported version for reading is 3. Your PyTorch installation may be too old.
Link to reproduce: https://www.kaggle.com/rohitsingh9990/error-reproducing-code?scriptVersionId=37468859
Any help will be appreciated, thanks in advance.
In torch.__version__ == 1.6.0 :
torch.save(model_.state_dict(), 'best_model.pth.tar', use_new_zipfile_serialization=False)
then in torch.__version__ == 1.5.1:
torch.load('best_model.pth.tar',map_location='cpu')
I have installed tensorflow on a Raspberry PI 3 and it worked correctly (following these instructions). After installing a number of libraries that I needed for loading a Keras model trained on my PC (numpy, scipy etc) I have observed the following error while importing tensorflow:
Runtime Error: module compiled against API version 0xc but this version of numpy is 0xa
Segmentation fault
I have updated all the necessary libraries, and importing any of them doesn't result in an error in a Python 3 script. Also the error is not keras related, because the statement import tensorflow raises an error no matter what follows after it. Should I uninstall tensorflow and start all over again?
I am trying to run a random forest example using in tensorflow 'TensorForestEstimator'. Following is the code that I used from tensorflow git repo:
Github Code Link
Error I am getting:
File "/home/mckw9/tensorflow2/lib/python3.4/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 1363, in score
eval_results, global_step = self._estimator._evaluate_model(
AttributeError: 'TensorForestEstimator' object has no attribute '_evaluate_model'
I am using tensorflow-gpu 1.0.1, NVIDIA Titan X Pascal 12GB GDDR5X, Ubuntu 14.04, Python 3.4
The problem disappears for Tensorflow 1.1+.