cellmodeller / CellModeller

GPU-accelerated multicellular modelling framework
http://cellmodeller.github.io/CellModeller/
Other
57 stars 48 forks source link

jitter_z=False fails to constrain cells in 2D #26

Closed odanieloliveira closed 3 years ago

odanieloliveira commented 4 years ago

Dear all, I've recently started to use CellModeller for my Master's thesis project. I was able to install the master branch following Tim Rudge's instructions posted in the comment section of another issue. However, when trying to run Tutorial1a as well as my own models the cells are leaving the plane (growing in 3D) even though I have set jitter_z=False. Does anybody have the same issue and if so, is there any way to fix this?

Thanks in advance for your help and time. Best regards, Daniel

avimanyu786 commented 4 years ago

Apparently, if you keep the position of the initial cell at (0,0,0.5) and raise the default number of maximum cells to 20000, you can simulate cells in 2D quite conveniently, over ~12000 cells. I just tested this on a GeForce GTX 1050 Ti with 4GB video memory.

image image

Please try experimenting with the following code(worked for the above screenshots):

import random
from CellModeller.Regulation.ModuleRegulator import ModuleRegulator
from CellModeller.Biophysics.BacterialModels.CLBacterium import CLBacterium
from CellModeller.GUI import Renderers
import numpy
import math

def setup(sim):
    # Set biophysics, signalling, and regulation models
    biophys = CLBacterium(sim, jitter_z=False, gamma = 20, max_planes=1, max_cells=20000)

    biophys.addPlane((0,0,0),(0,0,1),1.0) #Base plane
    #biophys.addPlane((10,0,0),(-1,0,0),1.0)
    #biophys.addPlane((-10,0,0),(1,0,0),1.0)
    #biophys.addPlane((0,10,0),(0,-1,0),1.0)
    #biophys.addPlane((0,-10,0),(0,1,0),1.0)

    # use this file for reg too
    regul = ModuleRegulator(sim, sim.moduleName)    
    # Only biophys and regulation
    sim.init(biophys, regul, None, None)

    # Specify the initial cell and its location in the simulation
    sim.addCell(cellType=0, pos=(0,0,0.5), dir=(1,0,0))

    # Add some objects to draw the models
    therenderer = Renderers.GLBacteriumRenderer(sim)
    sim.addRenderer(therenderer)
    sim.pickleSteps = 20

def init(cell):
    # Specify mean and distribution of initial cell size
    cell.targetVol = 3.0 + random.uniform(0.0,0.5)
    # Specify growth rate of cells
    cell.growthRate = 1.0
    cell.color = (0.0,1.0,0.0)

def update(cells):
    #Iterate through each cell and flag cells that reach target size for division
    for (id, cell) in cells.items():
        if cell.volume > cell.targetVol:
            cell.divideFlag = True

def divide(parent, d1, d2):
    # Specify target cell size that triggers cell division
    d1.targetVol = 3.0 + random.uniform(0.0,0.5)
    d2.targetVol = 3.0 + random.uniform(0.0,0.5)

It's a modified version of Tutorial_1c.py. I've kept only the base plane and reduced max_planes to 1. Hope that helps.

odanieloliveira commented 4 years ago

Dear Avimanyu,

First of all, thank you for your feedback! Following up on your comments, here's what I did:

Screenshot 2020-11-07 at 01 54 31 Screenshot 2020-11-07 at 01 55 48 Screenshot 2020-11-07 at 02 34 07 Screenshot 2020-11-07 at 02 34 20
import random
from CellModeller.Regulation.ModuleRegulator import ModuleRegulator
from CellModeller.Biophysics.BacterialModels.CLBacterium import CLBacterium
from CellModeller.GUI import Renderers
import numpy
import math

