3

I have a raspberry pi, connected to HDMI monitor.

I am trying to run a simple gui (created in qt), and I'm using mpi library for interprocess communication. I want to get this application working on raspberry pi, and on my laptop using something like this

$ mpiexec -f machinefile -n 2 ./mpi_gui

where the machinefile contains the ip addresses for my pi, and for the laptop.

I am following this tutorial. The thing is that this communication is over ssh and I get an "cannot connect to x server" error. I tried

$ mpiexec -enable-x -f machinefile -n 2 ./mpi_gui

to get the raspberry pi gui on my laptop, and it works ok.

Is it possible to run the gui of the raspberry pi on the hdmi monitor to which is connected?

Later edit:

I don't know if I explained well what I want to obtain. I want the process running on the raspberry pi to put the gui on the HDMI monitor connected to it. And the process running on my laptop, to output the gui on the laptop's monitor.

But I can't see how this can be achieved.

1) Using ssh to connect to pi, I enter the command:

sh-4.2$ ssh pi@192.168.1.186
pi@192.168.1.186's password: 
pi@raspberrypi ~/mpi_testing/mpi_with_gui/mpi_with_gui/mpi_gui $ DISPLAY=:0 mpiexec -n 2 ./mpi_gui
Greetings from process 0 of 2!
Greetings from process 1 of 2!

This starts both processes on the raspberry, both gui's are displayed on the hdmi monitor connected to pi. (not what I want)

2) I run on my laptop the command bellow:

sh-4.2$ mpiexec -n 2 ./mpi_gui
Greetings from process 0 of 2!
Greetings from process 1 of 2!

Both processes are running on my laptop, as expected, I got those 2 gui's on the laptop's display. (still, not what I want)

3) I run from my laptop the command below:

sh-4.2$ DISPLAY=:0 mpiexec -f machinefile -n 2 ./mpi_gui
pi@192.168.1.186's password: 
mpi_gui: cannot connect to X server

It would be nice to start the laptop process with the gui displayed on the laptop's screen, and the raspberry pi process with the gui displayed on its hdmi screen. Though, there should be a way to tell mpiexec that each process should use it's own X server (or is this ssh job?)

  • 2
    try prepending your command like this DISPLAY=:0 mpiexec ... – Krzysztof Adamski Apr 2 '13 at 18:05
  • still got cannot connect to X server – Adrian Apr 3 '13 at 7:33
  • And X server is started on your RasbperryPi? – Krzysztof Adamski Apr 3 '13 at 7:36
  • Yes, it is. I will try to run the application, but this time from the raspberry pi (i tried the above commands from my laptop). – Adrian Apr 3 '13 at 7:42
  • Could you please paste the whole commandline that you are using and all the error messages you get? – Krzysztof Adamski Apr 3 '13 at 7:56
4

First of all, you should be able to access your Pi via its hostname, like raspberrypi.local. Second, you should make an entry in your .ssh/config file for the Pi:

Host raspberrypi
   User pi
   Hostname raspberrypi.local
   Compression yes
   ForwardX11 yes

This will enable X11 forwarding for the host with hostname raspberrypi.local (replace with IP if you like). It also enables compression, which is a good idea for X11. You could also specify an RSA key here for authentication, so you don't have to type a password.

Edit: To actually don't have the X11 connection forwarded, but to instead use the local X server, you can do the following: First, you have to run xhost +local: on your Raspberry Pi (not via ssh). Second, you have to set the display variable for your remote command to DISPLAY=:0 you can test this by running ssh interactively:

ssh pi@raspberrypi.local 'DISPLAY=:0 name-of-program-to-run'
  • Oh, now I get your problem. You don't want the X11 connection to be forwarded. :) – Arne Apr 3 '13 at 13:22
  • Edited my answer to reflect this. – Arne Apr 3 '13 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.