Asd-g / avs-mlrt

ML Runtimes for AviSynth+.
GNU General Public License v3.0
19 stars 0 forks source link

[mlrt_ort] Error with parameter device=1 #10

Closed kedaitinh12 closed 8 months ago

kedaitinh12 commented 9 months ago

I try with parameter device=1 (cause with device=0, the provider=mlt always chooses my iGPU), my dGPU starts with using vram but i meet this error image

My script: LoadPlugin("C:\Encode Tools\MeGUI-2944-64\tools\ffms\ffms2.dll") FFImageSource("C:\Users\ADMIN\Downloads\LCFome7.jpeg") z_ConvertFormat(pixel_type="rgbps", colorspace_op="709:709:709:l=>rgb:709:709:f") mlrt_ort(network_path="C:/Program Files (x86)/AviSynth+/plugins64+/models/RealESRGAN/RealESRGAN_x4plus_anime_6B.onnx", builtin=false, fp16=true, provider="dml", device=1) propSet("_FieldBased",0) deep_resize(1920,1080,grain=0) z_ConvertFormat(pixel_type="yuv420p8", colorspace_op="rgb:709:709:f=>709:709:709:l")

when i change to mlrt_ort(network_path="C:/Program Files (x86)/AviSynth+/plugins64+/models/RealESRGAN/RealESRGAN_x4plus_anime_6B.onnx", builtin=false, fp16=true, provider="dml", device=1, tilesize_w=width/2, tilesize_h=height/2), the script works so I think it relates my dedicated GPU memory not enough but I can launch the script even use shared GPU memory in Vapoursynth version

Asd-g commented 9 months ago

Try with the attached DirectML.dll.

DirectML.zip

kedaitinh12 commented 9 months ago

same error

Asd-g commented 9 months ago

Can you share RealESRGAN_x4plus_anime_6B.onnx ?

kedaitinh12 commented 9 months ago

here RealESRGAN_x4plus_anime_6B.zip

Asd-g commented 9 months ago

Thanks.

Are you sure that the vs version is running without specifying tilesize and with the same gpu selected?

kedaitinh12 commented 9 months ago

yes, sample preview work + script + GPU usage in the image below image

Asd-g commented 9 months ago

You're using a wrapper. Can you try with core.ort.Model(....) ?

kedaitinh12 commented 9 months ago

I use Hybrid so I know about this app. If I add title size the script will like this image

Asd-g commented 8 months ago

Please redownload runtime files from Releases and follow the updated guide about the runtime files.

kedaitinh12 commented 8 months ago

I do like you but both Cuda and DML don't work now LoadPlugin("C:\Encode Tools\MeGUI-2944-64\tools\ffms\ffms2.dll") FFImageSource("C:\Users\ADMIN\Downloads\LCFome7.jpeg") z_ConvertFormat(pixel_type="rgbps", colorspace_op="709:709:709:l=>rgb:709:709:f") mlrt_ort(network_path="C:/Program Files (x86)/AviSynth+/plugins64+/models/RealESRGAN/RealESRGAN_x4plus_anime_6B.onnx", builtin=false, fp16=true, provider="cuda", device=0) propSet("_FieldBased",0) deep_resize(1920,1080,grain=0) z_ConvertFormat(pixel_type="yuv420p8", colorspace_op="rgb:709:709:f=>709:709:709:l") image LoadPlugin("C:\Encode Tools\MeGUI-2944-64\tools\ffms\ffms2.dll") FFImageSource("C:\Users\ADMIN\Downloads\LCFome7.jpeg") z_ConvertFormat(pixel_type="rgbps", colorspace_op="709:709:709:l=>rgb:709:709:f") mlrt_ort(network_path="C:/Program Files (x86)/AviSynth+/plugins64+/models/RealESRGAN/RealESRGAN_x4plus_anime_6B.onnx", builtin=false, fp16=true, provider="dml", device=1) propSet("_FieldBased",0) deep_resize(1920,1080,grain=0) z_ConvertFormat(pixel_type="yuv420p8", colorspace_op="rgb:709:709:f=>709:709:709:l") image My mlrt_ort_loader.avsi LoadDLL(".\ort_dll\cublasLt64_12.dll") LoadDLL(".\ort_dll\cudart64_12.dll") LoadDLL(".\ort_dll\cublas64_12.dll") LoadDLL(".\ort_dll\cufft64_11.dll") LoadDLL(".\ort_dll\cudnn_ops_infer64_8.dll") LoadDLL(".\ort_dll\cudnn_cnn_infer64_8.dll") LoadDLL(".\ort_dll\cudnn_adv_infer64_8.dll") LoadDLL(".\ort_dll\DirectML.dll") LoadDLL(".\ort_dll\onnxruntime.dll") LoadPlugin("mlrt_ort.dll")

Asd-g commented 8 months ago

Is there error if tilesize_... is used?

kedaitinh12 commented 8 months ago

