Skip to content

Commit

Permalink
Update setup.py (#360)
Browse files Browse the repository at this point in the history
Check if environment variable is set before retrieving variable at setup time.
  • Loading branch information
szaman19 authored Feb 14, 2025
1 parent 6de4a2e commit 718e401
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@


# If WITH_CUDA is defined
if os.environ.get("WITH_CUDA", "0") == "1":
use_cuda = True
elif os.environ.get("WITH_CUDA", "0") == "0":
use_cuda = False
if os.getenv("WITH_CUDA") is None:
if os.environ.get("WITH_CUDA", "0") == "1":
use_cuda = True
elif os.environ.get("WITH_CUDA", "0") == "0":
use_cuda = False
else:
raise ValueError("Invalid flag with WITH_CUDA environment variable. Expected '0' or '1'")
else:
use_cuda = torch.cuda._is_compiled()

Expand Down

0 comments on commit 718e401

Please sign in to comment.