BachiLi / diffvg

Differentiable Vector Graphics Rasterization
https://people.csail.mit.edu/tzumao/diffvg/
Apache License 2.0
902 stars 152 forks source link

diffvg compiles correctly with CPU but not with GPU #56

Closed kristianQh closed 1 year ago

kristianQh commented 1 year ago

Running the installation steps on Manjaro Gnome with cuda 11.8, pytorch 12.1 only using CPU runs flawlessly. However, whenever I enable GPU (GTX 1070 Ti) compiling the setup.py installation stops at:

[ 28%] Building NVCC (Device) object CMakeFiles/diffvg.dir/diffvg_generated_diffvg.cpp.o

Here I among other errors receive the following;

CMake Error at diffvg_generated_diffvg.cpp.o.Release.cmake:280 (message):
  Error generating file
  /home/kristian/diffvg/build/temp.linux-x86_64-3.8/CMakeFiles/diffvg.dir//./diffvg_generated_diffvg.cpp.o

make[2]: *** [CMakeFiles/diffvg.dir/build.make:1103: CMakeFiles/diffvg.dir/diffvg_generated_diffvg.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:114: CMakeFiles/diffvg.dir/all] Error 2
make: *** [Makefile:103: all] Error 2
....
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '-j8']' returned non-zero exit status 2.

I also tried to create a small CMakeList.txt using CUDA on a small kernel example which worked correctly so I assume my CUDA is correctly setup. (Pytorch of course also recognises my GPU).

kristianQh commented 1 year ago

Hi @BachiLi Hope that is fine I am tagging you. I was just wondering what exact versions you recommend in order to make diffvg compile on GPU?

kristianQh commented 1 year ago

Just wanted to update this issue after spending way too many hours debugging. I was able to successfully install diffvg on a GPU on Windows with some small adjustments and by making a debug build. I also had to hardcode my Anaconda lib directory into the setup file.

Installing diffvg on a GPU on Linux (Manjaro Gnome) was a bit more challenging as pybind11 seemed to run into some trouble. What finally worked for me was deleting the shortcut for calling the caster's cast_op_type (line 949-952 in diffvg/pybind11/include/pybind11/cast.h). I have not thoroughly tested the compiled diffvg package, but running the example app single_circle.py works and uses my GPU.