if you use CPU, OpenMP multi-threading introduces non-determinism for some functions.
You can disable this and run with a single thread, that will run fully deterministcally (on CPU):
OMP_NUM_THREADS=1 MKL_NUM_THREADS=1 python mycode.py