Beginner Problems with MCX

346 views
Skip to first unread message

Josef Probst

unread,
Jul 27, 2021, 10:19:01 AM7/27/21
to mcx-users
Hi,
First of all thanks for this awesome OpenSource project.
I am new to MCX and noticed a few things.
Regarding MCX Studio (version: v2021.2)(On Win10 if this matters):
  • When opening the digimouse.json file from the examles in  MCXStudio, I get the error message "string exceeds end of line"
  • I created json files from the colin27 example (by copying from mcxCloud or from "mcx --bench colin27 --dumpjson > file"). When opening these jsons with MCXStudio I get the error message "Invalid type cast"
There are no errors if I use "mcx -f file.json" in these two cases .
Regarding MCX Cloud:
  • If I load a json which has no Param1 defined and switch to the preview tab. I get a message with " TypeError: obj.Param1 is undefined" (even though the type is "pencil", where no param is needed, right?)
I know MCX Cloud is in the beta, but maybe you are not aware of this particular thing.
Regarding MCXLab:
For a custom volume simulationo I configured the detpos like this:
cfg.detpos=[32 22 1 1;32 42 1 1;22 32 1 1;42 32 1 1];
then used:
mcx2json(cfg,'cfg_from_matlab');
but got:
        "Detector":[
            [
                {
                    "Pos":[32,22,1],
                    "R":1
                },
                {
                    "Pos":[32,42,1],
                    "R":1
                },
                {
                    "Pos":[22,32,1],
                    "R":1
                },
                {
                    "Pos":[42,32,1],
                    "R":1
                }
            ]
        ]
which is one " [ ] " too many, right?

