@yf225
Yes, I added omp_set_num_threads(1) (which has precedence over OMP_NUM_THREADS=1) in the beginning of the main function and still it uses all the CPU cores.
I also removed omp_set_num_threads(1) from the code, and entered OMP_NUM_THREADS=1 in the command line before running the mnist, and still it uses all of the CPU cores.