<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" id="owaParaStyle"></style>
</head>
<body fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Pavan,
<div>sorry when I do run mpiexec id the output is</div>
<div>uid=1000(pi) gid=1000(pi) groups=1000(pi),4(adm),20(dialout),24(cdrom),27(sudo),29(audio),44(video),46(plugdev),60(games),100(users),105(netdev),999(input)</div>
<div><br>
</div>
<div>regardless of whether I'm in root or my usual user. root@raspi or pi@raspi<span style="font-size: 10pt;">. Is this output what you would expect?</span></div>
<div><span style="font-size: 10pt;"><br>
</span></div>
<div><span style="font-size: 10pt;">Jim, </span></div>
<div><span style="font-size: 10pt;">I have tried changing the ownership of /dev/mem by</span></div>
<div><span style="font-size: 10pt;">chmod 755 /dev/mem so that the output of ls -l /dev/mem is </span></div>
<div><span style="font-size: 10pt;">crwxr-xr-x 1 root kmem 1, 1 Jan 1 1970 /dev/mem</span></div>
<div><span style="font-size: 10pt;">but I still can't open /dev/mem inside my program. I also tried with the code 777.</span></div>
<div><span style="font-size: 10pt;"><br>
</span></div>
<div><span style="font-size: 10pt;">I tried adding my user to the kmem group by doing</span></div>
<div>usermod -a -G kmem pi</div>
<div>but this doesn't fix the problem.</div>
<div><br>
</div>
<div><br>
</div>
<div>Have I gotten totally confused and pi isn't my user?</div>
<div><br>
</div>
<div>Thank you in advance,</div>
<div>Eibhlin</div>
<div>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div id="divRpF100517" style="direction: ltr;"><font face="Tahoma" size="2" color="#000000"><b>From:</b> discuss-bounces@mpich.org [discuss-bounces@mpich.org] on behalf of Jim Dinan [james.dinan@gmail.com]<br>
<b>Sent:</b> 14 June 2013 21:31<br>
<b>To:</b> discuss@mpich.org<br>
<b>Subject:</b> Re: [mpich-discuss] Running an mpi program that needs to access /dev/mem<br>
</font><br>
</div>
<div></div>
<div>
<div dir="ltr">I don't know if this has been suggested, but you could also add your user to the kmem group and chmod /dev/mem so that you have the access you need.
<div><br>
</div>
<div style=""> ~Jim.</div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Fri, Jun 14, 2013 at 1:24 PM, Pavan Balaji <span dir="ltr">
<<a href="mailto:balaji@mcs.anl.gov" target="_blank">balaji@mcs.anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<br>
You can run mpich as root.  There's no restriction on that.  You still haven't tried out my suggestion of running "id" to check what user ID you are running your processes as.  My guess is that you are not setting your user ID correctly.<span class="HOEnZb"><font color="#888888"><br>
<br>
 -- Pavan</font></span>
<div class="HOEnZb">
<div class="h5"><br>
<br>
On 06/14/2013 06:27 AM, Lee, Eibhlin wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
I found that the reason we want to access /dev/mem is to setup memory regions to access the peripherals. (We are trying to read the output of an ADC). At this point it becomes more a linux/raspberry-pi specific problem than an MPICH problem. Although the fact
 that you can't run a program that needs access to memory mapping (even as the root user) seems something that MPICH could improve on for future versions. I know I am using smpd instead of hydra so this problem may already be solved. But if someone could confirm
 that, it would be really helpful.<br>
______________________________<u></u>__________<br>
From: <a href="mailto:discuss-bounces@mpich.org" target="_blank">discuss-bounces@mpich.org</a> [<a href="mailto:discuss-bounces@mpich.org" target="_blank">discuss-bounces@mpich.org</a>] on behalf of Lee, Eibhlin [<a href="mailto:eibhlin.lee10@imperial.ac.uk" target="_blank">eibhlin.lee10@imperial.ac.uk</a>]<br>
Sent: 14 June 2013 11:20<br>
To: <a href="mailto:discuss@mpich.org" target="_blank">discuss@mpich.org</a><br>
Subject: Re: [mpich-discuss] Running an mpi program that        needs   to      access  /dev/mem<br>
<br>
Gus,<br>
I tried running cpi, as is included in the installation of MPI, on two machines with two processes. The output message confirmed that it had started only 1 process instead of 2.<br>
Process 0 of 1 is on raspi<br>
pi is approximately...<br>
<br>
Then it just hung. I think this is because the other machine didn't know where to output the data?<br>
<br>
When I tried running two processes on the one machine using the wrapper you suggested the output was the same but doubled. It didn't hang. This confirms that every process was started with rank 0.<br>
<br>
I'm not entirely sure why /dev/mem is needed. I'm working in a group and another member set up io and gpio and it seemed it needed access to /dev/mem I am going to do a strace as suggested by Pavan Balaji to see where it is used and see if I can somehow work
 around it.<br>
