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.

[Custom python environment]

See original GitHub issue

Hi all !

In the context of cluster computing, it is sometime necessary to have the jobs running with a local python environment and not the one from the central one (where the job has been launched).

Currently, the python executable path is automatically extracted with shlex.quote(sys.executable) in slurm.py before being used to generate the scratch file in _make_sbatch_string.

While this is a great default behaviour, we would argue with @MJHutchinson to be able to specify a custom python executable path to override the default one, as implemented in this commit. The key line is:

 f"srun --output {stdout} --error {stderr} --unbuffered {executable} {command}",

Then, it combination with hydra, it is sufficient to add executable:/data/localhost/not-backed-up/${env:USER}/utils/venv_projec_name/bin/python in the slurm config.

If that sounds like a good solution to you all, I’ll push a PR, otherwise I’m happy to discuss the issue.

Additionally, it seems that it is now possible to execute commands before running srun cf hydra_submitit_launcher. Would be great to also have a teardown argument to execute commands after running srun.

Best, Emile

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
cgerumcommented, Apr 30, 2021

One additional problem is then running with singularity where executable should usually be something along the lines of:

singularity --nv exec my_image.sif /opt/python3.8/bin/python

Which will break when running shlex.quote() on the executable string. Singularity is the preferred way of building environments on all SLURM cluster i have worked with.

2reactions
tileb1commented, Jun 11, 2022

Hi @gwenzek, I also tried the branch and it works with my singularity image. It would be great to have it merged!

Read more comments on GitHub >

github_iconTop Results From Across the Web

12. Virtual Environments and Packages — Python 3.11.1 ...
The module used to create and manage virtual environments is called venv . venv will usually install the most recent version of Python...
Read more >
Python Virtual Environments: A Primer
Customize your virtual environments using optional arguments to venv; Deactivate and remove virtual environments; Choose additional tools for ...
Read more >
Use Virtualenv to customize Python - IU KB - Indiana University
Virtualenv is a package that simplifies the process of installing other packages. It is similar to Anaconda in that it creates a small, ......
Read more >
Using Python Environments in Visual Studio Code
From within VS Code, you can create non-global environments, using virtual environments or Anaconda, by opening the Command Palette (Ctrl+Shift+P), start typing ...
Read more >
How to Set Up a Virtual Environment in Python – And Why It's ...
When developing software with Python, a basic approach is to install Python on your machine, install all your required libraries via the ...
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