comp-imaging / ProxImaL

A domain-specific language for image optimization.
MIT License
112 stars 29 forks source link

Cuda Version #39

Closed wiedemannc closed 7 years ago

wiedemannc commented 7 years ago

As discussed in the issue https://github.com/comp-imaging/ProxImaL/issues/38, here is the pull request.

I have created an example test_cuda.py. For pycuda to work, you need of course pycuda installed (https://pypi.python.org/pypi/pycuda) and you need the nvidia development toolkit. You also might need to set the environment variable PYCUDA_DEFAULT_NVCC_FLAGS (I needed to set this to "-ccbin clang-3.8" for being able to compile cuda kernels).

If everything's good, you should be able to run the test_cuda.py script (BTW: you might notice, that I have changed the variable initialization interface and allow variables to be initialized with an .init_val member; the original "x0" interface is still there).

Not in any examples or tests, but quite handy is the graphviz support for plotting the comp_graph :)

I have also created test cases for the linear operators and the prox functions (well, atm there is only group_norm1). Further, I have added the cuda implementation in the pock_chambolle unittests, and (finally ...) these tests also pass. The tests pass for python2 and python3.

Interface-wise, I have tried to adapt to what is already there (you see it in the example). I also tried to keep the pycuda dependency optional, so proximal is still running without pycuda installed.

Please take a look and I'm looking forward to your comments. Don't hesitate to criticize about design decisions, interfaces, implementation or whatever.

Kind Regards Christoph

SteveDiamond commented 7 years ago

First off let me apologize for the extremely slow response. This is an extraordinarily thorough contribution and I'm hugely appreciative. I don't understand the PyCuda code 100% but the tests work for me. I'm happy to merge this in and address my minor issues myself. Thanks again for doing this!

wiedemannc commented 7 years ago

Thanks for merging! If you have any questions or problems, don't hesitate to ask.