# NVENC encoding -- keep getting version error

**URL:** <https://forums.developer.nvidia.com/t/nvenc-encoding-keep-getting-version-error/173468>\
**Category:** NVAPI\
**Created:** [March 26, 2021, 7:50pm UTC](https://forums.developer.nvidia.com/t/nvenc-encoding-keep-getting-version-error/173468 "2021-03-26T19:50:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![roger.p](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@roger.p](https://forums.developer.nvidia.com/u/roger.p)\
**Post date:** [March 26, 2021, 7:50pm UTC](https://forums.developer.nvidia.com/t/nvenc-encoding-keep-getting-version-error/173468/1 "2021-03-26T19:50:59Z")

</div>

I’m trying to start a simple NVENC encoding session.

int main () {

NV\_ENCODE\_API\_FUNCTION\_LIST \*pNVFunctionList;  
pNVFunctionList = (NV\_ENCODE\_API\_FUNCTION\_LIST \*) malloc(sizeof(NV\_ENCODE\_API\_FUNCTION\_LIST));  
memset(pNVFunctionList, 0, sizeof(NV\_ENCODE\_API\_FUNCTION\_LIST));

CUresult result = cuInit(0);  
printf(“cuInit result %d\n”,result);

int count;  
result = cuDeviceGetCount(&count);  
printf(“Counted %d devices returned %d\n”,count,result);

pNVFunctionList-\>version = NV\_ENCODE\_API\_FUNCTION\_LIST\_VER;  
NVENCSTATUS nvencCreateInstanceResult = NvEncodeAPICreateInstance(pNVFunctionList);  
printNVENCErrorsAndExit((char \*) “CreateInstance Error”, nvencCreateInstanceResult);

CUdevice dev;  
int status = cuDeviceGet(&dev, 0);  
printf(“cuDeviceGet status %d Device \n”,status,dev);

CUcontext pctx;  
result = cuCtxCreate\_v2 ( &pctx, 0, dev);  
printf(“cuCtxCreate status %d\n”,result);

NV\_ENC\_OPEN\_ENCODE\_SESSION\_EX\_PARAMS encParams = { 0 } ;  
encParams.version = NV\_ENC\_OPEN\_ENCODE\_SESSION\_EX\_PARAMS\_VER;  
encParams.apiVersion = NVENCAPI\_VERSION;  
encParams.deviceType = NV\_ENC\_DEVICE\_TYPE\_CUDA;  
encParams.device = &pctx;  
encParams.reserved = 0;

void \* encoder;  
NVENCSTATUS nvencOpenEncodeSessionResult = pNVFunctionList-\>nvEncOpenEncodeSessionEx(&encParams,(void \*\*) &encoder);  
printf(“OpenEncode status %d NVENCAPIVERSION %x NV\_ENC\_OPEN\_ENCODE\_SESSION\_EX\_PARAMS\_VER %x\n”,nvencOpenEncodeSessionResult,NVENCAPI\_VERSION,NV\_ENC\_OPEN\_ENCODE\_SESSION\_EX\_PARAMS\_VER);

return 0;

}

g++ BasicNvenc.cpp -o BasicNvenc -I /usr/local/cuda-10.2/include/ -lcuda   
-I~/Video\_Codec\_SDK\_11.0.10/Interface   
~/Video\_Codec\_SDK\_11.0.10/Lib/linux/stubs/x86\_64/libnvidia-encode.so

Here is what I get:

cuInit result 0  
Counted 1 devices returned 0  
CreateInstance Error = 0 SUCCESS  
cuDeviceGet status 0 Device  
cuCtxCreate status 0  
OpenEncode status 15 NVENCAPIVERSION b NV\_ENC\_OPEN\_ENCODE\_SESSION\_EX\_PARAMS\_VER 7001000b

Error 15 is NV\_ENC\_ERR\_INVALID\_VERSION

I’ve checked the apiVersion, the version, and the function list version. I also made sure I was linking against the same library I was compiling the header for. Card is a RTX4000 and I know it’s working. I’m baffled. Any thoughts on what I may be doing wrong here?

Running CENTOS on x86\_64 if it makes a difference.

Any ideas what I may be doing wrong here?

Thanks,

Roger

---

<div class="post-metadata">

**Author:** ![roger.p](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@roger.p](https://forums.developer.nvidia.com/u/roger.p)\
**Post date:** [March 27, 2021, 12:51am UTC](https://forums.developer.nvidia.com/t/nvenc-encoding-keep-getting-version-error/173468/2 "2021-03-27T00:51:44Z")

</div>

Figured it out… I had a slightly older nvidia driver.

nvidia-smi told me which driver I needed… I cross-checked with Read\_Me.pdf from the Video Codec SDK and I had version 440.xx but needed version 455.27 or later.

---

<div class="post-metadata">

**Author:** ![agokhale](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/agokhale/32/14047_2.png) [@agokhale](https://forums.developer.nvidia.com/u/agokhale)\
**Post date:** [May 6, 2021, 9:06pm UTC](https://forums.developer.nvidia.com/t/nvenc-encoding-keep-getting-version-error/173468/3 "2021-05-06T21:06:41Z")

</div>

Dear @roger.p

Glad to know that you have figured out the problem. If your issue is resolved, could you please mark your own answer as a `solution`, so that this post can be considered as resolved?

Thank you.  
NVAPI Forum Moderator

---

<div class="post-metadata">

**Author:** ![agokhale](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/agokhale/32/14047_2.png) [@agokhale](https://forums.developer.nvidia.com/u/agokhale)\
**Post date:** [May 27, 2021, 6:06pm UTC](https://forums.developer.nvidia.com/t/nvenc-encoding-keep-getting-version-error/173468/4 "2021-05-27T18:06:07Z")

</div>

Closed on May 27, 2021, 6:06pm UTC


