Fix cuda detection script (#22527)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/22507
Pull Request resolved: https://github.com/pytorch/pytorch/pull/22527
Differential Revision: D16126220
Pulled By: ezyang
fbshipit-source-id: eb05141282b0f058324da1b3d3cb34566f222a67