def setup(sim):
    # Set biophysics module
    biophys = CLBacterium(sim, jitter_z=False, gamma = 20, max_planes=1, max_cells=20000)

    biophys.addPlane((0,0,0),(0,0,1),1.0) #Base plane

    # Set up regulation module
    regul = ModuleRegulator(sim, sim.moduleName)    
    # Only biophys and regulation
    sim.init(biophys, regul, None, None)

    # Specify the initial cell and its location in the simulation
    sim.addCell(cellType=0, pos=(0,0,0.5), dir=(1,0,0))

    # Add some objects to draw the models
    therenderer = Renderers.GLBacteriumRenderer(sim)
    sim.addRenderer(therenderer)

    # Specify how often data is saved
    sim.pickleSteps = 100

def init(cell):
    # Specify mean and distribution of initial cell size
    cell.targetVol = 3.5 + random.uniform(0.0,0.5)
    # Specify growth rate of cells
    cell.growthRate = 1.0
    cell.color = (0.0,1.0,0.0)

def update(cells):
    #Iterate through each cell and flag cells that reach target size for division
    for (id, cell) in cells.items():
        if cell.volume > cell.targetVol:
            cell.divideFlag = True

def divide(parent, d1, d2):
    # Specify target cell size that triggers cell division
    d1.targetVol = 3.5 + random.uniform(0.0,0.5)
    d2.targetVol = 3.5 + random.uniform(0.0,0.5)

Finally, since my own models require more flexibility in terms of the initial number of cells and their positional parameters, the best fix that I found and that I've been using for a while now is to add one base plane and a second plane on top to squeeze the cells and force them to grow in 2D. I've been going up to 10 000 cells or more and I didn't feel much increase in computational time (due to the increased number of contact calculations). Anyway, it would still be interesting to sort out what's happening with jitter-z since I have a colleague who uses an older version of CellModeller and doesn't have the same issues. I'll try to take some time to figure it out and I'll keep you updated if I find any other solution.

timrudge commented 4 years ago

Hi there - sorry for the delay. I am really not sure what the problem is here, but anyway I recommend you switch to the newer python 3 code found on the dev branch. To do this;

  1. Clone the repo - git clone https://github.com/HaseloffLab/CellModeller.git
  2. cd CellModeller
  3. Checkout the branch - git checkout dev
  4. Install the package - pip install -e .

You can then run the GUI - python Scripts/CellModellerGUI.py, or batch mode - python Scripts/batch.py

Let me know if you have any problems.

best Tim

On 07-11-2020, at 00:03, odanieloliveira notifications@github.com wrote:

Dear Avimanyu,

First of all, thank you for your feedback! Following up on your comments, here's what I did:

• Try to replicate your result in my machine which I was able to do just by copying the code. Here are the screenshots:

• Inspired by the parameters you changed and since my initial report was regarding Tutorial_1a.py I modified Tutorial_1a.py to try to replicate the results. Firstly, by setting max_cells= 20 000 and adding just a base plane the cells grow in 2D until around 500 cells but then break out. Secondly, changing from pos=(0,0,0) to pos=(0,0,0.5) allowed the simulation to run smoothly in 2D up to around 9000 cells. The only difference between your modified version of Tutorial_1c.py and my modified version of Tutorial_1a.py seems to be the cell.targetVol which is set to 3.0 and 3.5 respectively. Please find the modified code as well as the screenshots below.

import random from CellModeller.Regulation.ModuleRegulator import ModuleRegulator from CellModeller.Biophysics.BacterialModels.CLBacterium import CLBacterium from CellModeller.GUI import Renderers import numpy import math

def setup(sim):

Set biophysics module

biophys = CLBacterium(sim, jitter_z=False, gamma = 20, max_planes=1, max_cells=20000)

biophys.addPlane((0,0,0),(0,0,1),1.0) #Base plane

# Set up regulation module
regul = ModuleRegulator(sim, sim.moduleName)  
# Only biophys and regulation
sim.init(biophys, regul, None, None)

# Specify the initial cell and its location in the simulation
sim.addCell(cellType=0, pos=(0,0,0.5), dir=(1,0,0))

