6 ms·
I love how many python to native/gpu code projects there are now. It's nice to see a lot of competition in the space. An alternative to this one could be Taichi
by raytopia 2y ago
I love how many python to native/gpu code projects there are now. It's nice to see a lot of competition in the space. An alternative to this one could be Taichi Lang [0] it can use your gpu through Vulkan so you don't have to own Nvidia hardware. Numba [1] is another alternative that's very popular. I'm still waiting on a Python project that compiles to pure C (unlike Cython [2] which is hard to port) so you can write homebrew games or other embedded applications.
[0] https://www.taichi-lang.org/ https://www.taichi-lang.org/
[1] http://numba.pydata.org/ http://numba.pydata.org/
[2] https://cython.readthedocs.io/en/stable/ https://cython.readthedocs.io/en/stable/
- setopt 2y agoCuPy is also great – makes it trivial to port existing numerical code from NumPy/SciPy to CUDA, or to write code than can run either on CPU or on GPU. I recently saw a 2-3 orders of magnitude speed-up of some physics code when I got a mid-range nVidia card and replaced a few NumPy and SciPy calls with CuPy.
- 6gvONxR4sf7o 2y agoDon’t forget JAX! It’s my preferred library for “i want to write numpy but want it to run on gpu/tpu with auto diff etc”
- westurner 2y agoFrom https://news.ycombinator.com/item?id=37686351 https://news.ycombinator.com/item?id=37686351 : >> sympy.utilities.lambdify.lambdify() https://github.com/sympy/sympy/blob/a76b02fcd3a8b7f79b3a88df50c19eb7aee33c17/sympy/utilities/lambdify.py#L182 https://github.com/sympy/sympy/blob/a76b02fcd3a8b7f79b3a88df... : >> """Convert a SymPy expression into a function that allows for fast numeric evaluation""" [e.g. the CPython math module, mpmath, NumPy, SciPy, CuPy, JAX, TensorFlow, SymPy, numexpr,] sympy#20516: "re-implementation of torch-lambdify" https://github.com/sympy/sympy/pull/20516 https://github.com/sympy/sympy/pull/20516
- skrhee 2y agoI would like to warn people away from taichi if possible. At least back in 1.7.0 there were some bugs in the code that made it very difficult to work with.
- hoosieree 2y agoDo you have any more specifics about these limitations? I'm considering trying Taichi for a project because it seems to be GPU vendor agnostic (unlike CuPy).
- sinuhe69 2y agoI only dabbled in Taichi, but I find its magic has limitation. I took a provided example, just increased the length of the loop and bam! it crashed the Windows driver. Obviously it ran out of memory but I have no idea how how to adjust except experiment with different values. If it has information about the GPU and its memory, I thought it could automatically adjust the block size but apparently not. There is a config command to fine tune the for loop parallelizing but the docs says we normally do not need to use them.
- szvsw 2y agoI’m a huge Taichi stan. So much easier and more elegant than numba. The support for data classes and data_oriented classes is excellent. Being able to define your own memory layouts is extremely cool. Great documentation. Really really recommend!
- Joky 2y ago> I'm still waiting on a Python project that compiles to pure C In case you haven't tried it yet, Pythran is an interesting one to play with: https://pythran.readthedocs.io https://pythran.readthedocs.io Also, not compiling to C but to native code still would be Mojo: https://www.modular.com/max/mojo https://www.modular.com/max/mojo
- holoduke 2y agoDoes it really matters in performance. I see python in these kind of setups as orchestrators of computing apis/engines. For example from python you instruct to compute following list etc. No hard computing in python. Performance not so much of an issue.
- crabbone 2y agoMarshaling is an issue as well as concurrency. Simply copying a chunk of data between two libraries through Python is already painful. There are so-called "buffer API" in Python, but it's very rare that Python users can actually take advantage of this feature. If anything in Python as much as looks at the data, that's not going to work etc. Similarly, concurrency. A lot of native libraries for Python are written with the expectation that nothing in Python really runs concurrently. And then you are presented with two bad options: try running in different threads (so that you don't have to copy data), but things will probably break because of races, or run in different processes, and spend most of the time copying data between them. Your interface to stuff like MPI is, again, only at the native level, or you will copy so much that the benefits of distributed computation might not outweigh the downsides of copying.
- pjmlp 2y agoI would rather that Python catches up with Common Lisp tooling in JIT/AOT in the box, instead of compilation via C.
- heavyset_go 2y agoI'd kill for AOT compiled Python. 3.13 ships with a basic JIT compiler.
- pjmlp 2y agoIn 3.13 you need to compile Python yourself if you want to test the preview JIT.
- LoganDark 2y agomypyc can compile a strictly-typed subset of Python AOT to native code, and as a bonus it can still interop with native Python libraries whose code wasn't compiled. It's slightly difficult to set up but I've used it in the past and it is a decent speedup. (plus mypy's strict type checking is sooo good)
- zelphirkalt 2y agoWhy is it named after a type checking library?
- LoganDark 2y agoBecause it uses that library for type checking?
- heavyset_go 2y agoIt's part of the Mypy project: https://github.com/python/mypy/tree/master/mypyc https://github.com/python/mypy/tree/master/mypyc
- crabbone 2y ago[flagged]
- tony69 2y agohttps://nuitka.net/ https://nuitka.net/ ?
- jkercher 2y agoI'm not looking for an argument, but my knee jerk reaction to seeing 4 or 5 different answers to the question of getting python to C... Why not just learn C?
- parentheses 2y agoThe python already exists. These efforts enable increasing performance without having to rewrite in a very different language.
- richrichie 2y agoI have dabbled in Cython, C and Rust via PyO3. C is much cleaner and portable. Easy to use in Python directly.
- bradknowles 2y agoI’m happy to have ways to run my python code that will execute much faster on GPUs, but I don’t want anything that is tied to a particular GPU family. I’ll happily use CUDA if I’m on NVIDIA, but I want something that is also performant on other architectures as well. Otherwise, I’m not going to bother.