Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPU accelerated support #66

Open
ChabaneAmaury opened this issue Sep 22, 2022 · 7 comments
Open

GPU accelerated support #66

ChabaneAmaury opened this issue Sep 22, 2022 · 7 comments

Comments

@ChabaneAmaury
Copy link
Contributor

@liubenyuan Since issue #22, I was wondering how to implement GPU support in the module. Could it be a thing to have a second module, completely separated? Like tensorflow and tensorflow-gpu? It may allow us to have gpu acceleration and have gpu specific optimizations in the program.
This would need 2 separated pipelines, but it could be of a great help to a lot of people. And the limited memory allowed on a single GPU makes it a good start to take a look at huge models support, since we would need some kind of slicing/dataflow method we could as well implement in the classic module.

@liubenyuan
Copy link
Collaborator

Sure! How could we maintain that these two modules share a common base of functions and sync between them?

@liubenyuan
Copy link
Collaborator

liubenyuan commented Sep 23, 2022

Hi, I set up a EIT community organization, eitcom for short, to host all the EIT related things (software, mesh, and possibly OSS hardware). Would you like to be a member of this and create, push and manage a separate pyeit-gpu module?

@ChabaneAmaury
Copy link
Contributor Author

Sure! How could we maintain that these two modules share a common base of functions and sync between them?

Not sure yet, since each update in the classic module needs to be manually rewritten and optimized for gpu, as stated in #22 .

I managed to make it work on gpu, but it is insanely slow (it constantly needs to send back and forth data between host memory and gpu memory, because I haven't optimized it yet).

I am actively looking into it, and when I will have something working (at least for fem and jac), then I will create and push on a new repo

@ChabaneAmaury
Copy link
Contributor Author

Hi @liubenyuan ,
I have dpone some research on why it is so slow using the GPU, and I came across this article, which state that memory exchanges between the main host and the GPU is the main bottleneck of this settup. It is efficient only when it comes to calculate the same thing thousands of times. Unfortunately (or fortunately, depending on how you see it), it is not the case in this module, making the pyeit-gpu module inefficient. I can still continue to optimize the module, but the cpu method is still the best, and will be for a very long time.
The only work-around I could suggest it to run the calculations on google-colab, but I am highly unexperienced with it so I won't assume anything right now.

@liubenyuan
Copy link
Collaborator

Thank you for your effort. And make pyeit-gpu as is and keep this repository. I will also try the gpu accelerated version of forward computing nevertheless. We could share the results :)

@ChabaneAmaury
Copy link
Contributor Author

ChabaneAmaury commented Sep 26, 2022

Thank you for your effort. And make pyeit-gpu as is and keep this repository. I will also try the gpu accelerated version of forward computing nevertheless. We could share the results :)

Alright, I will push what I have done so far, you will find the dev branch, it should be on it. You can try and launch the eit_static_jac.py example. If you have any issues regarding the installation, just come to me, I will do my best to guide you.

Update: Just as a reference, on my system, it takes around 5 min 33s to reconstruct the example with 16 electrodes (GPU: Nvidia RTX 2060 6GB), against 37s on the CPU (AMD Ryzen 3 3100 4-Core 3.9 GHz)

@ChabaneAmaury
Copy link
Contributor Author

I have updated the README file on the dev branch so you have clearer informations on how to setup everything :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants