Topic: GPU init problem with Avisynth, but not with Vapoursynth

Got the problem that 64bit Vapoursynth works fine with SVP (svpflow-4.2.0.142), but 32bit Avisynth+ doesn't.

using Avisynth+ 32bit with:

LoadCPlugin("I:\Hybrid\32bit\AVISYN~1\ffms2.dll")
LoadPlugin("I:\Hybrid\32bit\AVISYN~1\svpflow1.dll")
LoadPlugin("I:\Hybrid\32bit\AVISYN~1\svpflow2.dll")
Import("I:\Hybrid\32bit\avisynthPlugins\InterFrame2.avsi")
SetFilterMTMode("DEFAULT_MT_MODE", MT_MULTI_INSTANCE)
# loading source: F:\TestClips&Co\files\test.avi
#  input color sampling YV12
#  input luminance scale tv
FFVideoSource("F:\TESTCL~1\files\test.avi",cachefile="E:\Temp\avi_078c37f69bb356e7b5fa040c71584c40_41_1_0.ffindex",fpsnum=25)
# current resolution: 640x352
InterFrame(GPU=true,NewNum=60,NewDen=1,Cores=32)
# filtering
PreFetch(16)
return last

and InterFram2.avsi containing:

#------------------------------------------------------------------------------#
#                                                                              #
#                         InterFrame 2.8.2 by SubJunk                          #
#                                                                              #
#         A frame interpolation script that makes accurate estimations         #
#                   about the content of non-existent frames                   #
#      Its main use is to give videos higher framerates like newer TVs do      #
#------------------------------------------------------------------------------#


# For instructions and further information see the included InterFrame.html
# For news go to spirton.com


