-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sulabh Kumra
committed
Jun 8, 2020
1 parent
3c75ebf
commit c2db619
Showing
6 changed files
with
43 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import logging | ||
|
||
import torch | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
|
||
|
||
def get_device(force_cpu): | ||
# Check if CUDA can be used | ||
if torch.cuda.is_available() and not force_cpu: | ||
logging.info("CUDA detected. Running with GPU acceleration.") | ||
device = torch.device("cuda") | ||
elif force_cpu: | ||
logging.info("CUDA detected, but overriding with option '--cpu'. Running with only CPU.") | ||
device = torch.device("cpu") | ||
else: | ||
logging.info("CUDA is *NOT* detected. Running with only CPU.") | ||
device = torch.device("cpu") | ||
return device |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters