Why does trying to render with Cuda on a remote server fail?
I don't know your specific error code, getting this ***** to run on server took me forever. What helped was getting the latest Daily Build and installing it instead of the default blender package. Also try a similar code to mine if nothing works (mine works for two Titans XP's, you'll have to rewrite it for your GPUs I guess).  If I remember correctly enabling all devices enabled CPU and caused blender to only use that.

def gpuSettings():
    bpy.context.scene.render.engine = 'CYCLES'
    bpy.data.scenes["Scene"].cycles.device = 'GPU'
    bpy.data.scenes["Scene"].cycles.feature_set = 'SUPPORTED'
    bpy.context.user_preferences.addons['cycles'].preferences.compute_device_type = 'CUDA'

    # Switch render engine to cycles
    cprefs = bpy.context.user_preferences.addons['cycles'].preferences

    for device in cprefs.devices:
        if device.name == 'TITAN Xp':
            device.use = True
        else:
            device.use = False

    #print('Compute_device_type: ', cprefs.compute_device_type)
    for device in cprefs.devices:
        if device.use == True:
            print('USED: ', device.name)
        else:
            print('NOT_USED: ', device.name)
    print('Will be used: ' + bpy.data.scenes["Scene"].cycles.device)
    print('Feature set: ' + bpy.data.scenes["Scene"].cycles.feature_set)
    print('Render engine: ' + bpy.context.scene.render.engine)
    return