Jump to content

Recommended Posts



I have a Python script that trains a TensorFlow model. Python is installed in a Conda environment.


When the Python script is run from a command prompt, the model is trained on GPU. But when the script is run from Delphi PythonEngine, the model is trained on CPU instead.


Would anyone has an idea why I am not able to use GPU with Python4Delphi?



Share this post

Link to post
Posted (edited)

the first thing that comes to mind is that some configuration settings are "lost" due to the fact that the current directory may be different

(or some logic related to this is broken)


also check this: https://www.tensorflow.org/guide/gpu

you can do some diagnostic this way

Edited by KoRiF

Share this post

Link to post

Process monitor from Sysinternals is your friend here. Trace the startup and see where the file is not found.


Python at the command prompt is built with vcruntime, and Delphi does not. Put a copy of msvcp140.dll and vcruntime140_1.dll in the directory that has your EXE and then see if works correctly.

Share this post

Link to post

Thank you for your advice.


Despite using the same working directory, TensorFlow is indeed loading CUDA DLLs from a different location with Python4Delphi.

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now