ContactEngineering / ContactMechanics

Contact mechanics using elastic half-space methods
https://contactengineering.github.io/ContactMechanics/
MIT License
21 stars 5 forks source link

Error running Hardwall simulation - Runtime error: Plan failed (Traceback from c++ library) #83

Closed sitangshugk95 closed 2 years ago

sitangshugk95 commented 2 years ago

Surface Topography and Contact Mechanics packages have been successfully installed. I am trying to run the example file Hardwall simulation from Contact Mechanics using Jupyter, but I am getting the following error - Screenshot from 2022-11-07 22-17-02 How can I solve this?

sitangshugk95 commented 2 years ago

Similar errors while running easy_hardwall_simulation

Screenshot from 2022-11-08 00-06-52

@sannant @pastewka @mcrot

sannant commented 2 years ago

Dear @sitangshugk95, sorry for all the mess

@jotelha built a docker image allowing to start a kind of virtual machine with SurfaceTopography, ContactMechanics and even Adhesion.

I think there is even a Docker application for windows but I never tried.

Please follow the instructions here: https://github.com/ContactEngineering/SurfaceTopography/tree/doc/instructions_for_docker_image

Sorry that we didn't come earlier to this solution.

I hope that using ContactMechanics via this image solves the problems.

sitangshugk95 commented 2 years ago

Hello @sannant ,

Thanks for the response.

  1. Were the screenshots that I sent an error on my part only, or are you seeinng the same errors too?
  2. I don't really need Windows anymore, as we have purchased a Linux system solely for running Contact Mechanics via your packages.
  3. @jotelha The installation guide for Docker has a lot of sudo commands on it, but I don't have sudo rights. Are there any other alternatives?
jotelha commented 2 years ago

@sitangshugk95 I am no SurfaceTopography expert, and I can't offer any third alternative next to the manual setup instructions or the docker image, but I am afraid without admin privileges on your machine, it will be difficult to get SurfaceTopography running properly either way. The docker image can help when you are having troubles putting together the right environment, but it will introduce many other inconveniences if you are not used to working with containers. If your machine does not have the docker engine installed and you don't have the privileges to do that, the docker image is of course useless anyway.

pastewka commented 2 years ago

We could convert the Docker into a Singularity image which can be run without root priviledges.

jotelha commented 2 years ago

Sure, but installing the singularity engine in the first place will of course still require root privileges, @sitangshugk95 . The docker recipe currently lives at https://github.com/IMTEK-Simulation/code-snippets/pull/20, shall we move that into SurfaceTopography, @pastewka ? Originally, that was only intended as my "quick and dirty" personal environment documentation, and I am a bit worried that it will introduce more maintenance overhead than it will resolve support issues in the long run.

sitangshugk95 commented 2 years ago

Hello @pastewka - that is what my IT dept suggested as well - use Singularity instead. IT has installed Singularity on my system, so I am able to download and open the Docker image using Singularity now. (My university has restricted Docker for security reasons, but Singularity is available for use)

Hello @jotelha I have followed your instructions , and I am currently on this screen after opening the jupyterlab server in my browser: Opened_Jupyterlab_server_in_browser

Specifically, I want to run and modify the HardwallSimulations jupyter notebook file from the ContactMechanics git repo. What should be my next step?

sannant commented 2 years ago

I am not sure that is the simplest solution, but you can run

wget https://raw.githubusercontent.com/ContactEngineering/ContactMechanics/1.0.0/examples/Hardwall_Simulation.ipynb

That will download it

sitangshugk95 commented 2 years ago
  1. Do you mean typing the command in the terminal of the window opened on the browser using Singularity? If yes, I have downloaded it : Singularity_screen What command should I use to run it?
  2. I used jupyter notebook to run it. Screenshot from 2022-11-10 03-17-18 I opened the link in a web browser, but when I try to run, I get the same error as I was getting on my own system (without using Singularity): Screenshot from 2022-11-10 03-17-36 Am I doing something wrong?
sitangshugk95 commented 2 years ago

@sitangshugk95 I am no SurfaceTopography expert, and I can't offer any third alternative next to the manual setup instructions or the docker image, but I am afraid without admin privileges on your machine, it will be difficult to get SurfaceTopography running properly either way. The docker image can help when you are having troubles putting together the right environment, but it will introduce many other inconveniences if you are not used to working with containers. If your machine does not have the docker engine installed and you don't have the privileges to do that, the docker image is of course useless anyway.

@jotelha The error that I am getting using the Docker image is the same as the one I was getting when using the manual steps - which somehow makes me feel like it is not an issue with my system (I might be wrong though). If you can convert it into a Singularity image and send me, I can try running it again.

P.S. I really appreciate you guys helping me out, as I am stuck in a project that needs BEM modeling. In fact, I made my advisor buy a dedicated Linux system just for running this code, so I really need to get this thing running asap.

sannant commented 2 years ago

Sorry for the mess . What you do wrong is that you do not need to start a notebook from the terminal in jupyterlab. jupyter lab replaces jupyter notebook I think there is enough material on the web to help you familliarize with jupyter lab.

But quickly: on the left in your second screenshoot you see a file browser of your local filesystem. You can open the notebook by double clicking and this should open it with the kernel from the docker/singularity image.

