djl icon indicating copy to clipboard operation
djl copied to clipboard

It seems to be some problems when load faster Rcnn by pytorch model

Open yang162132 opened this issue 3 years ago • 10 comments

MVSZVGQQ~LJC9QZM (NL}H3 N08J Q1I1B PN$Y~TME)9YA When I load a faster rcnn model from pytorch's TorchScript model It says unknows torchvision::nms

yang162132 avatar Apr 08 '22 03:04 yang162132

@yang162132 Thanks for reporting the issue. It is expected as the NMS operator is implemented in TorchVision and not part of libtorch.

stu1130 avatar Apr 08 '22 04:04 stu1130

@yang162132 We current don't support torchvision/torchtext, see: #1394

frankfliu avatar Apr 08 '22 05:04 frankfliu

@frankfliu Is there some ways to use torchvision.dll?

yang162132 avatar Apr 08 '22 10:04 yang162132

torchvision.dll depends on python, I didn't find a way to load into Java process.

frankfliu avatar Apr 10 '22 03:04 frankfliu

OH, that's terrible, it's seem that hard to use faster rcnn model trained by pytorch

yang162132 avatar Apr 10 '22 05:04 yang162132

Hello guys, any news on that issue? I saw the issue you linked on torch's side was resolved: https://github.com/pytorch/vision/issues/2692 I got a similar issue (just another operation missing) when scripting a model including the torchvision transforms and I am hoping that this will be resolved once you guys release PyTorch engine building for their version 1.12.1? Thanks in advance!

aditen avatar Aug 14 '22 16:08 aditen

@aditen Will revisit this issue.

At the mean time, can you try to load torchvision with DJL use:

export PYTORCH_EXTRA_LIBRARY_PATH=python3.9/site-packages/torchvision/_C.so

frankfliu avatar Aug 14 '22 16:08 frankfliu

@frankfliu Thanks a lot for your support! This env variable resolved my issue of using scriptable transforms in my model. On my Windows environment the file extension of the _C file turned out to be .pyd, but worked just as well.

As we plan to use DJL in combination with torchvision in a docker environment, it would be a bit complicated to deploy it this way as it requires including the .so file specifically as I understand it. Is there a chance of this becoming part of the DJI pytorch package or maybe an additional/extended maven package?

aditen avatar Aug 17 '22 10:08 aditen

@frankfliu Thanks a lot for your support! This env variable resolved my issue of using scriptable transforms in my model. On my Windows environment the file extension of the _C file turned out to be .pyd, but worked just as well.

As we plan to use DJL in combination with torchvision in a docker environment, it would be a bit complicated to deploy it this way as it requires including the .so file specifically as I understand it. Is there a chance of this becoming part of the DJI pytorch package or maybe an additional/extended maven package?

Hey! @aditen How did you do that.I tried it but no success.

play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[EngineException: Failed to load PyTorch native library]]
	at play.api.http.HttpErrorHandlerExceptions$.$anonfun$convertToPlayException$2(HttpErrorHandler.scala:381)
Caused by: ai.djl.engine.EngineException: Failed to load PyTorch native library
	at ai.djl.pytorch.engine.PtEngine.newInstance(PtEngine.java:90)
	at ai.djl.pytorch.engine.PtEngineProvider.getEngine(PtEngineProvider.java:40)
	at ai.djl.engine.Engine.getEngine(Engine.java:187)
	at ai.djl.engine.Engine.getInstance(Engine.java:142)
	at ai.djl.ndarray.NDManager.newBaseManager(NDManager.java:130)
Caused by: java.lang.UnsatisfiedLinkError: D:\ProgramData\Anaconda3\envs\torch\Lib\site-packages\torchvision\_C.pyd: 找不到指定的程序。

yang162132 avatar Jan 11 '24 07:01 yang162132

@yang162132 Can you use dumpbin to check if all torchvision dll dependencies are in the PATH

frankfliu avatar Jan 12 '24 17:01 frankfliu