We aim to port MCX for all modern GPUs. Currently, we have two MCX editions, the CUDA-edition is supported only on the NVIDIA graphics card, and an OpenCL-edition, supported for all OpenCL-compliant computing devices (Intel/AMD CPUs, NVIDIA GPU and AMD GPUs, etc). In order to run MCX (CUDA-edition), you have to make sure you have the right hardware and software support, this includes:
Starting from v0.9, MCX/MCXLAB released packages are compiled with CUDA library statically linked (embedded). Therefore, you do not need to install CUDA library in order to run MCX/MCXLAB.
You must use a CUDA capable NVIDIA graphics card in order to use MCX. A list of CUDA capable cards can be found at here. The oldest graphics card that MCX supports is the "Fermi" series (circa 2010). Using the latest NVIDIA card is expected to produce the best speed. The default release of MCX supports atomic operations and photon detection within a single binary. In the below webpage, we summarized the speed differences between different generations of NVIDIA GPUs
Windows users: if you use MCXStudio, please follow this video tutorial (Lesson 6) to apply a registry fix to enable MCX to run more than 5 seconds on your computer. Alternatively, you may use the Windows installer to install MCX. This is important!
To install MCX, you need to download the binary executable compiled for your
computer architecture (32 or 64bit) and platform, extract the package
and run the executable under the
<mcx root>/bin directory.
To test if your system supports MCX, you need to open a terminal (for Windows users, please click on the Start menu and type "cmd", then enter), and type
where path/to/mcx/bin should be replaced to the actual extracted bin folder from the downloaded package. If your path contains space, you must enclose it with double-quotes.
Once you are in the bin/ folder, you can then type
You may see 3 possible outcomes
No CUDA-capable GPU device found
MCX ERROR(-1):No GPU device found in unit mcextreme.c:54If your are certain your system has a working NVIDIA GPU, it is likely that your GPU driver was not up to date or was not installed properly. Please check your driver installation again.
In the event that your system does not have supported GPU, you may consider using MCX-CL instead - MCX-CL has the same functionality as MCX but it can also be executed on AMD/Intel CPUs and GPUs.
If you use MCXLAB, you may use the below procedure to test if it can use your GPU. First, open MATLAB or octave, then type
so that mcx.mex* file is in the search path. You may type
to confirm it is added to MATLAB. Then you can use the below command to query your GPUs
You must see valid output from this call, otherwise, your system does not have GPU or it is not properly configured to run MCXLAB.
If you are used to graphics interfaces, you can find an executable mcxstudio under the same folder as mcx. MCX Studio is a cross-platform interface to interact with MCX. It gives users a straightforward way to set various of parameters for a MCX session, and organize different sessions into projects that can be saved for later use. Please read README to see how to use this tool to create, run and save the simulation sessions.
To compile MCX/MCXLAB, you need to install CUDA toolkit (version 7-10 is supported). Once you install the CUDA library, you need to setup the system environment variable in order to let the compiler find the needed CUDA run-time library. For Linux and Mac OS users, you might need to add the following settings to your shell initialization file. Use "echo $SHELL" command to identify your shell type. For c-shell, i.e. csh/tcsh, add the following lines to your ~/.cshrc file
if ("and for "bash" or "sh" users, add
uname -p" =~ "*_64" ) then setenv LD_LIBRARY_PATH "/usr/local/cuda/lib64" else setenv LD_LIBRARY_PATH "/usr/local/cuda/lib" endif setenv PATH "/usr/local/cuda/bin:$PATH"
if [[ "to your ~/.bash_profile. If the libcudart.so* file is installed in a non-standard folder, please replace the paths in the above scripts to your installation path where
uname -p" =~ .*_64 ]]; then export LD_LIBRARY_PATH="/usr/local/cuda/lib64" else export LD_LIBRARY_PATH="/usr/local/cuda/lib" fi export PATH="/usr/local/cuda/bin:$PATH"
sudo apt-get install build-essentialand then type your own password
su -c 'yum groupinstall "Development Tools"'and then type the root password
For Windows, one need to add the path to nvcc (by default, C:\CUDA\bin), path to cl.exe (by default, C:\Program Files\Microsoft Visual Studio 8\VC\bin) and path to gcc/make (by default, C:\MinGW\bin) to your Path environment variable. You can follow the screenshots as in this tutorial, and paste the following string at the beginning of the variable value field.
C:\Program Files\Microsoft Visual Studio 8\VC\bin;C:\MinGW\bin;C:\CUDA\bin;
If you have installed VC2008, you need to replace "Microsoft Visual Studio 8" to "Microsoft Visual Studio 9".
If you have installed CUDA, MSVC or MinGW at a non-standard location, please open the Makefile under <mcx>/src to update all the library/include directories to the actual path.
For Windows, you need to double click on a shortcut named "MSYS", a terminal will pop up. Then type "cd /path/to/your/mcx/src", then type "make". The binary will be generated as <mcx>/bin/mcx.exe.