function InterFrame(clip Input, string "Preset", string "Tuning", int "NewNum", int "NewDen", bool "GPU", string "InputType", int "OverrideAlgo", int "OverrideArea", int "Cores", bool "FrameDouble") {
    # Defaults
    Preset        = default(Preset      , "Medium")
    NewNum        = default(NewNum      , 0       )
    NewDen        = default(NewDen      , 0       )
    Tuning        = default(Tuning      , "Film"  )
    GPU           = default(GPU         , false   )
    InputType     = default(InputType   , "2D"    )
    OverrideAlgo  = default(OverrideAlgo, 0       )
    OverrideArea  = default(OverrideArea, 0       )
    FrameDouble   = default(FrameDouble , false   )

    # Convert integers to strings
    NewNum       = String(NewNum)
    NewDen       = String(NewDen)
    OverrideAlgo = String(OverrideAlgo)
    OverrideArea = String(OverrideArea)

    # Validate inputs
    Assert(Preset == "Medium" || Preset == "Fast" || Preset == "Faster" || Preset == "Fastest", "'"+Preset+"' is not a valid preset. Please check the documentation for a list of the valid presets.")
    Assert(Tuning == "Film" || Tuning == "Smooth" || Tuning == "Animation" || Tuning == "Weak", "'"+Tuning+"' is not a valid tuning. Please check the documentation for a list of the valid tunings.")
    Assert(InputType == "2D" || InputType == "SBS" || InputType == "OU" || InputType == "HSBS" || InputType == "HOU", "'"+InputType+"' is not a valid InputType. Please check the documentation for a list of the valid InputTypes.")
    Assert(Defined(Cores), "You must enter a value for Cores. Please check the documentation for details.")

    # Get either 1 or 2 clips depending on InputType
    InputType == "SBS" ? Eval("""
        FirstEye  = InterFrameProcess(Input.crop(0            , 0, -Input.Width/2, 0), Preset=Preset, Tuning=Tuning, NewNum=NewNum, NewDen=NewDen, GPU=GPU, InputType=InputType, OverrideAlgo=OverrideAlgo, OverrideArea=OverrideArea, Cores=Cores, FrameDouble=FrameDouble)
        SecondEye = InterFrameProcess(Input.crop(Input.Width/2, 0, 0             , 0), Preset=Preset, Tuning=Tuning, NewNum=NewNum, NewDen=NewDen, GPU=GPU, InputType=InputType, OverrideAlgo=OverrideAlgo, OverrideArea=OverrideArea, Cores=Cores, FrameDouble=FrameDouble)
        StackHorizontal(FirstEye, SecondEye)
    """) : InputType == "OU" ? Eval("""
        FirstEye  = InterFrameProcess(Input.crop(0, 0             , 0, -Input.Height/2), Preset=Preset, Tuning=Tuning, NewNum=NewNum, NewDen=NewDen, GPU=GPU, InputType=InputType, OverrideAlgo=OverrideAlgo, OverrideArea=OverrideArea, Cores=Cores, FrameDouble=FrameDouble)
        SecondEye = InterFrameProcess(Input.crop(0, Input.Height/2, 0, 0              ), Preset=Preset, Tuning=Tuning, NewNum=NewNum, NewDen=NewDen, GPU=GPU, InputType=InputType, OverrideAlgo=OverrideAlgo, OverrideArea=OverrideArea, Cores=Cores, FrameDouble=FrameDouble)
        StackVertical(FirstEye, SecondEye)
    """) : InputType == "HSBS" ? Eval("""
        FirstEye  = InterFrameProcess(Input.crop(0            , 0, -Input.Width/2, 0).Spline36Resize(Input.Width, Input.Height), Preset=Preset, Tuning=Tuning, NewNum=NewNum, NewDen=NewDen, GPU=GPU, InputType=InputType, OverrideAlgo=OverrideAlgo, OverrideArea=OverrideArea, Cores=Cores, FrameDouble=FrameDouble)
        SecondEye = InterFrameProcess(Input.crop(Input.Width/2, 0, 0             , 0).Spline36Resize(Input.Width, Input.Height), Preset=Preset, Tuning=Tuning, NewNum=NewNum, NewDen=NewDen, GPU=GPU, InputType=InputType, OverrideAlgo=OverrideAlgo, OverrideArea=OverrideArea, Cores=Cores, FrameDouble=FrameDouble)
        StackHorizontal(FirstEye.Spline36Resize(Input.Width/2, Input.Height), SecondEye.Spline36Resize(Input.Width/2, Input.Height))
    """) : InputType == "HOU" ? Eval("""
        FirstEye  = InterFrameProcess(Input.crop(0, 0             , 0, -Input.Height/2).Spline36Resize(Input.Width, Input.Height), Preset=Preset, Tuning=Tuning, NewNum=NewNum, NewDen=NewDen, GPU=GPU, InputType=InputType, OverrideAlgo=OverrideAlgo, OverrideArea=OverrideArea, Cores=Cores, FrameDouble=FrameDouble)
        SecondEye = InterFrameProcess(Input.crop(0, Input.Height/2, 0, 0              ).Spline36Resize(Input.Width, Input.Height), Preset=Preset, Tuning=Tuning, NewNum=NewNum, NewDen=NewDen, GPU=GPU, InputType=InputType, OverrideAlgo=OverrideAlgo, OverrideArea=OverrideArea, Cores=Cores, FrameDouble=FrameDouble)
        StackVertical(FirstEye.Spline36Resize(Input.Width, Input.Height/2), SecondEye.Spline36Resize(Input.Width, Input.Height/2))
    """) : Eval("""
        InterFrameProcess(Input, Preset=Preset, Tuning=Tuning, NewNum=NewNum, NewDen=NewDen, GPU=GPU, InputType=InputType, OverrideAlgo=OverrideAlgo, OverrideArea=OverrideArea, Cores=Cores, FrameDouble=FrameDouble)
    """)
}

