So I have the following situation:
- computer with 3 graphic cards
- python script using Keras with Theano backend and multiple threads
I specified the device to use in .theanorc
as described in the documentation.
The python script is of this form (still working on a standalone example):
import theano
from threading import Thread
...
class Test(Thread):
def run(self):
#calculations with Keras
test = Test()
test.start()
test.join()
Starting the script Theano uses the specified device but after some time a second python thread appears on one of the other graphic cards (and uses up resources).
The second thread seems to ignore the config as its running on the wrong GPU and isn't allocating ram as specified by the CNEM
flag.
This should not be possible according to the documentation as everything that forks from the thread that started the Theano calculation should be running on the same device (ensured by importing Theano right at the beginning).
After some poking around I found out that this behavior stops when I don't run my Keras code in a separate thread.
So before I start creating Github issues I would like some pointers what's most likely:
- Is this a bug in Theano?
- Is this a bug in Keras?
- Is this a bug in my own code?
@3. My whole project doesn't create separate Python processes (confirmed over process list) and doesn't change any Theano configuration.
Any idea what could even cause this kind of behavior?