# Add some objects to draw the models
therenderer = Renderers.GLBacteriumRenderer(sim)
sim.addRenderer(therenderer)

# Specify how often data is saved
sim.pickleSteps = 100

def init(cell):

Specify mean and distribution of initial cell size

cell.targetVol = 3.5 + random.uniform(0.0,0.5)
# Specify growth rate of cells
cell.growthRate = 1.0
cell.color = (0.0,1.0,0.0)

def update(cells):

Iterate through each cell and flag cells that reach target size for division

for (id, cell) in cells.items():
    if cell.volume > cell.targetVol:
        cell.divideFlag = True

def divide(parent, d1, d2):

Specify target cell size that triggers cell division

d1.targetVol = 3.5 + random.uniform(0.0,0.5)
d2.targetVol = 3.5 + random.uniform(0.0,0.5)

Finally, since my own models require more flexibility in terms of the initial number of cells and their positional parameters, the best fix that I found and that I've been using for a while now is to add one base plane and a second plane on top to squeeze the cells and force them to grow in 2D. I've been going up to 10 000 cells or more and I didn't feel much increase in computational time (due to the increased number of contact calculations). Anyway, it would still be interesting to sort out what's happening with jitter-z since I have a colleague who uses an older version of CellModeller and doesn't have the same issues. I'll try to take some time to figure it out and I'll keep you updated if I find any other solution.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

danieljones333 commented 4 years ago

Hi, I'm also experiencing the same issue as OP and have adopted odanieloliveira's workaround of adding a second plane. Just checked out the dev branch two days ago so it should be the latest version of the code. best regards, Daniel

timrudge commented 4 years ago

You have the same problem on dev branch? I will look into this. You should not need planes, that will be inefficient…

On 11-11-2020, at 12:27, danieljonesiii notifications@github.com wrote:

Hi, I'm also experiencing the same issue as OP and have adopted odanieloliveira's workaround of adding a second plane. Just checked out the dev branch two days ago so it should be the latest version of the code. best regards, Daniel

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

danieljones333 commented 4 years ago

My command of git is unfortunately rather shaky but here is the output of git log, apologies if I'm on the wrong branch:

`commit b896f3109387307b773960627c3656ba72bdcf6a (HEAD -> dev, origin/dev) Author: Tim Rudge timrudge@gmail.com Date: Wed Jul 8 09:16:58 2020 -0400

Add load geometry button to only load cell position, orientation, length. Not fully tested

commit 6c34ad45f149a0d6ae2365774ea43c3d583722b5 Author: Tim Rudge timrudge@gmail.com Date: Wed Jun 17 19:30:30 2020 -0400

Correct rendering of signal grid, scaled to max

commit 58fc68cd8d70abee8846d7c344bb36f1ecd4c623 Author: Tim Rudge timrudge@gmail.com Date: Wed Jun 17 19:29:38 2020 -0400

Fix saving of signals and species in pickles

etc `

timrudge commented 4 years ago

Hi all - this is very strange, I can run the dev branch using Examples/ex1_simpleGrowth.py and it works fine. Did you do “pip install -e .” After switching to dev branch, and before running the example models?

On 11-11-2020, at 12:38, danieljonesiii notifications@github.com wrote:

My command of git is unfortunately rather shaky but here is the output of git log, apologies if I'm on the wrong branch:

`commit b896f31 (HEAD -> dev, origin/dev) Author: Tim Rudge timrudge@gmail.com Date: Wed Jul 8 09:16:58 2020 -0400

Add load geometry button to only load cell position, orientation, length. Not fully tested

commit 6c34ad4 Author: Tim Rudge timrudge@gmail.com Date: Wed Jun 17 19:30:30 2020 -0400

Correct rendering of signal grid, scaled to max

commit 58fc68c Author: Tim Rudge timrudge@gmail.com Date: Wed Jun 17 19:29:38 2020 -0400

Fix saving of signals and species in pickles

`

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

odanieloliveira commented 4 years ago