function InterFrameProcess(clip Input, string "Preset", string "Tuning", string "NewNum", string "NewDen", bool "GPU", string "InputType", string "OverrideAlgo", string "OverrideArea", int "Cores", bool "FrameDouble") {
    # Create SuperString
    Preset == "Fastest" ? Eval("""
        SuperString = "{pel:2,"
    """) : Preset == "Fast" || Preset == "Faster" ? Eval("""
        SuperString = "{pel:1,"
    """) : Eval("""
        SuperString = "{"
    """)

    GPU == true ? Eval("""
        SuperString = SuperString + "scale:{up:0,down:4},gpu:1,rc:false}"
    """) : Eval("""
        SuperString = SuperString + "scale:{up:2,down:4},gpu:0,rc:false}"
    """)

    # Create VectorsString
    Tuning == "Animation" || Preset == "Fastest" ? Eval("""
        VectorsString = "{block:{w:32,"
    """) : Tuning == "Fast" || Preset == "Faster" || GPU == false ? Eval("""
        VectorsString = "{block:{w:16,"
    """) : Eval("""
        VectorsString = "{block:{w:8,"
    """)

    Tuning == "Animation" || Tuning == "Fastest" ? Eval("""
        VectorsString = VectorsString + "overlap:0"
    """) : Preset == "Faster" && GPU == true ? Eval("""
        VectorsString = VectorsString + "overlap:1"
    """) : Eval("""
        VectorsString = VectorsString + "overlap:2"
    """)

    Tuning == "Animation" ? Eval("""
        VectorsString = VectorsString + "},main:{search:{coarse:{type:2,"
    """) : Preset == "Faster" ? Eval("""
        VectorsString = VectorsString + "},main:{search:{coarse:{"
    """) : Eval("""
        VectorsString = VectorsString + "},main:{search:{distance:0,coarse:{"
    """)

    Tuning == "Animation" ? Eval("""
        VectorsString = VectorsString + "distance:-6,satd:false},distance:0,"
    """) : Tuning == "Weak" ? Eval("""
        VectorsString = VectorsString + "distance:-1,trymany:true,"
    """) : Eval("""
        VectorsString = VectorsString + "distance:-10,"
    """)

    Tuning == "Animation" || Preset == "Faster" || Preset == "Fastest" ? Eval("""
        VectorsString = VectorsString + "bad:{sad:2000}}}}}"
    """) : Tuning == "Weak" ? Eval("""
        VectorsString = VectorsString + "bad:{sad:2000}}}},refine:[{thsad:250,search:{distance:-1,satd:true}}]}"
    """) : Eval("""
        VectorsString = VectorsString + "bad:{sad:2000}}}},refine:[{thsad:250}]}"
    """)

    # Create SmoothString
    NewNum != "0" ? Eval("""
        SmoothString = "{rate:{num:"+NewNum+",den:"+NewDen+",abs:true},"
    """) : Input.Framerate == 15 || Input.Framerate == 25 || Input.Framerate == 30 || FrameDouble == true ? Eval("""
        SmoothString = "{rate:{num:2,den:1,abs:false},"
    """) : Eval("""
        SmoothString = "{rate:{num:60000,den:1001,abs:true},"
    """)

    OverrideAlgo != "0" ? Eval("""
        SmoothString = SmoothString + "algo:"+OverrideAlgo+",mask:{cover:80,"
    """) : Tuning == "Animation" ? Eval("""
        SmoothString = SmoothString + "algo:2,mask:{"
    """) : Tuning == "Smooth" ? Eval("""
        SmoothString = SmoothString + "algo:23,mask:{"
    """) : Eval("""
        SmoothString = SmoothString + "algo:13,mask:{cover:80,"
    """)

    OverrideArea != "0" ? Eval("""
        SmoothString = SmoothString + "area:"+OverrideArea
    """) : Tuning == "Smooth" ? Eval("""
        SmoothString = SmoothString + "area:150"
    """) : Eval("""
        SmoothString = SmoothString + "area:0"
    """)

    Tuning == "Weak" ? Eval("""
        SmoothString = SmoothString + ",area_sharp:1.2},scene:{blend:true, mode:0, limits: {blocks: 50}}}"
    """) : Eval("""
        SmoothString = SmoothString + ",area_sharp:1.2},scene:{blend:true, mode:0}}"
    """)

    # Make interpolation vector clip
    Super   = SVSuper(Input, SuperString)
    Vectors = SVAnalyse(Super, VectorsString)

    # Put it together
    smooth_video = SVSmoothFps(Input, Super, Vectors, SmoothString, url="www.svp-team.com", mt=Cores)
    smooth_video
}

I get:

SVSmoothFps: unable to init GPU-based renderer [code 0x10000]

using 64bit Vapoursynth and

