CUDAExtension in setup.py may fail with an environment where CUDA isn’t installed. What is the best practice to make CUDAExtension compatible with a non-CUDA environment?
Traceback (most recent call last):
  File "setup.py", line 23, in <module>
    'my_extension.cu',
  File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 476, in CUDAExtension
    library_dirs += library_paths(cuda=True)
  File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 555, in library_paths
    if (not os.path.exists(_join_cuda_home(lib_dir)) and
  File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1146, in _join_cuda_home
    raise EnvironmentError('CUDA_HOME environment variable is not set. '
OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root.