Is there error if tilesize_... is used?

with runtimes files before, i can work with Cuda ver without tilesize by just putting all files into plugins64+

kedaitinh12 commented 8 months ago

Yeah, same error with tilesize LoadPlugin("C:\Encode Tools\MeGUI-2944-64\tools\ffms\ffms2.dll") FFImageSource("C:\Users\ADMIN\Downloads\LCFome7.jpeg") z_ConvertFormat(pixel_type="rgbps", colorspace_op="709:709:709:l=>rgb:709:709:f") mlrt_ort(network_path="C:/Program Files (x86)/AviSynth+/plugins64+/models/RealESRGAN/RealESRGAN_x4plus_anime_6B.onnx", builtin=false, fp16=true, provider="dml", device=1, tilesize_w=width/2, tilesize_h=height/2) propSet("_FieldBased",0) deep_resize(1920,1080,grain=0) z_ConvertFormat(pixel_type="yuv420p8", colorspace_op="rgb:709:709:f=>709:709:709:l")

Asd-g commented 8 months ago

Try with edited mlrt_ort_loader.avsi to

LoadDLL(".\ort_dll\DirectML.dll")
LoadDLL(".\ort_dll\onnxruntime.dll")
LoadPlugin("mlrt_ort.dll")
kedaitinh12 commented 8 months ago

same error

kedaitinh12 commented 8 months ago

I tried to delete mlrt_ov_loader.avsi and mlrt_ort_loader.avsi. Put all runtime files to plugins64+ and use onnxruntime_only_dml.zip, DML works with this script now (without tilesize) LoadPlugin("C:\Encode Tools\MeGUI-2944-64\tools\ffms\ffms2.dll") FFImageSource("C:\Users\ADMIN\Downloads\LCFome7.jpeg") z_ConvertFormat(pixel_type="rgbps", colorspace_op="709:709:709:l=>rgb:709:709:f") mlrt_ort(network_path="C:/Program Files (x86)/AviSynth+/plugins64+/models/RealESRGAN/RealESRGAN_x4plus_anime_6B.onnx", builtin=false, fp16=true, provider="dml", device=1) propSet("_FieldBased",0) deep_resize(1920,1080,grain=0) z_ConvertFormat(pixel_type="yuv420p8", colorspace_op="rgb:709:709:f=>709:709:709:l")

kedaitinh12 commented 8 months ago

Next, I put the old onnx runtime back, and Cuda works now (deleted mlrt_ov_loader.avsi and mlrt_ort_loader.avsi. Put all runtime files to plugins64+). Openvino works with and without putting all runtime files in the plugins64+ (if without, need mlrt_ort_loader.avsi to load all runtime files)

Asd-g commented 8 months ago

If you have Windows shipped directml.dll in C:\Windows\System32\directml.dll can you rename that file to C:\Windows\System32\directml_.dll and try onnxruntime.dll from Release (not onnxruntime_only_dml.zip)?

Edit: In Windows 11 check also for file C:\Windows\System32\onnxruntime.dll. If there is such file renamed to C:\Windows\System32\onnxruntime.dll and try onnxruntime.dll from Release (not onnxruntime_only_dml.zip).

kedaitinh12 commented 8 months ago

If you have Windows shipped directml.dll in C:\Windows\System32\directml.dll can you rename that file to C:\Windows\System32\directml_.dll and try onnxruntime.dll from Release (not onnxruntime_only_dml.zip)?

Edit: In Windows 11 check also for file C:\Windows\System32\onnxruntime.dll. If there is such file renamed to C:\Windows\System32\onnxruntime.dll and try onnxruntime.dll from Release (not onnxruntime_only_dml.zip).

after changing those names, the error is still the same as DML if I don't use onnxruntime_only_dml.zip

Asd-g commented 8 months ago

Ok, thanks for the feedback.

Asd-g commented 8 months ago

Can you test the attached versions too?

onnxruntime_m.zip onnxruntime_n.zip

kedaitinh12 commented 8 months ago

Can you test the attached versions too?

onnxruntime_m.zip onnxruntime_n.zip

What's m and n?

kedaitinh12 commented 8 months ago

Both have the same error but the error call is from mlrt_ov, I don't know why it's mlrt_ov when I don't call this function (download the image to see cause the image has very many of text) New File000000_1 My script: LoadPlugin("C:\Encode Tools\MeGUI-2944-64\tools\ffms\ffms2.dll") FFImageSource("C:\Users\ADMIN\Downloads\LCFome7.jpeg") z_ConvertFormat(pixel_type="rgbps", colorspace_op="709:709:709:l=>rgb:709:709:f") mlrt_ort(network_path="C:/Program Files (x86)/AviSynth+/plugins64+/models/RealESRGAN/RealESRGAN_x4plus_anime_6B.onnx", builtin=false, fp16=true, provider="dml", device=1) propSet("_FieldBased",0) deep_resize(1920,1080,grain=0) z_ConvertFormat(pixel_type="yuv420p8", colorspace_op="rgb:709:709:f=>709:709:709:l")