# Imports
import os
import sys
import vapoursynth as vs
core = vs.get_core()
# Import scripts folder
scriptPath = 'I:/Hybrid/64bit/vsscripts'
sys.path.append(os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/FrameFilter/Interframe/svpflow2_vs64.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/FrameFilter/Interframe/svpflow1_vs64.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/FFMS2/ffms2k.dll")
# Import scripts
import havsfunc
# Loading F:\TestClips&Co\files\test.avi using FFMS2K
clip = core.ffms2.Source(source="F:/TESTCL~1/files/test.avi",cachefile="E:/Temp/avi_078c37f69bb356e7b5fa040c71584c40_41.ffindex",format=vs.YUV420P8,alpha=False)
# making sure input color matrix is set as unspec
clip = core.resize.Point(clip, matrix_in_s="unspec",range_s="limited")
# making sure frame rate is set to 25/1
clip = core.std.AssumeFPS(clip, fpsnum=25, fpsden=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# adjusting frame count with Interframe/SVP
clip = havsfunc.InterFrame(clip, NewNum=60, NewDen=1, GPU=True)
# Output
clip.set_output()

with havsfunc.InterFrame being:

#------------------------------------------------------------------------------#
#                                                                              #
#                         InterFrame 2.8.2 by SubJunk                          #
#                                                                              #
#         A frame interpolation script that makes accurate estimations         #
#                   about the content of non-existent frames                   #
#      Its main use is to give videos higher framerates like newer TVs do      #
#------------------------------------------------------------------------------#
#
#
# For instructions and further information see the included InterFrame.html
# For news go to spirton.com
def InterFrame(Input, Preset='Medium', Tuning='Film', NewNum=None, NewDen=1, GPU=False, InputType='2D', OverrideAlgo=None, OverrideArea=None,
               FrameDouble=False):
    if not isinstance(Input, vs.VideoNode):
        raise TypeError('InterFrame: This is not a clip')

    # Validate inputs
    Preset = Preset.lower()
    Tuning = Tuning.lower()
    InputType = InputType.upper()
    if Preset not in ['medium', 'fast', 'faster', 'fastest']:
        raise ValueError("InterFrame: '{Preset}' is not a valid preset".format(Preset=Preset))
    if Tuning not in ['film', 'smooth', 'animation', 'weak']:
        raise ValueError("InterFrame: '{Tuning}' is not a valid tuning".format(Tuning=Tuning))
    if InputType not in ['2D', 'SBS', 'OU', 'HSBS', 'HOU']:
        raise ValueError("InterFrame: '{InputType}' is not a valid InputType".format(InputType=InputType))

    def InterFrameProcess(clip):
        # Create SuperString
        if Preset in ['fast', 'faster', 'fastest']:
            SuperString = '{pel:1,'
        else:
            SuperString = '{'

        SuperString += 'gpu:1}' if GPU else 'gpu:0}'

        # Create VectorsString
        if Tuning == 'animation' or Preset == 'fastest':
            VectorsString = '{block:{w:32,'
        elif Preset in ['fast', 'faster'] or not GPU:
            VectorsString = '{block:{w:16,'
        else:
            VectorsString = '{block:{w:8,'

        if Tuning == 'animation' or Preset == 'fastest':
            VectorsString += 'overlap:0'
        elif Preset == 'faster' and GPU:
            VectorsString += 'overlap:1'
        else:
            VectorsString += 'overlap:2'

        if Tuning == 'animation':
            VectorsString += '},main:{search:{coarse:{type:2,'
        elif Preset == 'faster':
            VectorsString += '},main:{search:{coarse:{'
        else:
            VectorsString += '},main:{search:{distance:0,coarse:{'

        if Tuning == 'animation':
            VectorsString += 'distance:-6,satd:false},distance:0,'
        elif Tuning == 'weak':
            VectorsString += 'distance:-1,trymany:true,'
        else:
            VectorsString += 'distance:-10,'

        if Tuning == 'animation' or Preset in ['faster', 'fastest']:
            VectorsString += 'bad:{sad:2000}}}}}'
        elif Tuning == 'weak':
            VectorsString += 'bad:{sad:2000}}}},refine:[{thsad:250,search:{distance:-1,satd:true}}]}'
        else:
            VectorsString += 'bad:{sad:2000}}}},refine:[{thsad:250}]}'

        # Create SmoothString
        if NewNum is not None:
            SmoothString = '{rate:{num:' + repr(NewNum) + ',den:' + repr(NewDen) + ',abs:true},'
        elif clip.fps_num / clip.fps_den in [15, 25, 30] or FrameDouble:
            SmoothString = '{rate:{num:2,den:1,abs:false},'
        else:
            SmoothString = '{rate:{num:60000,den:1001,abs:true},'

        if OverrideAlgo is not None:
            SmoothString += 'algo:' + repr(OverrideAlgo) + ',mask:{cover:80,'
        elif Tuning == 'animation':
            SmoothString += 'algo:2,mask:{'
        elif Tuning == 'smooth':
            SmoothString += 'algo:23,mask:{'
        else:
            SmoothString += 'algo:13,mask:{cover:80,'

        if OverrideArea is not None:
            SmoothString += 'area:{OverrideArea}'.format(OverrideArea=OverrideArea)
        elif Tuning == 'smooth':
            SmoothString += 'area:150'
        else:
            SmoothString += 'area:0'

        if Tuning == 'weak':
            SmoothString += ',area_sharp:1.2},scene:{blend:true,mode:0,limits:{blocks:50}}}'
        else:
            SmoothString += ',area_sharp:1.2},scene:{blend:true,mode:0}}'

        # Make interpolation vector clip
        Super = core.svp1.Super(clip, SuperString)
        Vectors = core.svp1.Analyse(Super['clip'], Super['data'], clip, VectorsString)

        # Put it together
        return core.svp2.SmoothFps(clip, Super['clip'], Super['data'], Vectors['clip'], Vectors['data'], SmoothString)

    # Get either 1 or 2 clips depending on InputType
    if InputType == 'SBS':
        FirstEye = InterFrameProcess(core.std.Crop(Input, right=Input.width // 2))
        SecondEye = InterFrameProcess(core.std.Crop(Input, left=Input.width // 2))
        return core.std.StackHorizontal([FirstEye, SecondEye])
    elif InputType == 'OU':
        FirstEye = InterFrameProcess(core.std.Crop(Input, bottom=Input.height // 2))
        SecondEye = InterFrameProcess(core.std.Crop(Input, top=Input.height // 2))
        return core.std.StackVertical([FirstEye, SecondEye])
    elif InputType == 'HSBS':
        FirstEye = InterFrameProcess(core.std.Crop(Input, right=Input.width // 2).resize.Spline36(Input.width, Input.height))
        SecondEye = InterFrameProcess(core.std.Crop(Input, left=Input.width // 2).resize.Spline36(Input.width, Input.height))
        return core.std.StackHorizontal([core.resize.Spline36(FirstEye, Input.width // 2, Input.height),
                                         core.resize.Spline36(SecondEye, Input.width // 2, Input.height)])
    elif InputType == 'HOU':
        FirstEye = InterFrameProcess(core.std.Crop(Input, bottom=Input.height // 2).resize.Spline36(Input.width, Input.height))
        SecondEye = InterFrameProcess(core.std.Crop(Input, top=Input.height // 2).resize.Spline36(Input.width, Input.height))
        return core.std.StackVertical([core.resize.Spline36(FirstEye, Input.width, Input.height // 2),
                                       core.resize.Spline36(SecondEye, Input.width, Input.height // 2)])
    else:
        return InterFrameProcess(Input)

Works fine.
Any clue why using Avisynth fails and using Vapoursynth works? Reinstalling drivers didn't help.
(Using Win10 pro 64bit as OS.)

Cu Selur

Re: GPU init problem with Avisynth, but not with Vapoursynth

> Any clue why using Avisynth fails and using Vapoursynth works?

most obvious - Avisynth 32-bit, Vapoursynth 64-bit

Re: GPU init problem with Avisynth, but not with Vapoursynth

Any idea how to fix or debug  the 32bit handling?

Re: GPU init problem with Avisynth, but not with Vapoursynth

SVP package contains a console 'clinfo' tool, both 32- and 64-bit located in the 'utils' subfolder to check if OpenCL subsystems are working correctly.

Re: GPU init problem with Avisynth, but not with Vapoursynth

Meanwhile I did some testing and noticed that the problem only occurs with Avisynth+ (r2772, MT), while when using the old Avisynth MT 2.6.0.5 the problem doesn't occur.
-> seems like it's some incompatibility between Avisynth+ and the Avisynth SVP filters.