Hello, I am facing PyNvVideoCodec library crash on video reading with floating point exception. This is happening on only particular video and on only linux. I have attached the test script, video file.
toolkit: NVIDIA Container Toolkit CLI version 1.18.1
container: nvcr.io/nvidia/cuda:13.0.2-cudnn-devel-ubuntu24.04
python test2.py fault_1.mp4 3488
test script and media file attached
test script:
import os
import sys
from datetime import datetime, timedelta
from sys import argv
from threading import Thread
from time import sleep
import PyNvVideoCodec as nvc
import numpy as np
import pycuda.autoprimaryctx as ctx_module
from psutil import Process
if sys.platform == “linux”:
pass
import pycuda.driver as cuda
if name == ‘main’:
try:
mediaPath = argv[1]
mediaLength = (int)(argv[2])
videoParts = []
videoPartsSize = 300
totalBatchSize = 16
decodeCacheSize = 4
videoPartOverlapFrameCount = 30
GPUMaxCachedFramesPerVideoPart = 56
partSize = videoPartsSize if np.ceil(mediaLength / videoPartsSize) <= totalBatchSize else int( np.ceil(mediaLength / totalBatchSize))
progressPingExpireDuration: timedelta = timedelta(seconds=(10)) # adjust this duration based on batch size and segment duration of transcriber, calculated through experiment on gpu and cpu
progressPingRecievedTime = datetime.now()
def pingRecievedCallback():
global progressPingRecievedTime
progressPingRecievedTime = datetime.now()
stopPingThread = False
def killProcessOnPingExpire():
while not stopPingThread:
currentTime = datetime.now()
pingExpiryTime = progressPingRecievedTime + progressPingExpireDuration
pingExpired = currentTime > pingExpiryTime
if pingExpired:
Process(os.getpid()).terminate()
sleep(0.4)
Thread(target=killProcessOnPingExpire).start()
cuda_ctx = ctx_module.context
cuda_ctx.push()
cuda_stream = cuda.Stream() # Single stream since global lock ensures one decoder at a time
try:
decoder = nvc.SimpleDecoder(enc_file_path=mediaPath, cuda_context=cuda_ctx.handle,
cuda_stream=cuda_stream.handle,
use_device_memory=True,
max_width=3840,
max_height=3840,
decoder_cache_size=decodeCacheSize,
output_color_type=nvc.OutputColorType.RGB)
for i in range(int(np.ceil(mediaLength / partSize))):
videoPartStartFrame = i * partSize + 1
videoPartEndFrame = min(videoPartStartFrame + partSize - 1, mediaLength)
videoPartStartFrame = max(1, videoPartStartFrame - videoPartOverlapFrameCount)
for frameIndex in range(videoPartStartFrame-1, videoPartEndFrame):
retrievedFrame = decoder[frameIndex]
except Exception as ex:
sys.exit(1)
finally:
cuda_ctx.pop()
except Exception as ex:
sys.exit(1)
finally:
stopPingThread = True
sys.exit(0)
Note: @mandar_godse do not delete my post and private message me, reply in this post.