Is it possible to get two different results using the same code but running from the two different system ?
33 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I was running the same code and calculating some matrix and some other calculations with for loop nothing special function but I am getting different results one from window installed matlab and other from my cluster computer (Centos-7) installed matlab.
So i want to know why is it so ?
Am i doing something wrong in the cluster (Centos-7)?
are cluster(Cluster) not used for matlab ?
1 comentario
Jan
el 23 de Feb. de 2022
Without seeing the code, it is impossible to find the cause of the different results. If an algorithm is instable, the results can be different due to rounding errors.
Respuestas (1)
Simar
el 20 de Nov. de 2023
Editada: Simar
el 20 de Nov. de 2023
Hi Vivek,
I understand that you're getting different results from running the same MATLAB code on different systems (Windows vs. CentOS-7), there could be several reasons for this. Here are some factors to consider that might explain the discrepancy:
- Ensure that the MATLAB version installed on your Windows machine is the same as the one on the CentOS-7 cluster. Different versions of MATLAB may have different algorithms, optimizations, or even bug fixes that can lead to different results, especially for functions that involve randomness or advanced numerical computations.
- MATLAB uses floating-point arithmetic, which can lead to minor differences in calculations due to round-off errors. These differences can be magnified in a clustered environment if the underlying hardware (e.g., CPUs) has different architectures or if the cluster nodes have different settings for floating-point precision.
- If the code involves random number generation, ensure that you have set a fixed seed for the random number generator using “rng” for reproducibility. Different systems may have different default random number generators or states.
- If parallel computing features are being used like “parfor”, the order of operations can affect the results due to non-deterministic reductions. Make sure to initialize any variables that are used in a reduction operation within the loop.
- Verify that all required toolboxes and add-ons are installed and licensed on both systems. Missing toolboxes or different versions of toolboxes could lead to different behaviour.
- If cluster configuration is being used, it is possible that the MATLAB Distributed Computing Server or other parallel computing configurations are affecting your results. Ensure that the cluster is configured correctly, and that the code is designed to run in a distributed environment.
- System-specific environment variables can influence MATLAB's behaviour. Check that the environment variables related to MATLAB are consistent across both systems.
- If code reads from or writes to files, differences in file system precision or formatting between Windows and CentOS-7 could lead to discrepancies.
Follow these steps to troubleshoot the issue:
- Check the MATLAB version on both systems.
- Ensure that the environment is consistent (e.g., same path, same toolboxes).
- Use “rng” with a fixed seed if randomness is involved.
- Test smaller parts of the code to isolate the part that gives different results.
- If using parallel computing, review the parallelization strategy and ensure its deterministic.
- Review any warnings or errors that MATLAB might output on both systems.
Clusters are indeed used for running MATLAB, especially for large-scale computations and simulations that can benefit from distributed computing. The MATLAB Distributed Computing Server is specifically designed to run MATLAB code on clusters.
Finally, even after considering all these factors and still facing issues, you can contact MathWorks Support for assistance or reach out to your cluster's system administrator to ensure that the MATLAB environment on the cluster is configured correctly.
Please refer to the following documentation link –
- Parfor-https://in.mathworks.com/help/matlab/ref/parfor.html?searchHighlight=parfor&s_tid=srchtitle_support_results_1_parfor
- Rng-https://in.mathworks.com/help/matlab/ref/rng.html?searchHighlight=rng&s_tid=srchtitle_support_results_1_rng
Hope it helps!
Best Regards,
Simar
0 comentarios
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!