Skip to content

Commit 718e401

Browse files
authored
Update setup.py (#360)
Check if environment variable is set before retrieving variable at setup time.
1 parent 6de4a2e commit 718e401

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

setup.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99

1010

1111
# If WITH_CUDA is defined
12-
if os.environ.get("WITH_CUDA", "0") == "1":
13-
use_cuda = True
14-
elif os.environ.get("WITH_CUDA", "0") == "0":
15-
use_cuda = False
12+
if os.getenv("WITH_CUDA") is None:
13+
if os.environ.get("WITH_CUDA", "0") == "1":
14+
use_cuda = True
15+
elif os.environ.get("WITH_CUDA", "0") == "0":
16+
use_cuda = False
17+
else:
18+
raise ValueError("Invalid flag with WITH_CUDA environment variable. Expected '0' or '1'")
1619
else:
1720
use_cuda = torch.cuda._is_compiled()
1821

0 commit comments

Comments
 (0)