Merge pull request #889 from billhollings/master

Fix crash when more than two GPUs.