Python3 port. Cuda only.