Skip to content
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

ZMT zurich med tech

  1. Home
  2. Sim4Life
  3. Python API
  4. Feasibility of Sim4Life GPU Acceleration and Multithreaded Script Execution

Feasibility of Sim4Life GPU Acceleration and Multithreaded Script Execution

Scheduled Pinned Locked Moved Python API
9 Posts 3 Posters 220 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lucky_lin
    wrote last edited by
    #1

    Hello everyone! I'm currently running simulations with Sim4Life and would like to know if it's possible to improve efficiency through GPU acceleration or by running multiple scripts in parallel using multithreading. Could anyone share some experience or provide simple example code? Thanks a lot!

    1 Reply Last reply
    0
    • brynB Offline
      brynB Offline
      bryn
      ZMT
      wrote last edited by
      #2
      • in theory, you can do anything you could do in a "normal" Python installation, in the Sim4Life Python. You might just have to install the package (go to the Python folder in C:\Program Files\Sim4Life_<installed version>\Python and run python.exe -m pip install <some package>.

      • the analysis pipeline can run independent jobs in parallel when you run it from the GUI. In Python, the "Update" is probably blocking. @Sylvain might know?

      L 1 Reply Last reply
      0
      • brynB bryn
        • in theory, you can do anything you could do in a "normal" Python installation, in the Sim4Life Python. You might just have to install the package (go to the Python folder in C:\Program Files\Sim4Life_<installed version>\Python and run python.exe -m pip install <some package>.

        • the analysis pipeline can run independent jobs in parallel when you run it from the GUI. In Python, the "Update" is probably blocking. @Sylvain might know?

        L Offline
        L Offline
        lucky_lin
        wrote last edited by
        #3

        @bryn Is it correct that the EM LF Electro series of solvers do not support GPU acceleration?

        SylvainS 1 Reply Last reply
        0
        • L lucky_lin

          @bryn Is it correct that the EM LF Electro series of solvers do not support GPU acceleration?

          SylvainS Offline
          SylvainS Offline
          Sylvain
          ZMT
          wrote last edited by
          #4

          @lucky_lin The EM LF solvers do not support GPU acceleration, that is correct. They do use multi-processing on the CPU, though. You can enable that in the solver's setting of any LF simulation, provided your license allows it.

          As for multithreading/multithreading via Python scripts, it is in general entirely possible but the way to proceed (and whether or not it might be worth it) depends on what your scripts are doing (e.g. pre-processing grids and voxels, running simulations, or doing postprocessing) and what are the performance bottlenecks.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lucky_lin
            wrote last edited by Sylvain
            #5

            @Sylvain Is this how to set up multi-core processing in a Python script:

            solver_settings = simulation.SolverSettings  
            solver_settings.NumberOfProcesses = 0 # use all available cores
            
            SylvainS 1 Reply Last reply
            0
            • L lucky_lin

              @Sylvain Is this how to set up multi-core processing in a Python script:

              solver_settings = simulation.SolverSettings  
              solver_settings.NumberOfProcesses = 0 # use all available cores
              
              SylvainS Offline
              SylvainS Offline
              Sylvain
              ZMT
              wrote last edited by
              #6

              @lucky_lin Yes, that looks correct.

              You probably know this already, but for the sake of completeness (and for the other readers) note that you can find the Python equivalent of most (and ideally all) simulation settings by setting up a simulation in the GUI, changing the desired parameters from their default values, right-clicking on the simulation and choosing "To Python" in the menu. This should create a script visible in the Scripter window (click VIEW -> Scripter if it is not visible).

              feafcde0-92ef-40a1-b734-bcabc3c13b1c-image.png

              L 1 Reply Last reply
              1
              • SylvainS Sylvain

                @lucky_lin Yes, that looks correct.

                You probably know this already, but for the sake of completeness (and for the other readers) note that you can find the Python equivalent of most (and ideally all) simulation settings by setting up a simulation in the GUI, changing the desired parameters from their default values, right-clicking on the simulation and choosing "To Python" in the menu. This should create a script visible in the Scripter window (click VIEW -> Scripter if it is not visible).

                feafcde0-92ef-40a1-b734-bcabc3c13b1c-image.png

                L Offline
                L Offline
                lucky_lin
                wrote last edited by
                #7

                @Sylvain
                If I set solver_settings.NumberOfProcesses to 0 or a number greater than 3, the simulation fails, even though the computer I'm using has 208 cores.

                SylvainS 1 Reply Last reply
                0
                • L lucky_lin

                  @Sylvain
                  If I set solver_settings.NumberOfProcesses to 0 or a number greater than 3, the simulation fails, even though the computer I'm using has 208 cores.

                  SylvainS Offline
                  SylvainS Offline
                  Sylvain
                  ZMT
                  wrote last edited by
                  #8

                  @lucky_lin There could be many reasons, but the usual suspects would be licenses (i.e. you run out of MPI licenses to run on different processes), or RAM (parallelized simulations can use significantly more RAM and it may exceed what your operating system allows).
                  Best is, in general, to describe what you are doing (a screenshot of the simulation settings usually gives a lot of information, such as solver type and grid size), report the exact error you are getting (e.g. from the Console), and check the solver logs for errors (those due to license issues would typically be visible there).
                  I hope this helps already!

                  L 1 Reply Last reply
                  0
                  • SylvainS Sylvain

                    @lucky_lin There could be many reasons, but the usual suspects would be licenses (i.e. you run out of MPI licenses to run on different processes), or RAM (parallelized simulations can use significantly more RAM and it may exceed what your operating system allows).
                    Best is, in general, to describe what you are doing (a screenshot of the simulation settings usually gives a lot of information, such as solver type and grid size), report the exact error you are getting (e.g. from the Console), and check the solver logs for errors (those due to license issues would typically be visible there).
                    I hope this helps already!

                    L Offline
                    L Offline
                    lucky_lin
                    wrote last edited by
                    #9

                    @Sylvain I exported the electric field results from an AC simulation and found that the last six columns of the data are imaginary numbers. Are these the electric field values in three different directions? Why aren't they time-varying? Did I only export the peak values?

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Search