mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-06-18 11:48:53 +00:00
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.
This commit is contained in:
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
Block a user