mirror of https://github.com/hpcaitech/ColossalAI
Allow building cuda extension without a device. (#5535)
Added FORCE_CUDA environment variable support, to enable building extensions where a GPU device is not present but cuda libraries are.pull/5787/head
parent
3f7e3131d9
commit
c46e09715c
|
@ -28,7 +28,9 @@ class _CudaExtension(_CppExtension):
|
||||||
try:
|
try:
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
cuda_available = torch.cuda.is_available()
|
# torch.cuda.is_available requires a device to exist, allow building with cuda extension on build nodes without a device
|
||||||
|
# but where cuda is actually available.
|
||||||
|
cuda_available = torch.cuda.is_available() or bool(os.environ.get('FORCE_CUDA', 0))
|
||||||
except:
|
except:
|
||||||
cuda_available = False
|
cuda_available = False
|
||||||
return cuda_available
|
return cuda_available
|
||||||
|
|
Loading…
Reference in New Issue