def test_cuda_driver_installed_failures(mocker): ''' Simple test for cuda_driver_installed failure scenarios ''' mocker.patch('subprocess.check_output', side_effect=OSError(errno.ENOENT, "")) with pytest.raises(OpenCEError) as exc: utils.cuda_driver_installed() assert "lsmod command not found" in str(exc.value) mocker.patch('subprocess.check_output', side_effect=OSError(errno.EPERM, "")) with pytest.raises(OpenCEError) as exc: utils.cuda_driver_installed() assert "lsmod command unexpectedly failed" in str(exc.value)
def test_cuda_driver_installed(mocker): ''' Simple test for cuda_driver_installed ''' mocker.patch('subprocess.check_output', return_value=bytes("nvidia 123", "utf-8")) assert utils.cuda_driver_installed() == True
def _capable_of_cuda_containers(cuda_versions): ''' Check if we can run containers with Cuda installed. This can be accomplished in two ways First if the host server does not have a driver installed Second, if the host driver is compatible with the level of cuda being used in the image ''' return not utils.cuda_driver_installed() or utils.cuda_level_supported(cuda_versions)