Asd-g commented 8 months ago

Filenames are just marks to know which file what build config has.

Can you test this? Also use the attached DirectML.dll with the attached onnxruntime.dll.

build.zip

kedaitinh12 commented 8 months ago

Filenames are just marks to know which file what build config has.

Can you test this? Also use the attached DirectML.dll with the attached onnxruntime.dll.

build.zip same error with those files and my script New File000000_1

SangenBR commented 8 months ago

Filenames are just marks to know which file what build config has. Can you test this? Also use the attached DirectML.dll with the attached onnxruntime.dll. build.zip same error with those files and my script New File000000_1

the same error I have

Asd-g commented 8 months ago

Can you test the attached versions?

build1.zip

SangenBR commented 8 months ago

still with the same error

Asd-g commented 8 months ago

Can you share short sample with the used script and model so I can reproduce the issue?

SangenBR commented 8 months ago

Sure.

SetMemoryMax(8192)

##Load source

DGSource("D:\Encodes\The Guts\01\01.dgi")

#Detint

AnimeIVTC(mode=1,ifade=true,nnedi3pel=true,stabilize=true,aapel=4,smooth=-1,tradius=3,ediandnn=3,degrain=3,threads=12)
#AnimeIVTC(mode=2,bbob=4,ifade=true,nnedi3pel=true,stabilize=true,aapel=4,smooth=-1,tradius=3,ediandnn=3,degrain=3,threads=12,cach

ConvertBits(32)
ConvertToPlanarRGB()
mlrt_ort(network_path="C:\Program Files (x86)\AviSynth+\plugins64\models\onnx\1x_Dotzilla_Compact_80k_net_g.onnx",builtin=false,provider="dml")
ConvertBits(8).ConvertToYV12()

#Crop(6,0,-6,0)
#Fixer(2,0,0,0,chroma=true)

blackmanresizeMT(1416,1080,taps=8,threads=12)

1x_Dotzilla_Compact_80k_net_g.zip

https://openmodeldb.info/models/1x-Dotzilla-Compact

Asd-g commented 8 months ago

Thanks. What is the resolution of the clip?

SangenBR commented 8 months ago

Thanks. What is the resolution of the clip?

720x480

Asd-g commented 8 months ago

Can you test the following script:

BlankClip(pixel_type="rgbps") # If still error test with BlankClip(pixel_type="rgbps", width=240, height=120)
mlrt_ort(network_path="C:\Program Files (x86)\AviSynth+\plugins64\models\onnx\1x_Dotzilla_Compact_80k_net_g.onnx",builtin=false,provider="dml")
SangenBR commented 8 months ago

the tragedy continues my friend Captura de tela 2024-02-15 172244

Asd-g commented 8 months ago

Rename C:\Windows\System32\directml.dll to C:\Windows\System32\directml_.dll and try again.

SangenBR commented 8 months ago

now avspmod closes by itself

Asd-g commented 8 months ago

Use the attached mlrt_ort.dll. Make sure DirectML.dll and onnxruntime.dll are in same folder.

mlrt_ort.zip

SangenBR commented 8 months ago

Captura de tela 2024-02-15 181746

Asd-g commented 8 months ago

Rename C:\Windows\System32\onnxruntime.dll to C:\Windows\System32\onnxruntime_.dll and try again.

SangenBR commented 8 months ago

same mistake

Asd-g commented 8 months ago

Remove mlrt_ort_loader.avsi if you have it. Remove all onnxruntime.dll, DirectML.dll, onnxruntime_xxx.dll and all cuda runtime files from your plugins folder. Put the attached DirectML.dll and onnxruntime.dll next to downloaded mlrt_ort.dll test version.

native.zip

SangenBR commented 8 months ago

it was fun Captura de tela 2024-02-15 185604

Asd-g commented 8 months ago

Thanks for the testing. What's the performance? Better than mlrt_ncnn?

SangenBR commented 8 months ago

yes and a little faster also uses less vram

SangenBR commented 8 months ago

I saw now that you asked in the other closed topic, which windows do I use

I use Windows 11 latest version

Asd-g commented 8 months ago

These Windows versions have onnxruntime.dll and DirectML.dll in System32and they can be loaded instead of the correct one.

Asd-g commented 8 months ago

@SangenBR, can you test the attached onnxruntime.dll and DirectML.dll? Just replace the existing ones with the attached version.

build1.zip

SangenBR commented 8 months ago

@SangenBR, can you test the attached onnxruntime.dll and DirectML.dll? Just replace the existing ones with the attached version.

build1.zip

It doesn't work, the same error as above

Asd-g commented 8 months ago

Ok.

SangenBR commented 8 months ago

What works for me and this one from the attachment I would say it is 10 to 20% compared to mlrt_ncnn plugins64.zip