Closed elliottd closed 9 years ago
Yes, there would be differences. The main difference is that CPU uses float64 data and GPU uses float32. You could run float32 computations on your CPU though (set the Thenao flat floatx=float32
), but then again there can be remaining differences since all operations are being run by different pieces of code altogether, on physical devices that work quite differently.
Keras code can only be made deterministic on CPU or on GPU, but won't be deterministic across the two.
However your loss / accuracy metrics should be very close whatever the device. If you see significant differences there, that indicates a problem.
@fchollet So the differences are due to how the CPU / GPU code is designed and executed? Do you know of any discussions about what causes this by the developers of Theano or libgpuarray?
Across machines even with same architecture and same environments, I get different results as well. But on a single machine, with successive runs (either CPU or GPU) I am able to get the exact same results.
Make sure you have the exact same version of all software. Just having a different BLAS (openBLAS vs mkl for example) can change slightly the results, as when small change like a + (b + c) != (a + b) + c on float value.
On Wed, Dec 7, 2016 at 8:43 PM, wulabs notifications@github.com wrote:
Across machines even with same architecture and same environments, I get different results as well. But on a single machine, with successive runs (either CPU or GPU) I am able to get the exact same results.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/fchollet/keras/issues/681#issuecomment-265551808, or mute the thread https://github.com/notifications/unsubscribe-auth/AALC-yaDZhGWzvwz5-Vn-_oBR58v59UDks5rFwx-gaJpZM4F8cnG .
Hi,
I ran the
lstm_text_generation.py
example on the CPU and GPU and reached different outcomes. Is this expected behaviour? I setnumpy.random.seed(1234)
at the top of the file before any Keras imports and ran both processes withTHEANO_FLAGS=floatX=float32
CPU: Intel Xeon E5-2650 GPU: NVidia Tesla K20X
GPU-mode output