<br>
Thank you for your help.<br>
Eibhlin<br>
______________________________<u></u>__________<br>
From: <a href="mailto:discuss-bounces@mpich.org" target="_blank">discuss-bounces@mpich.org</a> [<a href="mailto:discuss-bounces@mpich.org" target="_blank">discuss-bounces@mpich.org</a>] on behalf of Gus Correa [<a href="mailto:gus@ldeo.columbia.edu" target="_blank">gus@ldeo.columbia.edu</a>]<br>
Sent: 13 June 2013 21:11<br>
To: Discuss Mpich<br>
Subject: Re: [mpich-discuss] Running an mpi program that needs  to      access  /dev/mem<br>
<br>
Hi Eibhlin<br>
<br>
On 06/13/2013 12:59 PM, Lee, Eibhlin wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
Gus,<br>
I believe your first assumption is correct. Unfortunately it just seemed to hang. I think this might be because each one is being made to have the same rank...<br>
</blockquote>
<br>
Darn!  I was afraid that it might give only rank 0 to all MPI processes.<br>
So, with the script wrapper the process being launched by mpiexec may<br>
indeed be sudo,<br>
not the actual mpi executable (main)  :(<br>
Then it may actually launch a bunch of separate rank 0 replicas of your<br>
program,<br>
instead of assigning to them different ranks.<br>
However, without any output or error message, it is hard to tell.<br>
<br>
No output at all?<br>
No error message, just hangs?<br>
Have you tried a verbose flag (-v) to mpiexec?<br>
(Not sure if it exists in MPICH mpiexec, you'd need to check.)<br>
<br>
Would you care to try it with another mpi program,<br>
one that doesn't deal with /dev/mem (a risky business),<br>
say cpi.c (in the examples directory), or an mpi version of Hello, world,<br>
just to see if the mpiexec+sudo_script_wrapper works as expected or<br>
if everybody gets rank 0?<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
It may already be obvious but this is the first time I am using Linux. I had tried sudo $(which mpiexec ....) and sudo $(which mpiexec) ... both without success.<br>
</blockquote>
<br>
"which mpiexec" will return the path to mpiexec, but won't execute it.<br>
<br>
You could try this (with backquotes):<br>
<br>
`which mpiexec` -n 2 ~/main<br>
<br>
On a side note, make sure the mpiexec you're using matches the<br>
mpicc/mpif90/MPI library from the MPICH that<br>
you used to compile  the program.<br>
Often times computers have several flavors of MPI installed, and mixing<br>
them just doesn't work.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
Is putting the full path to it similar to/is a symlink? (This still doesn't make main have super user privileges though.)<br>
</blockquote>
<br>
No, nothing to do with sudo privileges.<br>
<br>
This suggestion was just to avoid messing up your /usr/bin,<br>
which is a directory that despite the somewhat misleading name (/usr,<br>
for historical reasons I think),<br>
is supposed to hold system (Linux) programs (that users can use), but<br>
not user-installed programs.<br>
Normally things are that are installed in /usr get there via some Linux<br>
package manager program<br>
(yum, rpm, apt-get, etc), to keep consistency with libraries, etc.<br>
<br>
I belive MPICH would install by default in /usr/local/ (and put mpiexec<br>
in /usr/local/bin),<br>
which is kind of a default location for non-system applications.<br>
<br>
The full path suggestion would be something like:<br>
/path/to/where/you/installed/<u></u>mpiexec -n 2 ~/main<br>
<br>
However, this won't solve the other problem w.r.t. sudo and /dev/mem.<br>
<br>
You must know what you are doing, but it made me wonder,<br>
even if your program were sequential, why would you want to mess with<br>
/dev/mem directly?<br>
Just curious about it.<br>
<br>
Gus Correa<br>
<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
Eibhlin<br>
______________________________<u></u>__________<br>
From: <a href="mailto:discuss-bounces@mpich.org" target="_blank">discuss-bounces@mpich.org</a> [<a href="mailto:discuss-bounces@mpich.org" target="_blank">discuss-bounces@mpich.org</a>] on behalf of Gus Correa [<a href="mailto:gus@ldeo.columbia.edu" target="_blank">gus@ldeo.columbia.edu</a>]<br>
Sent: 13 June 2013 15:37<br>
To: Discuss Mpich<br>
Subject: Re: [mpich-discuss] Running an mpi program that needs to       access  /dev/mem<br>
<br>
Hi Lee<br>
<br>
How about replacing "~/main" in the mpiexec command line<br>
by one-liner script?<br>
Say, "sudo_main.sh", something like this:<br>
<br>
#! /bin/bash<br>
sudo ~/main<br>
<br>
After all, it is "main" that accesses /dev/mem,<br>
and needs "sudo" permissions, not mpiexec, right?<br>
[Or do the mpiexec-launched processes inherit<br>
the "sudo" stuff from mpiexec?]<br>
<br>
Not related, but, instead of putting mpiexec in /usr/bin,<br>
can't you just use the full path to it?<br>
<br>
I hope this helps,<br>
Gus Correa<br>
<br>
On 06/13/2013 10:09 AM, Lee, Eibhlin wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
Pavan,<br>
I had a lot of trouble getting hydra to work without having to enter a password/passphrase. I saw the option to pass a phrase in the mpich installers guide. I eventually found that for that command you needed to use the smpd process manager. That's the only
 reason I chose smpd over hydra.<br>
As to your other suggestion. I ran ./main and the same error (Can't open /dev/mem...) appeared. sudo ./main works but of course without multiple processes.<br>
Eibhlin<br>
______________________________<u></u>__________<br>
From: <a href="mailto:discuss-bounces@mpich.org" target="_blank">discuss-bounces@mpich.org</a> [<a href="mailto:discuss-bounces@mpich.org" target="_blank">discuss-bounces@mpich.org</a>] on behalf of Pavan Balaji [<a href="mailto:balaji@mcs.anl.gov" target="_blank">balaji@mcs.anl.gov</a>]<br>
Sent: 13 June 2013 14:34<br>
To: <a href="mailto:discuss@mpich.org" target="_blank">discuss@mpich.org</a><br>
Subject: Re: [mpich-discuss] Running an mpi program that needs to access        /dev/mem<br>
<br>
I just saw your older email.  Why are you using smpd instead of the<br>
default process manager (hydra)?<br>
<br>
     -- Pavan<br>
<br>
On 06/13/2013 08:05 AM, Pavan Balaji wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
What's "-phrase"?  That's not a recognized option.  I'm not sure where<br>
the /dev/mem check is coming from.  Try running ~/main without mpiexec<br>
first.<br>
<br>
     -- Pavan<br>
<br>
On 06/13/2013 06:56 AM, Lee, Eibhlin wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
Hello all,<br>
<br>
I am trying to use two raspberry-pi to sample and then process some<br>
data. The first process samples while the second processes and vice<br>
versa. To do this I use gpio and also mpich-3.0.4 with the process<br>
manager smpd. I have successfully run cpi on both machines (from the<br>
master machine). I have also managed to run a similar program but<br>
without the MPI, this involved compiling with gcc and when running<br>
putting sudo in front of the binary file.<br>
<br>
When I combine these two processes I get various error messages.<br>
For input:<br>
mpiexec -phrase cat -machinefile machinefile -n 2 ~/main<br>
the error is:<br>
Can't open /dev/mem<br>
Did you forget to use 'sudo .. ?'<br>
<br>
For input:<br>
sudo mpiexec -phrase cat -machinefile machinefile -n 2 ~/main<br>
the error is:<br>
sudo: mpiexec: Command not found<br>
<br>
I therefore put mpiexec into /usr/bin<br>
<br>
now for input:<br>
sudo mpiexec -phrase cat -machinefile machinefile -n 2 ~/main<br>
the error is:<br>
Can't open /dev/mem<br>
Did you forget to use 'sudo .. ?'<br>
<br>
Does anyone know how I can work around this?<br>
Thanks,<br>
Eibhlin<br>
<br>
<br>
<br>
______________________________<u></u>_________________<br>
discuss mailing list     <a href="mailto:discuss@mpich.org" target="_blank">discuss@mpich.org</a><br>
To manage subscription options or unsubscribe:<br>
<a href="https://lists.mpich.org/mailman/listinfo/discuss" target="_blank">https://lists.mpich.org/<u></u>mailman/listinfo/discuss</a><br>
<br>
</blockquote>
</blockquote>
--<br>
Pavan Balaji<br>
<a href="http://www.mcs.anl.gov/~balaji" target="_blank">http://www.mcs.anl.gov/~balaji</a><br>
______________________________<u></u>_________________<br>
discuss mailing list     <a href="mailto:discuss@mpich.org" target="_blank">discuss@mpich.org</a><br>
To manage subscription options or unsubscribe:<br>
<a href="https://lists.mpich.org/mailman/listinfo/discuss" target="_blank">https://lists.mpich.org/<u></u>mailman/listinfo/discuss</a><br>
______________________________<u></u>_________________<br>
discuss mailing list     <a href="mailto:discuss@mpich.org" target="_blank">discuss@mpich.org</a><br>
To manage subscription options or unsubscribe:<br>
<a href="https://lists.mpich.org/mailman/listinfo/discuss" target="_blank">https://lists.mpich.org/<u></u>mailman/listinfo/discuss</a><br>
</blockquote>
______________________________<u></u>_________________<br>
discuss mailing list     <a href="mailto:discuss@mpich.org" target="_blank">discuss@mpich.org</a><br>
To manage subscription options or unsubscribe:<br>
<a href="https://lists.mpich.org/mailman/listinfo/discuss" target="_blank">https://lists.mpich.org/<u></u>mailman/listinfo/discuss</a><br>
______________________________<u></u>_________________<br>
discuss mailing list     <a href="mailto:discuss@mpich.org" target="_blank">discuss@mpich.org</a><br>
To manage subscription options or unsubscribe:<br>
<a href="https://lists.mpich.org/mailman/listinfo/discuss" target="_blank">https://lists.mpich.org/<u></u>mailman/listinfo/discuss</a><br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
discuss mailing list     <a href="mailto:discuss@mpich.org" target="_blank">discuss@mpich.org</a><br>
To manage subscription options or unsubscribe:<br>
<a href="https://lists.mpich.org/mailman/listinfo/discuss" target="_blank">https://lists.mpich.org/<u></u>mailman/listinfo/discuss</a><br>
______________________________<u></u>_________________<br>
discuss mailing list     <a href="mailto:discuss@mpich.org" target="_blank">discuss@mpich.org</a><br>
To manage subscription options or unsubscribe:<br>
<a href="https://lists.mpich.org/mailman/listinfo/discuss" target="_blank">https://lists.mpich.org/<u></u>mailman/listinfo/discuss</a><br>
______________________________<u></u>_________________<br>
discuss mailing list     <a href="mailto:discuss@mpich.org" target="_blank">discuss@mpich.org</a><br>
To manage subscription options or unsubscribe:<br>
<a href="https://lists.mpich.org/mailman/listinfo/discuss" target="_blank">https://lists.mpich.org/<u></u>mailman/listinfo/discuss</a><br>
<br>
</blockquote>
<br>
-- <br>
Pavan Balaji<br>
<a href="http://www.mcs.anl.gov/~balaji" target="_blank">http://www.mcs.anl.gov/~balaji</a><br>
______________________________<u></u>_________________<br>
discuss mailing list     <a href="mailto:discuss@mpich.org" target="_blank">discuss@mpich.org</a><br>
To manage subscription options or unsubscribe:<br>
<a href="https://lists.mpich.org/mailman/listinfo/discuss" target="_blank">https://lists.mpich.org/<u></u>mailman/listinfo/discuss</a><br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
</body>
</html>