[petsc-users] Calling Pytorch and Python within PETSc C/C++ code
Amneet Bhalla
mail2amneet at gmail.com
Mon Jun 13 21:46:14 CDT 2022
Thanks for the information. We will check these examples out. Basically we
have some trained ANNs that will provide few scalars to the C++ based CFD
code. We won’t envision doing too much data transfer between C++ and
Python/PyTorch.
On Mon, Jun 13, 2022 at 2:11 PM Barry Smith <bsmith at petsc.dev> wrote:
>
> Note that your Python main ptsc4py program can call C/C++ code for some
> of its computations, so if you have a lot of C/C++ code you do not need to
> change it all to Python. It is also possible to call Petsc4py (and hence
> PyTorch) from a C/C++ main but a bit more cumbersome so not recommended.
> See src/ksp/ksp/tutorials/ex100.c and ex100.py for an example of a C/C++
> main that uses petsc4py (in a limited way).
>
>
> On Jun 13, 2022, at 4:42 PM, Zhang, Hong via petsc-users <
> petsc-users at mcs.anl.gov> wrote:
>
> No. It is not common to execute Python scripts or libraries from C/C++
> code. If you are looking for ways to use PETSc and PyTorch together, it is
> best to build your application in Python so that you can use both petsc4py
> and PyTorch. See the following code for an example:
> https://github.com/caidao22/pnode
>
> Hong (Mr.)
>
> On Jun 13, 2022, at 9:50 AM, Amneet Bhalla <mail2amneet at gmail.com> wrote:
>
>
> Hi Guys,
>
> Is there a PETSc interface to make calls to Python scripts or libraries
> (e.g., Pytorch) from a C/C++ code making use of PETSc? If so, are there
> some examples that I refer to?
>
> Thanks,
> --
> --Amneet
>
>
>
>
>
> --
--Amneet
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20220613/19720712/attachment.html>
More information about the petsc-users
mailing list