Hey everyone. I honestly haven't tried installing the dev branch since I'm getting closer to a deadline and I don't feel very comfortable doing those kinds of changes at this moment. Regardless, I've just tried running Examples/ex1_simpleGrowth.py on my machine with the version with which I first reported the issue, and, like Tim, I was able to run up to 20 000 cells without any z-axis movement. However, I must say I first noticed the issue not on Examples/ex1_simpleGrowth.py but instead on a model of my own, and then, in Examples/Tutorial_1/Tutorial_1a.py and found the same problem which apparently also happens in danieljones333's and avimanyu786's machines. Tim, if it's not asking too much, could you please try running Examples/Tutorial_1/Tutorial_1a.py instead of Examples/ex1_simpleGrowth.py in your machine with the dev branch to see if the issue persists?

Thank you all for your help!

timrudge commented 4 years ago

Sure. I ran it to about 1000 cells with the dev branch code and it remains 2D.

On 16-11-2020, at 18:10, odanieloliveira notifications@github.com wrote:

Hey everyone. I honestly haven't tried installing the dev branch since I'm getting closer to a deadline and I don't feel very comfortable doing those kinds of changes at this moment. Regardless, I've just tried running Examples/ex1_simpleGrowth.py on my machine with the version with which I first reported the issue, and, like Tim, I was able to run up to 20 000 cells without any z-axis movement. However, I must say I first noticed the issue on a model of my own, and then, as a test to rule out any issue unique to my model I ran Examples/Tutorial_1/Tutorial_1a.py and found the same problem which apparently is also happening in danieljones333's and avimanyu786's machines. Tim, if it's not asking too much, could you please try running Examples/Tutorial_1/Tutorial_1a.py instead of Examples/ex1_simpleGrowth.py in your machine with the dev branch to see if the issue persists?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

odanieloliveira commented 4 years ago

So strange! But thanks, I just ran it as well up to 11000 cells and it seems to be working fine now! I'll try with one of my models as well.

danieljones333 commented 4 years ago

Just to be safe I created a fresh conda environment, re-cloned the git repository, switched to dev branch, and re-installed, but I'm still having issues. (I've also tried running the code on another machine, as well as running the code from a docker container as described here, with similar results.)

For instance, here is what it looks like after running Examples/Tutorial_1/Tutorial_1a.py on my laptop for 200 steps: step-00200_cropped

I should add that the problems seem to go deeper than undesired z axis movement. When running Examples/Tutorial_1/Tutorial_1a.py using the Scripts/batch.py script, the simulation usually fails anywhere between 10 and ~100s of cells. Here are the tracebacks from two independent runs of Tutorial_1a.py:

200    32 cells      54 cts       7 iterations  residual = 0.004056
Traceback (most recent call last):
  File "/home/daniel/djl/code/CellModeller/Scripts/batch.py", line 54, in <module>
    main()
  File "/home/daniel/djl/code/CellModeller/Scripts/batch.py", line 50, in main
    simulate(moduleName, platnum, devnum)
  File "/home/daniel/djl/code/CellModeller/Scripts/batch.py", line 18, in simulate
    sim.step()
  File "/home/daniel/djl/code/CellModeller/CellModeller/Simulator.py", line 360, in step
    while not self.phys.step(self.dt): #neighbours are current here
  File "/home/daniel/djl/code/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 569, in step
    if self.progress():
  File "/home/daniel/djl/code/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 536, in progress
    if self.tick(self.actual_dt):
  File "/home/daniel/djl/code/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 601, in tick
    self.sub_tick_init(dt)
  File "/home/daniel/djl/code/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 590, in sub_tick_init
    self.sort_cells()
  File "/home/daniel/djl/code/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 755, in sort_cells
    self.sq_inds.put(numpy.arange(self.n_sqs), numpy.searchsorted(sorted_sqs, numpy.arange(self.n_sqs), side='left'))
MemoryError: Unable to allocate 6.58 TiB for an array with shape (904277555200,) and data type int64e 

  120     8 cells      16 cts       4 iterations  residual = 0.004618
/home/daniel/djl/code/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py:1009: RuntimeWarning: divide by zero encountered in true_divide
  alpha = numpy.float32(rsold/pAp)
Traceback (most recent call last):
  File "/home/daniel/djl/code/CellModeller/Scripts/batch.py", line 54, in <module>
    main()
  File "/home/daniel/djl/code/CellModeller/Scripts/batch.py", line 50, in main
    simulate(moduleName, platnum, devnum)
  File "/home/daniel/djl/code/CellModeller/Scripts/batch.py", line 18, in simulate
    sim.step()
  File "/home/daniel/djl/code/CellModeller/CellModeller/Simulator.py", line 360, in step
    while not self.phys.step(self.dt): #neighbours are current here
  File "/home/daniel/djl/code/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 569, in step
    if self.progress():
  File "/home/daniel/djl/code/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 536, in progress
    if self.tick(self.actual_dt):
  File "/home/daniel/djl/code/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 601, in tick
    self.sub_tick_init(dt)
  File "/home/daniel/djl/code/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 583, in sub_tick_init
    self.update_grid() # we assume local cell_centers is current
  File "/home/daniel/djl/code/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 707, in update_grid
    self.grid_x_min = int(math.floor(min_x_coord / self.grid_spacing))
ValueError: cannot convert float NaN to integer

I don't have much experience programming with OpenCL but my intuition is that something is going wrong in the underlying OpenCL calls. Certainly something is very wrong when the code tries to initialize arrays with shape (904277555200,).

timrudge commented 4 years ago

Which hardware/OS have you tried running on? Also when you say re-install you mean via pip?

On 17-11-2020, at 07:49, danieljones333 notifications@github.com wrote:

Just to be safe I created a fresh conda environment, re-cloned the git repository, switched to dev branch, and re-installed, but I'm still having issues. (I've also tried running the code on another machine, as well as running the code from a docker container as described here, with similar results.)

For instance, here is what it looks like after running Examples/Tutorial_1/Tutorial_1a.py on my laptop for 200 steps:

I should add that the problems seem to go deeper than undesired z axis movement. When running Examples/Tutorial_1/Tutorial_1a.py using the Scripts/batch.py script, the simulation usually fails anywhere between 10 and ~100s of cells. Here are the tracebacks from two independent runs of Tutorial_1a.py:

200 32 cells 54 cts 7 iterations residual = 0.004056 Traceback (most recent call last): File "/home/daniel/djl/code/CellModeller/Scripts/batch.py", line 54, in main() File "/home/daniel/djl/code/CellModeller/Scripts/batch.py", line 50, in main simulate(moduleName, platnum, devnum) File "/home/daniel/djl/code/CellModeller/Scripts/batch.py", line 18, in simulate sim.step() File "/home/daniel/djl/code/CellModeller/CellModeller/Simulator.py", line 360, in step while not self.phys.step(self.dt): #neighbours are current here File "/home/daniel/djl/code/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 569, in step if self.progress(): File "/home/daniel/djl/code/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 536, in progress if self.tick(self.actual_dt): File "/home/daniel/djl/code/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 601, in tick self.sub_tick_init(dt) File "/home/daniel/djl/code/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 590, in sub_tick_init self.sort_cells() File "/home/daniel/djl/code/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 755, in sort_cells self.sq_inds.put(numpy.arange(self.n_sqs), numpy.searchsorted(sorted_sqs, numpy.arange(self.n_sqs), side='left')) MemoryError: Unable to allocate 6.58 TiB for an array with shape (904277555200,) and data type int64e