If I should provide any file, just say it. (But I don't see how I can attach json-files in this "create Conversation" form)
I hope this is the correct place for my findings.
Have a nice day.
- Josef Probst

Qianqian Fang

unread,
Jul 27, 2021, 10:55:15 AM7/27/21
to mcx-...@googlegroups.com, Josef Probst
On 7/27/21 10:06 AM, Josef Probst wrote:
Hi,
First of all thanks for this awesome OpenSource project.
I am new to MCX and noticed a few things.
Regarding MCX Studio (version: v2021.2)(On Win10 if this matters):
  • When opening the digimouse.json file from the examles in  MCXStudio, I get the error message "string exceeds end of line"
  • I created json files from the colin27 example (by copying from mcxCloud or from "mcx --bench colin27 --dumpjson > file"). When opening these jsons with MCXStudio I get the error message "Invalid type cast"


hi Josef,

thanks for reporting these issues.

mcxstudio currently only supports shape-construct based domain rendering. unfortunately we haven't added the support of JData (http://openjdata.org) based volumetric input in this GUI tool. we will add that in the future.

mcxcloud supports both, although its rendering of shapes is not as complete as mcxstudio.


There are no errors if I use "mcx -f file.json" in these two cases .
Regarding MCX Cloud:
  • If I load a json which has no Param1 defined and switch to the preview tab. I get a message with " TypeError: obj.Param1 is undefined" (even though the type is "pencil", where no param is needed, right?)


this should be now fixed with this commit

https://github.com/fangq/mcx/commit/2633bfbe4d98d14b553a24c5bb5908b70d386b58

I also updated the web page, try it again


I know MCX Cloud is in the beta, but maybe you are not aware of this particular thing.
Regarding MCXLab:
For a custom volume simulationo I configured the detpos like this:
cfg.detpos=[32 22 1 1;32 42 1 1;22 32 1 1;42 32 1 1];
then used:
mcx2json(cfg,'cfg_from_matlab');
but got:
        "Detector":[
            [
                {
                    "Pos":[32,22,1],
                    "R":1
                },
                {
                    "Pos":[32,42,1],
                    "R":1
                },
                {
                    "Pos":[22,32,1],
                    "R":1
                },
                {
                    "Pos":[42,32,1],
                    "R":1
                }
            ]
        ]
which is one " [ ] " too many, right?


this should be fixed by the below patch

https://github.com/fangq/mcx/commit/65359f773683ca68c6963fe2e360d2f09b65ef9e


in jsonlab 2.0 (where savejson is provided), it reinforces the difference between a row and column vector by forcing a "[]" for each row in a column vector. changing the column vector to a row-vector, combined with the default singletarray=0 setting, eliminates the extra [] row labeling.


feel free to send me any other issues you found - you can also report these by creating an Issue on github (https://github.com/fangq/mcx/issues), so I can tag the patch properly.


Qianqian




If I should provide any file, just say it. (But I don't see how I can attach json-files in this "create Conversation" form)
I hope this is the correct place for my findings.
Have a nice day.
- Josef Probst
--
You received this message because you are subscribed to the Google Groups "mcx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mcx-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mcx-users/2f8c6cf0-9987-4350-ae47-8f07137f7de0n%40googlegroups.com.

Josef Probst

unread,
Jul 29, 2021, 3:57:53 AM7/29/21
to mcx-users
Thanks for the extremly fast help. If I find other issues I will create issues on Github.
-Josef

Josef Probst

unread,
Aug 16, 2021, 7:31:49 AM8/16/21
to mcx-users
I am struggling with another problem. Still the very basic example I mentioned here

I simply added my custom paths:
addpath(genpath('/home/josef/MCXStudio/MATLAB'));
addpath(genpath('/home/josef/MCXStudio/MCXSuite/mmc/matlab'));
addpath(genpath('/home/josef/MCXStudio/MCXSuite/mcxcl/utils'));
addpath(genpath('/home/josef/iso2mesh/'));

and set the number of photons to 1 (so it should finish instantly)

Output from Octave:

generating tetrahedral mesh from closed surfaces ...
creating volumetric mesh from a surface mesh ...
volume mesh generation is complete
Launching MMCLAB - Mesh-based Monte Carlo for MATLAB & GNU Octave ...
Running simulations for configuration #1 ...
mmc.nphoton=1;
mmc.nn=6504;
mmc.elem=[34623,4];
mmc.ne=34623;
mmc.srcpos=[30 30 0];
mmc.srcdir=[0 0 1 0];
mmc.prop=1;
mmc.tstart=0;
mmc.tend=5e-09;
mmc.tstep=5e-10;
mmc.debuglevel='TP';
mmc.facenb=[34623,4];
mmc.evol=34623;
mmc.e0=7724;
mmc.isreflect=0;
mmc.detnum=0;

But it doesn't finish or start to progress.
I also loaded a custom simulation which worked in Win10+Matlab but had the same behaviour as this example above.
I also used mmc2json and tried to execute it with mmc -f ... but again same behaviour the progress just sits at 0%.

Nvidia SMI shows a process from octave but CPU and GPU usage is zero.
mcxlab does work, with a custom volume/scenario.
./mmc -L shows my Nvidia-GPU
The onecube example did work, even though I had to remove the 4th argument from line11 because somehow the "[]" were replaced with [1,1]
fyi small output from "debugging":

debug> disp (varargin);
{
  [1,1] = [](0x0)
}
debug>
error: input must be in the form of ...,'name',value,... pairs or structs
error: called from
    varargin2struct at line 36 column 9
    savemmcmesh at line 30 column 4
    createmesh at line 13 column 1


What could be the problem?

Josef Probst

unread,
Aug 16, 2021, 10:41:46 AM8/16/21
to mcx-users
After more investigation:
When I use mmc2json and call
./mmc -f mycfg.json -c 0
then it works fine.
So the issue is related to my OpenCL setup. But for now CPU-Simulation is sufficient.
So I tried to force sse in mmclab as well. So my last line is now:
[fluxs,detps]=mmclab(cfgs,'sse');
But Octave doesn't even come to here, because useopencl is still '1', because 'sse' is not checked in this line .
if I add "|| strcmp(varargin{2},'sse')" then it will call the line with mmc_sse but say that it is undefined.

Fang, Qianqian

unread,
Aug 17, 2021, 12:11:43 PM8/17/21
to mcx-...@googlegroups.com, Josef Probst
On 8/16/21 10:41 AM, Josef Probst wrote:
After more investigation:
When I use mmc2json and call
./mmc -f mycfg.json -c 0
then it works fine.
So the issue is related to my OpenCL setup. But for now CPU-Simulation is sufficient.


do you use windows or Linux? for Windows, you need to disable the graphics driver watchdog time limit (followed by a reboot), see

http://mcx.space/wiki/index.cgi?Doc/FAQ#I_am_getting_a_kernel_launch_timed_out_error_what_is_that
http://mcx.space/wiki/index.cgi?Workshop/MCX19Preparation#MCX_software_download_and_preparation
http://mcx.space/tutorials/mcxstudio/8_How_to_solve_the_unspecified_launch_error_on_Windows.html


for Linux (at least for kernel 4.7), if you use Intel's integrated GPU with opencl, you will have to run

echo -n 0 > /sys/module/i915/parameters/enable_hangcheck

see

https://community.intel.com/t5/OpenCL-for-CPU/Is-there-a-driver-watchdog-time-limit-for-Intel-GPU-on-Linux/m-p/1108297/highlight/true#M5249


Josef Probst

unread,
Aug 18, 2021, 6:29:05 AM8/18/21
to mcx-users

Thanks for the support!

I am working with different combinations.

With Win10+Matlab I did not have any recent problems (already saw the Windows fix you mentioned).

But I am supporting researchers who do not have access to Matlab and therefore I am trying to run simulations in Ubuntu 1804 and Octave.

So the following is related to Ubuntu 1804 with Octave:

I am working on a laptop with a i7-6700HQ and a Nvidia GTX 970M.

I thought that since mmc -L lists my Nvidia GPU, the OpenCL drivers are installed correctly and thus the simulation should work just like with mcxlab i.e. the screen freezes during simulation but the simualtion is done during this.

I followed your instructions for my otherwise unused IntelGPU. (Nvidia Prime is set to performance mode)

Installed OpenCL drivers:

https://github.com/intel/compute-runtime/blob/master/opencl/doc/DISTRIBUTIONS.md

disabled the hangcheck as you mentioned and now the simulation with mmclab is working and uses my IntelGPU. (This already helps a lot! Thank you)

But is there a way to use my nvidiaGpu (on a linux-laptop where this nvidia gpu is also used for the "normal desktop-output")  with mmc?
MMC does work on a server with a dedicated nvidia-gpu.


Did you see my post above about mmc_sse?

https://groups.google.com/g/mcx-users/c/SCG67727xv0/m/Gwyrsvb7AgAJ

Greetings and many thanks
Josef Probst

Fang, Qianqian

unread,
Aug 18, 2021, 3:28:27 PM8/18/21
to mcx-...@googlegroups.com, Josef Probst
On 8/18/21 6:29 AM, Josef Probst wrote:

Thanks for the support!

I am working with different combinations.

With Win10+Matlab I did not have any recent problems (already saw the Windows fix you mentioned).

But I am supporting researchers who do not have access to Matlab and therefore I am trying to run simulations in Ubuntu 1804 and Octave.

So the following is related to Ubuntu 1804 with Octave:

I am working on a laptop with a i7-6700HQ and a Nvidia GTX 970M.

I thought that since mmc -L lists my Nvidia GPU,


on Linux, I usually had less issues with nvidia gpus - for Ubuntu, usually I first google "ppa nvidia driver" , run the command to run the ppa, apt-get update, and apt-get install nvidia-driver-..., and a reboot usually make everything work fine. if driver for some reason does not work, I do a sudo apt-get remove --purge nvidia\* and reinstall the driver usually solve the problem. when it is working, I check two things 1) nvidia-smi, does it prints the gpu info? 2) run glmark2, make sure the driver/OpenGL is working properly. for OpenCL, I also type clinfo and see if it recognizes the gpu.

many years ago, I used to get the watchdog timeout error on Linux if it is connected to a display, but for the past 4 years, I have been using this hack on my work desktop - i.e. using Intel i-GPU for display and keep nvidia dedicated for CUDA:

https://forums.developer.nvidia.com/t/solved-run-cuda-on-dedicated-nvidia-gpu-while-connecting-monitors-to-intel-hd-graphics-is-this-possible/47690/6


however, I switched my graphics to nvidia GPU this year, I noticed that there wasn't a time limit on my Ubuntu 16.04/18.04.


if it still does not work, try these

https://stackoverflow.com/questions/6906579/cuda-visual-profiler-interactive-x-config-option
https://stackoverflow.com/questions/15833261/how-to-disable-or-change-the-timeout-limit-for-the-gpu-under-linux


the OpenCL drivers are installed correctly and thus the simulation should work just like with mcxlab i.e. the screen freezes during simulation but the simualtion is done during this.


at least from my experience on Windows, screen freeze is expected during computing. if it does not return, maybe the issue is not because something is wrong, but because the computing is too long. reduce photon number and see if it returns


I followed your instructions for my otherwise unused IntelGPU. (Nvidia Prime is set to performance mode)

Installed OpenCL drivers:

https://github.com/intel/compute-runtime/blob/master/opencl/doc/DISTRIBUTIONS.md

disabled the hangcheck as you mentioned and now the simulation with mmclab is working and uses my IntelGPU. (This already helps a lot! Thank you)

But is there a way to use my nvidiaGpu (on a linux-laptop where this nvidia gpu is also used for the "normal desktop-output")  with mmc?


unfortunately I can't reproduce this, everything works fine on my Ubuntu 18.04+nvidia gpu+octave, see screenshot. gpu#0 is also used for display (see xorg in nvidia-smi output)


Qianqian


MMC does work on a server with a dedicated nvidia-gpu.


Did you see my post above about mmc_sse?

https://groups.google.com/g/mcx-users/c/SCG67727xv0/m/Gwyrsvb7AgAJ


again, I can't reproduce this. cpu/sse version works fine on my octave 4.2.2.


Qianqian


mmclab_ubuntu18.04_nvidia_gpu.png
Reply all
Reply to author
Forward
0 new messages