Skip to content

Commit 5c0f188

Browse files
author
Hanbin Hu
committedApr 28, 2021
Add better trigger for have_cuda in setup.py
1 parent 303b47a commit 5c0f188

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed
 

‎setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ def build_nvcc_extra_objects(nvcc_cmd: str, cxx11_abi: bool) -> List[str]:
452452
# cuda_kernels.o -lcudart
453453
nvcc_flags = f'-fPIC -D_GLIBCXX_USE_CXX11_ABI={int(cxx11_abi)}'
454454

455-
extra_object_dir = 'bluefog/common/cuda/'
455+
extra_object_dir = os.path.join(os.path.dirname(__file__), 'bluefog/common/cuda/')
456456
source = extra_object_dir+'cuda_kernels.cu'
457457
object_file = extra_object_dir+'cuda_kernels.o'
458458
object_link = extra_object_dir+'cuda_kernels_link.o'
@@ -478,6 +478,7 @@ def build_torch_extension(build_ext, global_options, torch_version):
478478
options = copy.deepcopy(global_options)
479479
have_cuda = is_torch_cuda(build_ext, include_dirs=options['INCLUDES'],
480480
extra_compile_args=options['COMPILE_FLAGS'])
481+
have_cuda = have_cuda and torch.cuda.is_available()
481482
if have_cuda:
482483
cuda_include_dirs, cuda_lib_dirs = get_cuda_dirs(
483484
build_ext, options['COMPILE_FLAGS'])

0 commit comments

Comments
 (0)
Please sign in to comment.