masahi edited a comment on issue #7363:
URL: https://github.com/apache/tvm/issues/7363#issuecomment-770353594


   @tqchen @zhiics I investigated this issue and I think I have a solution. 
Running `test_object_detection.py` indeed results in a segfault at the end, 
after correct execution. I didn't notice this segfault before because I was 
running a different script when I was working on optimizing MaskRCNN.
   
   Now, I wondered why running one script results in the segfault, while the 
other doesn't, when two scripts do essentially the same thing. And then I 
remembered the ONNX + PyTorch segfault problem, which was caused by pytorch 
being imported earlier than ONNX, see 
https://github.com/onnx/onnx/issues/2394#issuecomment-581638840
   
   `test_object_detection.py` indeed imports pytorch before TVM, while my other 
script imports TVM first. So I simply swap the import order in 
`test_object_detection.py` , and the segfault is gone. If I import torch first 
in my other scripts, segfault now happens, as expected. I can 100% reproduce 
this issue of segfault and import order. 
   
   Conclusion: When using PyTorch 1.7 + CUDA, always import TVM first, before 
torch. PR https://github.com/apache/tvm/pull/7380 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to