120 8 cells 16 cts 4 iterations residual = 0.004618 /home/daniel/djl/code/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py:1009: RuntimeWarning: divide by zero encountered in true_divide alpha = numpy.float32(rsold/pAp) Traceback (most recent call last): File "/home/daniel/djl/code/CellModeller/Scripts/batch.py", line 54, in main() File "/home/daniel/djl/code/CellModeller/Scripts/batch.py", line 50, in main simulate(moduleName, platnum, devnum) File "/home/daniel/djl/code/CellModeller/Scripts/batch.py", line 18, in simulate sim.step() File "/home/daniel/djl/code/CellModeller/CellModeller/Simulator.py", line 360, in step while not self.phys.step(self.dt): #neighbours are current here File "/home/daniel/djl/code/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 569, in step if self.progress(): File "/home/daniel/djl/code/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 536, in progress if self.tick(self.actual_dt): File "/home/daniel/djl/code/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 601, in tick self.sub_tick_init(dt) File "/home/daniel/djl/code/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 583, in sub_tick_init self.update_grid() # we assume local cell_centers is current File "/home/daniel/djl/code/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 707, in update_grid self.grid_x_min = int(math.floor(min_x_coord / self.grid_spacing)) ValueError: cannot convert float NaN to integer

I don't have much experience programming with OpenCL but my intuition is that something is going wrong in the underlying OpenCL calls. Certainly something is very wrong when the code tries to initialize arrays with shape (904277555200,).

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

odanieloliveira commented 4 years ago

On my side, I tried running my model overnight and it seems to be working fine now. I'll keep an eye on the issue and let you know if it returns again. Thanks for the help!

danieljones333 commented 4 years ago

Also when you say re-install you mean via pip?

Yes, I ran 'pip install -e . ' .

Which hardware/OS have you tried running on?

My laptop is running Linux Mint 19.1 with an Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz and Intel Corporation HD Graphics 620. I've tried running with two different OpenCL drivers: the CPU-based "pocl" driver as well as the "Neo" driver from Intel for the integrated graphics card. Interestingly, with the pocl driver I'm able to run Tutorial_1a.py for a few hundred steps before crashing (as described above) whereas with the Neo driver the simulation crashes immediately.

I don't have access to the other workstation right now but it is running Ubuntu 18.04 with an Nvidia graphics card - I can get back to you with more details later. UPDATE: The workstation has two Nvidia GeForce RTX 2070 SUPER GPUs and an Intel(R) Core(TM) i5-9600K CPU. As on the laptop, running the code with pocl platform leads to a memory error after a few hundred steps

$ python Scripts/batch.py Examples/Tutorial_1/Tutorial_1a.py 
Select OpenCL platform:
press 0 for <pyopencl.Platform 'NVIDIA CUDA' at 0x5597a6ab32e0>
press 1 for <pyopencl.Platform 'Portable Computing Language' at 0x7f20d5aa1008>
Platform Number: 1
Select OpenCL device:
press 0 for <pyopencl.Device 'pthread-Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz' on 'Portable Computing Language' at 0x5597a6aa7680>
Device Number: 0
Set up OpenCL context:
  Platform: Portable Computing Language
  Device: pthread-Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
Importing model Tutorial_1a
10           2 cells           1 contacts    0.000050 hour(s) or 0.003001 minute(s) or 0.180082 second(s)
  [snip]
210    34 cells      47 cts       2 iterations  residual = 0.002674
Traceback (most recent call last):
  File "/home/danielj/CellModeller/Scripts/batch.py", line 54, in <module>
    main()
  File "/home/danielj/CellModeller/Scripts/batch.py", line 50, in main
    simulate(moduleName, platnum, devnum)
  File "/home/danielj/CellModeller/Scripts/batch.py", line 18, in simulate
    sim.step()
  File "/home/danielj/CellModeller/CellModeller/Simulator.py", line 360, in step
    while not self.phys.step(self.dt): #neighbours are current here
  File "/home/danielj/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 569, in step
    if self.progress():
  File "/home/danielj/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 536, in progress
    if self.tick(self.actual_dt):
  File "/home/danielj/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 601, in tick
    self.sub_tick_init(dt)
  File "/home/danielj/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 590, in sub_tick_init
    self.sort_cells()
  File "/home/danielj/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 755, in sort_cells
    self.sq_inds.put(numpy.arange(self.n_sqs), numpy.searchsorted(sorted_sqs, numpy.arange(self.n_sqs), side='left'))