I think now you have already everything in your hands to make things work. I am happy to schedule a zoom meeting to discuss the last issues.

I can help with our code and singularity, but I almost never used docker.

jotelha commented 2 years ago

@sitangshugk95 I see you got the container running with singularity. Unfortunately, it's not that straight forward to just run a docker container with singularity if the container engineer did not think about making it compatible with different container engines. The image builds on https://jupyter-docker-stacks.readthedocs.io/en/latest/, and those don't have singularity in mind. The main issue here is that these images introduce their own user "jovyan" and expect their home folder to be available with the permissions set properly, which is not the case when simply launching with

singularity run docker://imteksim/jupyterlab-surfacetopography:0.3.0

As in your screenshots, you won't see the SurfaceTopography Kernel then and likely encounter many other errors. What worked for me with singularity is the following, but again, if you do not have root privileges on your local machine, you will likely hit another barrier here:

This will do a few things, in particular it will unpack the image locally, isolate it completely from your system (any changes done within the running container will be lost after stopping singularity), change to the correct directory and modify the permissions to what the original service needs.

You should end up with a launcher offering two kernels,

image

you should be able to download Antoine's test script,

image

and you should be able to run it after choosing the kernel

image

at least down to cell 14, where I encounter this error,

image

sitangshugk95 commented 2 years ago

@jotelha Thank you for the very detailed message. Once I get through the initial hurdle of getting to run the Docker image properly using singularity, the remaining steps look manageable.

For now, I tried singularity exec --writable --fakeroot --no-home --containall --userns docker://imteksim/jupyterlab-surfacetopography:0.3.0 bash -c 'cd /home/jovyan && chown -R jovyan . && start-wrapper.sh start-notebook.sh' as per your suggestion, and I got the following error: Screenshot from 2022-11-10 10-36-29

Also, if this does not work, is it possible to make a file compatible with Singularity directly? Would that make things simpler?

I have the following options available to me:

  1. A windows PC with admin access
  2. An Ubuntu system without admin access (but with Singularity installed)
jotelha commented 2 years ago

@sitangshugk95 that's exactly what I expected. I gave the docker image an overhaul, and (at least on my machine) it now runs without root privileges with

singularity run docker://imteksim/jupyterlab-surfacetopography:0.4.0

would you give it another try?

sitangshugk95 commented 2 years ago

@jotelha This works (yayy!!), thank you so much for going through all this. I do see the same error on cell 14, but that looks like a code error.

Just one final question - is there a way I can store the values that the program is executing somewhere on my local PC, so that I can use them as an input to another program (eg; calculate contact resistance in another FEM program based on the gap calculated by the SurfaceTopography package?)

sitangshugk95 commented 2 years ago

image

at least down to cell 14, where I encounter this error,

image

Hello @sannant , so I was finally able to run the codes on my system using the Docker images. However, I also get the same error involving "prestol" that @jotelha gets; so it looks like a code error. Do you have any inputs as to what might be causing this error, and how to fix it?

What do prestol and pentol do? Is it mandatory to use prestol for force inputs (as that is what I am mainly interested in)?

sannant commented 2 years ago

This is just because we changed the function signature.

You need to find the definition of the function of the code.

You need to read the documentation of the function.

This should be fixed in the current master but it isn't in the release you have in the docker image.

You can find the file path where it is defined by calling minimize_proxy? and/or minimize_proxy?? in a cell.

This will give you the docstring. That tells you that replaceing prestol by forcetol solves the problem.

It makes sense for you to learn to figure out were the code is defined, because our documentation is not perfect anyway.

I checked that after this change the whole example is executing properly.

jotelha commented 2 years ago

@jotelha This works (yayy!!), thank you so much for going through all this. I do see the same error on cell 14, but that looks like a code error.

Just one final question - is there a way I can store the values that the program is executing somewhere on my local PC, so that I can use them as an input to another program (eg; calculate contact resistance in another FEM program based on the gap calculated by the SurfaceTopography package?)

@sitangshugk95 we now automized the container image generation at https://github.com/ContactEngineering/ce-container-stack, please watch this in the future for changes to the image.

When running with singularity, the container engine should bind your home directory automatically and you should be able to dump anything you want persitently to your host file system with any standard method of numpy, pandas, or whatever library with IO functionality you prefer.

Best, Johannes

sannant commented 2 years ago

The way I usually dump results is using NuMPI.IO.NetCDF.NCStructuredGrid.

That is probably closest to what we do in contact.engineering as well if you are used to those outputs.

sitangshugk95 commented 1 year ago

@jotelha quick question - in the process that I am using currently to run the codes (and possibly make some changes to modify it to my application) using the Docker images, am I using your computational resources or ours? Also, if I want to write a new code using the existing packages, would you be able to see them? I ask this because we might want to keep some it private until the work is published, and I am not entirely sure how this works due to my limited familiarity with Linux OS.

jotelha commented 1 year ago

You are running on your local machine, no worries. This might be a suitable read https://epcced.github.io/2020-12-08-Containers-Online/index.html to understand what containers and container engines (Docker, Singularity, ...) actually do.