4

My situation
I want to run multiple R scripts on a Ubuntu server with which I connect via SSH. To run multiple R scripts I want to use tmux and one session for each run.

My problem
When I start one R script it should use 4 cores, because I have specified it (one Markov Chain per Core with the Stan library). But when I observe the cores with htop I see, that only one core is working at full capacity and the others are almost idle. When I run the same script outside of the tmux shell, it uses the 4 cores as it should do.

Furthermore, the code stops, when I exit the SSH session, even if I appropriately detach myself from tmux session.

Question: How can I enable multithreading in tmux? If you know other ways of letting code run on the server even if I disconnect, I would also be thankful!

  • 3
    AFAIK, tmux does not impose any limitations on multithreading. The issue must lie somewhere else. – Artur Meinild Sep 18 '23 at 12:25
  • @ArturMeinild that's what I thought too, from reading up on the tool. But when I start the command outside of a tmux shell, I perfectly uses 4 cores – Marcello Zago Sep 18 '23 at 12:32
  • How different are systemd status <pid-of-R-script> when you run the script inside and outside tmux? – muru Sep 19 '23 at 09:12
  • @muru I don't know much about linux, so for what should I be looking out when I run systemctl status <pid> – Marcello Zago Sep 19 '23 at 09:18
  • 2
    I'm not really sure myself. But they could be in different scopes or slices or whatever the term is, and so have different cgroups, and you can restrict a cgroup to limited CPU access, which is why that output might help. If you can, just edit the post and add the output, and we can see if anything in it helps in investigating – muru Sep 19 '23 at 09:23
  • Related to keeping shell running after SSH disconnection: https://askubuntu.com/a/1460233 – Raffa Sep 19 '23 at 14:50

0 Answers0