After tinkering with my code for a while, I noticed that changing from CUDA_VISIBLE_DEVICES="1,2" to CUDA_VISIBLE_DEVICES="0,1" makes everything work without any issues. Why does GPU 0 have to be included in the visible devices when using a custom CUDA module? What am I missing? Thanks!