-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #311 from hym97/cuda_device_selection
Cuda Device Selection
- Loading branch information
Showing
6 changed files
with
87 additions
and
15 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,26 @@ | ||
from totalsegmentator.bin.TotalSegmentator import validate_device_type | ||
import unittest | ||
import argparse | ||
class TestValidateDeviceType(unittest.TestCase): | ||
def test_valid_inputs(self): | ||
self.assertEqual(validate_device_type("gpu"), "gpu") | ||
self.assertEqual(validate_device_type("cpu"), "cpu") | ||
self.assertEqual(validate_device_type("mps"), "mps") | ||
self.assertEqual(validate_device_type("gpu:0"), "cuda:0") | ||
self.assertEqual(validate_device_type("gpu:1"), "cuda:1") | ||
|
||
def test_invalid_inputs(self): | ||
with self.assertRaises(argparse.ArgumentTypeError): | ||
validate_device_type("invalid") | ||
with self.assertRaises(argparse.ArgumentTypeError): | ||
validate_device_type("gpu:invalid") | ||
with self.assertRaises(argparse.ArgumentTypeError): | ||
validate_device_type("gpu:-1") | ||
with self.assertRaises(argparse.ArgumentTypeError): | ||
validate_device_type("gpu:3.1415926") | ||
with self.assertRaises(argparse.ArgumentTypeError): | ||
validate_device_type("gpu:") | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
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