I am trying to install tensorflow (with or without GPU support) with the keras API in the QGIS 3.4 LTR python 3 environment but without success. I do have a working install of tensorflow-gpu that I use in anaconda. I also have a working install of scikit-learn (and others) in the QGIS 3 env. So I think my method using the OSgeo4 shell and pip seems mostly OK. So from the python console in QGIS I can type:
And that works fine. But the same thing is not true for tensorflow and keras. First I tried to install tensorflow-gpu, when using pip I got no error messages. But:
import tensorflow as tf
returns this error:
ImportError: Could not find 'cudart64_100.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 10.0 from this URL: https://developer.nvidia.com/cuda-90-download-archive
I have used Settings>options>System and added all the CUDA paths to my environment variables. These do point to the folder where cudart64_100.dll is found.
If I un-install tensorflow-gpu and downgrade to the cpu version, I get another problem after an attempted import:
AttributeError: type object 'h5py.h5.H5PYConfig' has no attribute '__reduce_cython__'
This seems to be related to v 2.10 of h5py.
Ultimately, is there a solution here? Is it even possible to install tensorflow in QGIS and use it directly from the PyQGIS console?