-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for --gpus options in Rocker (shm merged separately) #304
Open
SamratThapa120
wants to merge
5
commits into
osrf:main
Choose a base branch
from
SamratThapa120:feat/shm_gpus
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -617,3 +617,73 @@ def test_group_add_extension(self): | |
args = p.get_docker_args(mock_cliargs) | ||
self.assertIn('--group-add sudo', args) | ||
self.assertIn('--group-add docker', args) | ||
|
||
class ShmSizeExtensionTest(unittest.TestCase): | ||
|
||
def setUp(self): | ||
# Work around interference between empy Interpreter | ||
# stdout proxy and test runner. empy installs a proxy on stdout | ||
# to be able to capture the information. | ||
# And the test runner creates a new stdout object for each test. | ||
# This breaks empy as it assumes that the proxy has persistent | ||
# between instances of the Interpreter class | ||
# empy will error with the exception | ||
# "em.Error: interpreter stdout proxy lost" | ||
em.Interpreter._wasProxyInstalled = False | ||
|
||
@pytest.mark.docker | ||
def test_shm_size_extension(self): | ||
plugins = list_plugins() | ||
shm_size_plugin = plugins['shm_size'] | ||
self.assertEqual(shm_size_plugin.get_name(), 'shm_size') | ||
|
||
p = shm_size_plugin() | ||
self.assertTrue(plugin_load_parser_correctly(shm_size_plugin)) | ||
|
||
mock_cliargs = {} | ||
self.assertEqual(p.get_snippet(mock_cliargs), '') | ||
self.assertEqual(p.get_preamble(mock_cliargs), '') | ||
args = p.get_docker_args(mock_cliargs) | ||
self.assertNotIn('--shm-size', args) | ||
|
||
mock_cliargs = {'shm_size': '12g'} | ||
args = p.get_docker_args(mock_cliargs) | ||
self.assertIn('--shm-size 12g', args) | ||
|
||
class GpusExtensionTest(unittest.TestCase): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would also go into the test_nvidia.py in parallel with moving the implementation |
||
|
||
def setUp(self): | ||
# Work around interference between empy Interpreter | ||
# stdout proxy and test runner. empy installs a proxy on stdout | ||
# to be able to capture the information. | ||
# And the test runner creates a new stdout object for each test. | ||
# This breaks empy as it assumes that the proxy has persistent | ||
# between instances of the Interpreter class | ||
# empy will error with the exception | ||
# "em.Error: interpreter stdout proxy lost" | ||
em.Interpreter._wasProxyInstalled = False | ||
|
||
@pytest.mark.docker | ||
def test_gpus_extension(self): | ||
plugins = list_plugins() | ||
gpus_plugin = plugins['gpus'] | ||
self.assertEqual(gpus_plugin.get_name(), 'gpus') | ||
|
||
p = gpus_plugin() | ||
self.assertTrue(plugin_load_parser_correctly(gpus_plugin)) | ||
|
||
# Test when no GPUs are specified | ||
mock_cliargs = {} | ||
self.assertEqual(p.get_snippet(mock_cliargs), '') | ||
self.assertEqual(p.get_preamble(mock_cliargs), '') | ||
args = p.get_docker_args(mock_cliargs) | ||
self.assertNotIn('--gpus', args) | ||
|
||
# Test when GPUs are specified | ||
mock_cliargs = {'gpus': 'all'} | ||
args = p.get_docker_args(mock_cliargs) | ||
self.assertIn('--gpus all', args) | ||
|
||
mock_cliargs = {'gpus': '0,1'} | ||
args = p.get_docker_args(mock_cliargs) | ||
self.assertIn('--gpus 0,1', args) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the cross coupling can you move this to the nvidia_extensions file instead? It's not explicitly nvidia but I'd like to keep them colocated. And that file could potentially be renamed in the future with it's expanded scope. The X11 class is already not nvidia tied.