[ / / / / / / / / / / / / / ] [ dir / cafechan / civ / doomer / just / tingles / vichan / vore / zoo ][Options][ watchlist ]

/tech/ - Technology

You can now write text to your AI-generated image at https://aiproto.com It is currently free to use for Proto members.
Email
Comment *
File
Select/drop/paste files here
Password (Randomized for file and post deletion; you may also set your own.)
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Expand all images

File (hide): 5a4b0c72dd3caf0⋯.png (843.3 KB, 781x1024, 781:1024, 64mwomydu7921.png) (h) (u)

[–]

 No.1024618>>1024656 [Watch Thread][Show All Posts]

I have a very large C program that I would to call Python from, for a single method. Specifically, i'd like to have my C code evaluate a trained machine learning model. Having an entire Python interpreter in the code would slow it down too much. I want to go really really fast. What is the correct way to embark on this?

Sadly, there seem to be no good ML libraries for C, other than a few gems coded by bronies with no documentation. Without any explanation it's hardly expectable to import the headers and use it...

I have looked in to using pipes between C and Python to make a fifo file to share the data, but I am looking to do this as quickly as possible because I would like to do this many many times per second. If anyone has a suggestion on how to do this or would like to take a shit on me, I would appreciate it. How to connect my C and Python very very fast?

 No.1024636

Writing python modules in C is painful, but that's what you got to do. If find TCL really easy in that matter.


 No.1024656

>>1024618 (OP)

Are you sure pipes would be too slow? Try it and see. If you set up buffering correctly they can be quite fast. Failing that, I would look into faster IPC methods. Basically the fastest you can get is shared memory. There might be libraries to do all this, but basically you would need to: set up the mmap in a parent process. Fork + exec to the python code. From python you would write items to a loop queue, while the c code would read items out. Add some locking mechanisms to prevent them stepping on each others toes. Though the python code would almost certainly become the limiting factor in that case.




[Return][Go to top][Catalog][Screencap][Nerve Center][Cancer][Update] ( Scroll to new posts) ( Auto) 5
2 replies | 0 images | Page ?
[Post a Reply]
[ / / / / / / / / / / / / / ] [ dir / cafechan / civ / doomer / just / tingles / vichan / vore / zoo ][ watchlist ]