Is it possible to build tf with pluggable devices plugin? #help_request #pluggable_device

With the new tensorflow-directml-plugin project that’s come out, I’m back on the hunt for a method to accelerate tf2.x with non-CUDA gpu’s. I was wondering if it’s possible to build the c api / libtensorflow package (specifically tensorflow.dll) for windows using/including this plugin? thanks for any help or ideas!

I really want to know about that.

/cc @PatriceVignola what do you think?

Hey @wl9300,

This is not a scenario that we explicitly support yet, but it should be possible to do by using the DLLs from the pypi package. After installing tensorflow-directml-plugin and tensorflow-cpu, you will need site-packages/tensorflow-plugins/tfdml_plugin.dll and site-packages/tensorflow-plugins/directml/DirectML.<SHA>.dll. Since tfdml_plugin.dll also depends on _pywrap_tensorflow_internal.pyd, you’ll also need site-packages/tensorflow/python/_pywrap_tensorflow_internal.pyd.

You should then be able to call TF_LoadLibrary("tfdml_plugin", status); to register the DML device and the kernels.

Remember that this is not something that we explicitly support or tested thoroughly, so it may be flaky. This is something that we might want to support more officially in the future though through a c_api package, like we did for TF 1.15.

Let me know if you have any questions or problems setting it up!

My use case right now is that i have a precompiled application (*.exe, not owned by me) that uses tensorflow.dll. I’m fairly new to and unfamiliar with tensorflow, so apologies if it seems like I’m asking dumb questions. If I understand correctly, one would call the TF_LoadLibrary() you mentioned from within a C++ program? If so, I don’t think that would be possible in my use case. What I currently have is a folder containing an application and tensorflow.dll, which was originally distributed as part of the c_api package. I am hoping to be able to compile a new tensorflow.dll to call the plugin the way the tf-dml c_api or cuda-enabled c_api would, and this is what I was wondering would be possible or not.

If this is not possible, I will see if I can contact the developer of the application and see about altering the application’s source code to call TF_LoadLibrary() or equivalent. Seeing that I’m pretty new to tf and programs using tf, could you clarify for me how to set everything up? I have both dll’s and the pyd file you described, but I’m not sure what to do with them once I have them?

Thanks for your help and sorry for the troubles! -wl

Modifying the application will definitely be necessary since the TensorFlow C API doesn’t know how to automatically load plugins. Furthermore, the workaround I outlined earlier may not work as easily as I thought, as you would also need to link to a punch of python dependencies just to be able to load tfdml_plugin.dll.

We will investigate the best way to provide a C API package for tensorflow-directml-plugin internally and we’ll keep you posted!

Thank you. I look forward to the c_api package!

Also, would you mind telling us which application you are trying to integrate tensorflow-directml with?

that would be starnet, a neural net star removal tool for astrophotography ( and its pixinsight integration (

1 Like