MemoryError: Unable to allocate 349. TiB for an array with shape (47946498945009,) and data type int64

whereas choosing the Nvidia driver leads to an immediate error:

$ python Scripts/batch.py Examples/Tutorial_1/Tutorial_1a.py 
Select OpenCL platform:
press 0 for <pyopencl.Platform 'NVIDIA CUDA' at 0x55e654fda2e0>
press 1 for <pyopencl.Platform 'Portable Computing Language' at 0x7f2e8db72008>
Platform Number: 0
Select OpenCL device:
press 0 for <pyopencl.Device 'GeForce RTX 2070 SUPER' on 'NVIDIA CUDA' at 0x55e654fd7b70>
press 1 for <pyopencl.Device 'GeForce RTX 2070 SUPER' on 'NVIDIA CUDA' at 0x55e654fd9730>
Device Number: 0
Set up OpenCL context:
  Platform: NVIDIA CUDA
  Device: GeForce RTX 2070 SUPER
Importing model Tutorial_1a
Traceback (most recent call last):
  File "/home/danielj/CellModeller/Scripts/batch.py", line 54, in <module>
    main()
  File "/home/danielj/CellModeller/Scripts/batch.py", line 50, in main
    simulate(moduleName, platnum, devnum)
  File "/home/danielj/CellModeller/Scripts/batch.py", line 18, in simulate
    sim.step()
  File "/home/danielj/CellModeller/CellModeller/Simulator.py", line 360, in step
    while not self.phys.step(self.dt): #neighbours are current here
  File "/home/danielj/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 569, in step
    if self.progress():
  File "/home/danielj/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 536, in progress
    if self.tick(self.actual_dt):
  File "/home/danielj/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 601, in tick
    self.sub_tick_init(dt)
  File "/home/danielj/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 583, in sub_tick_init
    self.update_grid() # we assume local cell_centers is current
  File "/home/danielj/CellModeller/CellModeller/Biophysics/BacterialModels/CLBacterium.py", line 707, in update_grid
    self.grid_x_min = int(math.floor(min_x_coord / self.grid_spacing))
ValueError: cannot convert float NaN to integer

UPDATE 2 I've done a little more digging and it seems like at least part of the problem is that the loop inside CGSSolv(self, dt, alpha, substep=False) in CLBacterium.py is failing to converge - when I insert a print(rsold) statement inside the loop for iter in range(max_iters): I can see that the value of rsold typically decreases upon the first iteration but then skyrockets upon subsequent iterations.

UPDATE 3 I was able to resolve the issue by installing the Intel® CPU Runtime for OpenCL™ Applications 18.1 for Linux* OS (64bit only) from https://software.intel.com/content/www/us/en/develop/articles/opencl-drivers.html.

avimanyu786 commented 3 years ago

Glad it helped you @odanieloliveira !

@danieljones333 @timrudge I switched to the dev branch from inside the docker container but unfortunately the issue still persists. Also tried installing the intel opencl runtime via the intel-opencl ppa(within the container) but still got similar results. Could it have something to do with the if not revisions(based on 2to3) in the divide_cell function of CLBacterium.py? It differs from the Python 2 version where this issue wasn't there.

avimanyu786 commented 3 years ago

Can confirm with the 1050 Ti that apparently, commit https://github.com/danilexn/CellModeller/commit/ae4eb610300c3f64d88e2445b83016ab7e6d066c fixes this issue..was able to run Tutorial_1a.py just fine upto 10,000 cells. Kudos to @danilexn!

timrudge commented 3 years ago

Hi @avimanyu786 is this issue resolved now?

avimanyu786 commented 3 years ago

Hi @avimanyu786 is this issue resolved now?

@timrudge

Yes Sir. https://github.com/HaseloffLab/CellModeller/pull/29 fixed it 😄.