question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

If I try to use rich output under MPI, I get blank lines. Here’s an example:

# test.py
from mpi4py import MPI
rank = MPI.COMM_WORLD.Get_rank()

from rich import print
print(rank)
mpirun -n 2 python3 test.py

Produces four blank lines.

Even if I wrap the output to only run on rank 0, i.e.,

if rank == 0:
    from rich import print
    print(rank)

I still get only blank lines (this time two of them).

What’s causing this, and how can I fix it?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12

github_iconTop GitHub Comments

1reaction
mrzvcommented, Jul 1, 2020

Ah, great. Thanks for figuring it out. I think this qualifies as a bug I should report upstream to OpenMPI. And the workaround is great, too.

0reactions
willmcgugancommented, Jul 1, 2020

I’ve figure out what is going on. When run with MPI, the shutil.get_terminal_size function reports a terminal size of (0, 0). Rich wraps text to the column width, and when you wrap to a width of 0 all you are left with is blank lines.

I think this must be a bug in how MPI sets the environment for processes.

A workaround would be to define a COLUMNS environment var with your desired terminal width. Or construct Console with an explicit width.

console = Console(width=80)
console.print(rank) # This works!
Read more comments on GitHub >

github_iconTop Results From Across the Web

Ordering Output in MPI - stdout - Stack Overflow
in a simple MPI program I have used a column wise division of a large matrix. How can I order the output so...
Read more >
How to print out the output from each process in MPI programing
Hello everyone, I have a 2d dynamic array and I broadcasted it to all processors. I was wondering how I can print the...
Read more >
8.2 MPI Basics
Figure 8.1: Basic MPI. These six functions suffice to write a wide range of parallel programs. The arguments are characterized as having mode...
Read more >
MPI & output to file - Google Groups
I am currently using MPI parralelism to run Basilisk on the dutch national supercomputer. This works fine apart from one of the output...
Read more >
Marginal Propensity to Invest (MPI): Definition and Calculation
The MPI is calculated as MPI = ΔI/ΔY, meaning the change in value of the investment function (I) with respect to the change...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found