Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: AMF failed to initialise on the given Vulkan device: 1. on headless transcode job #518

Open
jpsollie opened this issue Dec 4, 2024 · 9 comments
Labels

Comments

@jpsollie
Copy link

jpsollie commented Dec 4, 2024

when trying to transcode with h264_amf on a PC with no running graphics (X / wayland), AMF fails to initialize.

a sample of ffmpeg output:

[format @ 0x7f4f9c004200] Setting 'pix_fmts' to value 'nv12|yuv420p' 
[AVFilterGraph @ 0x7f4f9c001000] query_formats: 4 queried, 9 merged, 0 already done, 0 delayed 
[graph 0 input from stream 0:0 @ 0x7f4f9c0037c0] video frame properties congruent with link at pts_time: 0                                                                            
0124-11-04 12:34:13 AC7FF6C0 [VulkanImportTable]   Error: ../../../../../public/common/VulkanImportTable.cpp(405):Failed to aquire entrypoint vkCreateXlibSurfaceKHR                  
[h264_amf @ 0x558551ccdbc0] VulkanImportTable: 0124-11-04 12:34:13 AC7FF6C0 [VulkanImportTable]   Error: ../../../../../public/common/VulkanImportTable.cpp(405):Failed to aquire entrypoint vkCreateXlibSurfaceKHR                                                                                                                                                         
0124-11-04 12:34:13 AC7FF6C0 [AMFDeviceVulkanImpl]   Error: ../../../../../runtime/src/core/DeviceVulkanImpl.cpp(597):AMF_ERROR 1 : AMF_FAIL: LoadFunctionsTable() failed - check if the proper Vulkan SDK is installed                                                                                                                                                     
[h264_amf @ 0x558551ccdbc0] AMFDeviceVulkanImpl: 0124-11-04 12:34:13 AC7FF6C0 [AMFDeviceVulkanImpl]   Error: ../../../../../runtime/src/core/DeviceVulkanImpl.cpp(597):AMF_ERROR 1 : AMF_FAIL: LoadFunctionsTable() failed - check if the proper Vulkan SDK is installed                                                                                                    
0124-11-04 12:34:13 AC7FF6C0 [AMFContextImpl]   Error: ../../../../../runtime/src/core/ContextImpl.cpp(1054):AMF_ERROR 1 : AMF_FAIL: pDeviceVulkan->Init(pVulkanDevice)               
[h264_amf @ 0x558551ccdbc0] AMFContextImpl: 0124-11-04 12:34:13 AC7FF6C0 [AMFContextImpl]   Error: ../../../../../runtime/src/core/ContextImpl.cpp(1054):AMF_ERROR 1 : AMF_FAIL: pDeviceVulkan->Init(pVulkanDevice)                                                                                                                                                         
[h264_amf @ 0x558551ccdbc0] AMF failed to initialise on the given Vulkan device: 1.                                                                                                   
[vost#0:0/h264_amf @ 0x558551d0e5c0] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.                                                
[vf#0:0 @ 0x558551ccf980] Error sending frames to consumers: Function not implemented                                                                                                 
[vf#0:0 @ 0x558551ccf980] Task finished with error code: -38 (Function not implemented)                                                                                               
[vf#0:0 @ 0x558551ccf980] Terminating thread with return code -38 (Function not implemented)

using amdvlk 2024.2.1 driver
using amdgpu-pro amf 1.4.34.1787253

vulkaninfo works fine

@jpsollie jpsollie added the bug label Dec 4, 2024
@MikhailAMD
Copy link
Collaborator

Thanks for reporting. We will address this.

@IsabelleAMD
Copy link

@jpsollie Hey there, could you run the following command and attach the vulkaninfo_stdout.txt and vulkaninfo_stderr.txt files it creates? I'd like to see what vulkaninfo says when the system is in this bad state.

env LD_DEBUG=files vulkaninfo 2>vulkaninfo_stderr.txt >vulkaninfo_stdout.txt

Could you also run your ffmpeg command with env LD_DEBUG=files before the command, and send the stderr output? I want to make sure the right libvulkan.so library is being loaded.

@jpsollie
Copy link
Author

jpsollie commented Dec 4, 2024

@jpsollie Hey there, could you run the following command and attach the vulkaninfo_stdout.txt and vulkaninfo_stderr.txt files it creates? I'd like to see what vulkaninfo says when the system is in this bad state.

env LD_DEBUG=files vulkaninfo 2>vulkaninfo_stderr.txt >vulkaninfo_stdout.txt

Could you also run your ffmpeg command with env LD_DEBUG=files before the command, and send the stderr output? I want to make sure the right libvulkan.so library is being loaded.

Sure, here you go
vulkaninfo_stderr_ffmpeg.txt

Vulkaninfo_stdout_ffmpeg was empty, so not uploading ...

vulkaninfo_stderr.txt
vulkaninfo_stdout.txt

@IsabelleAMD
Copy link

Oh, I understand now. Based on the logs I see you're using gentoo. After doing some spelunking I see that when the X use flag is absent, media-libs/vulkan-loader will create a libvulkan.so.1 library without the vkCreateXlibSurfaceKHR symbol. This is unusual, as most distributions prebuild the vulkan loader with xlib support enabled, so we've only ever seen vkCreateXlibSurfaceKHR available on the systems we test.

I'm not too familiar with gentoo, but perhaps you could build media-libs/vulkan-loader with the X use flag enabled? This might require you to install additional x11 headers so it can build. You don't need an x server running for AMF to transcode.

@jpsollie
Copy link
Author

jpsollie commented Dec 5, 2024

Oh, I understand now. Based on the logs I see you're using gentoo. After doing some spelunking I see that when the X use flag is absent, media-libs/vulkan-loader will create a libvulkan.so.1 library without the vkCreateXlibSurfaceKHR symbol. This is unusual, as most distributions prebuild the vulkan loader with xlib support enabled, so we've only ever seen vkCreateXlibSurfaceKHR available on the systems we test.

I'm not too familiar with gentoo, but perhaps you could build media-libs/vulkan-loader with the X use flag enabled? This might require you to install additional x11 headers so it can build. You don't need an x server running for AMF to transcode.

that did it!
So, shall I send a bug report to the gentoo maintainers so a runtime dependency ffmpeg [amf?] => media-libs/vulkan-loader [x] is added? or isn't this the only way?

@IsabelleAMD
Copy link

I think this is necessary, yes. On our end, we could add a hack where we don't fail if Xlib-related vulkan symbols are missing, but since we don't test on any systems where this is the case, I am concerned this would just break again in the future if we add another xlib-specific symbol to our libvulkan.so loader code. I think it makes more sense for the distributions packaging to reflect what AMF needs directly.

@IsabelleAMD
Copy link

IsabelleAMD commented Dec 5, 2024

Actually, we discussed it within the team and since this symbol is only used in our samples, we can ignore it if it is missing and it won't cause a big problem, we'll just change our samples to check if its present. We will make this change internally. Until this change gets released in a new driver update, the runtime dependency you describe will be necessary.

@jpsollie
Copy link
Author

jpsollie commented Dec 5, 2024

Thanks! Looking forward to it!
Aside from that, while the h264_amf codec is werking (mostly) as it should, it can have some horrifying side-effects:
I know it's a little off-topic, but launching the h264_amf codec with pre-analysis enabled locks the whole system:

  • screen turns blank
  • network io no longer works
  • USB bus keyboard/Mouse are no longer connected

... and my kernel parameter panic=5 doesn't cause a reboot.

This must be a kernel bug: there's no way a regular user can lockup just everything in the system by playing with amf vulkan libraries.
Do you guys know what I could do before launching 'ffmpeg -i file1.mkv -c:v h264_amf -preanalysis true -f null -' so it gives as much info as possible? I executed it via ssh, and everything got locked up.

I promise I'll create a new issue if I know what's going on ;)

@MikhailAMD
Copy link
Collaborator

Hard to tell, pre-analysis works in general on Linux. You may want to try on supported distro first with TranscodeHW AMF sample. Debug level FFmpeg log would be helpful as well, but I guess we should start a different item here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants