[HIP] Add extra exception handling for non-ROCM builds#83009
[HIP] Add extra exception handling for non-ROCM builds#83009Gamrix wants to merge 4 commits intogh/gamrix/86/basefrom
Conversation
I got the following error on OSX, which doesn't have HIP.
As this file is supposed to compile with non-HIP builds,
I added this error to the errors to ignore.
```
Traceback (most recent call last):
File "test/test_profiler.py", line 31, in <module>
from torch.profiler._pattern_matcher import (Pattern, NamePattern,
File "/Users/jclow/pytorch3/torch/profiler/_pattern_matcher.py", line 9, in <module>
import torch.utils.benchmark as benchmark
File "/Users/jclow/pytorch3/torch/utils/benchmark/__init__.py", line 2, in <module>
from torch.utils.benchmark.utils.timer import * # noqa: F403
File "/Users/jclow/pytorch3/torch/utils/benchmark/utils/timer.py", line 8, in <module>
from torch.utils.benchmark.utils import common, cpp_jit
File "/Users/jclow/pytorch3/torch/utils/benchmark/utils/cpp_jit.py", line 13, in <module>
from torch.utils import cpp_extension
File "/Users/jclow/pytorch3/torch/utils/cpp_extension.py", line 19, in <module>
from .hipify import hipify_python
File "/Users/jclow/pytorch3/torch/utils/hipify/hipify_python.py", line 34, in <module>
from .cuda_to_hip_mappings import CUDA_TO_HIP_MAPPINGS
File "/Users/jclow/pytorch3/torch/utils/hipify/cuda_to_hip_mappings.py", line 34, in <module>
rocm_path = subprocess.check_output(["hipconfig", "--rocmpath"]).decode("utf-8")
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 415, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 493, in run
with Popen(*popenargs, **kwargs) as process:
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 1706, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: 'hipconfig'
```
[ghstack-poisoned]
🔗 Helpful links
✅ No Failures (0 Pending)As of commit ce3ff23 (more details on the Dr. CI page): Expand to see more💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Please report bugs/suggestions to the (internal) Dr. CI Users group. |
I got the following error on OSX, which doesn't have HIP.
As this file is supposed to compile with non-HIP builds,
I added this error to the errors to ignore.
```
Traceback (most recent call last):
File "test/test_profiler.py", line 31, in <module>
from torch.profiler._pattern_matcher import (Pattern, NamePattern,
File "/Users/jclow/pytorch3/torch/profiler/_pattern_matcher.py", line 9, in <module>
import torch.utils.benchmark as benchmark
File "/Users/jclow/pytorch3/torch/utils/benchmark/__init__.py", line 2, in <module>
from torch.utils.benchmark.utils.timer import * # noqa: F403
File "/Users/jclow/pytorch3/torch/utils/benchmark/utils/timer.py", line 8, in <module>
from torch.utils.benchmark.utils import common, cpp_jit
File "/Users/jclow/pytorch3/torch/utils/benchmark/utils/cpp_jit.py", line 13, in <module>
from torch.utils import cpp_extension
File "/Users/jclow/pytorch3/torch/utils/cpp_extension.py", line 19, in <module>
from .hipify import hipify_python
File "/Users/jclow/pytorch3/torch/utils/hipify/hipify_python.py", line 34, in <module>
from .cuda_to_hip_mappings import CUDA_TO_HIP_MAPPINGS
File "/Users/jclow/pytorch3/torch/utils/hipify/cuda_to_hip_mappings.py", line 34, in <module>
rocm_path = subprocess.check_output(["hipconfig", "--rocmpath"]).decode("utf-8")
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 415, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 493, in run
with Popen(*popenargs, **kwargs) as process:
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 1706, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: 'hipconfig'
```
ghstack-source-id: 58eedd3
Pull Request resolved: #83009
I got the following error on OSX, which doesn't have HIP.
As this file is supposed to compile with non-HIP builds,
I added this error to the errors to ignore.
```
Traceback (most recent call last):
File "test/test_profiler.py", line 31, in <module>
from torch.profiler._pattern_matcher import (Pattern, NamePattern,
File "/Users/jclow/pytorch3/torch/profiler/_pattern_matcher.py", line 9, in <module>
import torch.utils.benchmark as benchmark
File "/Users/jclow/pytorch3/torch/utils/benchmark/__init__.py", line 2, in <module>
from torch.utils.benchmark.utils.timer import * # noqa: F403
File "/Users/jclow/pytorch3/torch/utils/benchmark/utils/timer.py", line 8, in <module>
from torch.utils.benchmark.utils import common, cpp_jit
File "/Users/jclow/pytorch3/torch/utils/benchmark/utils/cpp_jit.py", line 13, in <module>
from torch.utils import cpp_extension
File "/Users/jclow/pytorch3/torch/utils/cpp_extension.py", line 19, in <module>
from .hipify import hipify_python
File "/Users/jclow/pytorch3/torch/utils/hipify/hipify_python.py", line 34, in <module>
from .cuda_to_hip_mappings import CUDA_TO_HIP_MAPPINGS
File "/Users/jclow/pytorch3/torch/utils/hipify/cuda_to_hip_mappings.py", line 34, in <module>
rocm_path = subprocess.check_output(["hipconfig", "--rocmpath"]).decode("utf-8")
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 415, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 493, in run
with Popen(*popenargs, **kwargs) as process:
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 1706, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: 'hipconfig'
```
[ghstack-poisoned]
I got the following error on OSX, which doesn't have HIP.
As this file is supposed to compile with non-HIP builds,
I added this error to the errors to ignore.
```
Traceback (most recent call last):
File "test/test_profiler.py", line 31, in <module>
from torch.profiler._pattern_matcher import (Pattern, NamePattern,
File "/Users/jclow/pytorch3/torch/profiler/_pattern_matcher.py", line 9, in <module>
import torch.utils.benchmark as benchmark
File "/Users/jclow/pytorch3/torch/utils/benchmark/__init__.py", line 2, in <module>
from torch.utils.benchmark.utils.timer import * # noqa: F403
File "/Users/jclow/pytorch3/torch/utils/benchmark/utils/timer.py", line 8, in <module>
from torch.utils.benchmark.utils import common, cpp_jit
File "/Users/jclow/pytorch3/torch/utils/benchmark/utils/cpp_jit.py", line 13, in <module>
from torch.utils import cpp_extension
File "/Users/jclow/pytorch3/torch/utils/cpp_extension.py", line 19, in <module>
from .hipify import hipify_python
File "/Users/jclow/pytorch3/torch/utils/hipify/hipify_python.py", line 34, in <module>
from .cuda_to_hip_mappings import CUDA_TO_HIP_MAPPINGS
File "/Users/jclow/pytorch3/torch/utils/hipify/cuda_to_hip_mappings.py", line 34, in <module>
rocm_path = subprocess.check_output(["hipconfig", "--rocmpath"]).decode("utf-8")
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 415, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 493, in run
with Popen(*popenargs, **kwargs) as process:
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 1706, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: 'hipconfig'
```
ghstack-source-id: f473615
Pull Request resolved: #83009
malfet
left a comment
There was a problem hiding this comment.
Looks good to me, but why we even running this one on MacOS?
|
The thing that I find most suspect is the topline import of I don't see any need for that module to be imported by default, and I think people are just being not mindful about what they import. The change was introduced in #35897 . @ezyang , as the reviewer of that diff, do you know of any reason why we should have HIP import be a top level import for this file? |
|
If you want to hide it behind actual use when we notice we're compiling a hipify that's fine. But imports are supposed to be fine at the top level unless they result in an import cycle. |
|
Since this subprocess call is only triggered when one imports |
|
Seems like the best solution should be to not do the call to check if HIP is available in the module scope, and instead call it when used and cache the result. |
|
@pytorchmergebot merge |
|
@pytorchbot successfully started a merge job. Check the current status here. |
|
Merge failed due to This PR is too stale; the last push date was more than 3 days ago. Please rebase and try again. |
I got the following error on OSX, which doesn't have HIP.
As this file is supposed to compile with non-HIP builds,
I added this error to the errors to ignore.
```
Traceback (most recent call last):
File "test/test_profiler.py", line 31, in <module>
from torch.profiler._pattern_matcher import (Pattern, NamePattern,
File "/Users/jclow/pytorch3/torch/profiler/_pattern_matcher.py", line 9, in <module>
import torch.utils.benchmark as benchmark
File "/Users/jclow/pytorch3/torch/utils/benchmark/__init__.py", line 2, in <module>
from torch.utils.benchmark.utils.timer import * # noqa: F403
File "/Users/jclow/pytorch3/torch/utils/benchmark/utils/timer.py", line 8, in <module>
from torch.utils.benchmark.utils import common, cpp_jit
File "/Users/jclow/pytorch3/torch/utils/benchmark/utils/cpp_jit.py", line 13, in <module>
from torch.utils import cpp_extension
File "/Users/jclow/pytorch3/torch/utils/cpp_extension.py", line 19, in <module>
from .hipify import hipify_python
File "/Users/jclow/pytorch3/torch/utils/hipify/hipify_python.py", line 34, in <module>
from .cuda_to_hip_mappings import CUDA_TO_HIP_MAPPINGS
File "/Users/jclow/pytorch3/torch/utils/hipify/cuda_to_hip_mappings.py", line 34, in <module>
rocm_path = subprocess.check_output(["hipconfig", "--rocmpath"]).decode("utf-8")
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 415, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 493, in run
with Popen(*popenargs, **kwargs) as process:
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 1706, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: 'hipconfig'
```
[ghstack-poisoned]
I got the following error on OSX, which doesn't have HIP.
As this file is supposed to compile with non-HIP builds,
I added this error to the errors to ignore.
```
Traceback (most recent call last):
File "test/test_profiler.py", line 31, in <module>
from torch.profiler._pattern_matcher import (Pattern, NamePattern,
File "/Users/jclow/pytorch3/torch/profiler/_pattern_matcher.py", line 9, in <module>
import torch.utils.benchmark as benchmark
File "/Users/jclow/pytorch3/torch/utils/benchmark/__init__.py", line 2, in <module>
from torch.utils.benchmark.utils.timer import * # noqa: F403
File "/Users/jclow/pytorch3/torch/utils/benchmark/utils/timer.py", line 8, in <module>
from torch.utils.benchmark.utils import common, cpp_jit
File "/Users/jclow/pytorch3/torch/utils/benchmark/utils/cpp_jit.py", line 13, in <module>
from torch.utils import cpp_extension
File "/Users/jclow/pytorch3/torch/utils/cpp_extension.py", line 19, in <module>
from .hipify import hipify_python
File "/Users/jclow/pytorch3/torch/utils/hipify/hipify_python.py", line 34, in <module>
from .cuda_to_hip_mappings import CUDA_TO_HIP_MAPPINGS
File "/Users/jclow/pytorch3/torch/utils/hipify/cuda_to_hip_mappings.py", line 34, in <module>
rocm_path = subprocess.check_output(["hipconfig", "--rocmpath"]).decode("utf-8")
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 415, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 493, in run
with Popen(*popenargs, **kwargs) as process:
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 1706, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: 'hipconfig'
```
ghstack-source-id: 6f79e7f
Pull Request resolved: #83009
|
[Windows tests are failing due to unrelated changes https://github.com//issues/83433 ] |
I got the following error on OSX, which doesn't have HIP.
As this file is supposed to compile with non-HIP builds,
I added this error to the errors to ignore.
```
Traceback (most recent call last):
File "test/test_profiler.py", line 31, in <module>
from torch.profiler._pattern_matcher import (Pattern, NamePattern,
File "/Users/jclow/pytorch3/torch/profiler/_pattern_matcher.py", line 9, in <module>
import torch.utils.benchmark as benchmark
File "/Users/jclow/pytorch3/torch/utils/benchmark/__init__.py", line 2, in <module>
from torch.utils.benchmark.utils.timer import * # noqa: F403
File "/Users/jclow/pytorch3/torch/utils/benchmark/utils/timer.py", line 8, in <module>
from torch.utils.benchmark.utils import common, cpp_jit
File "/Users/jclow/pytorch3/torch/utils/benchmark/utils/cpp_jit.py", line 13, in <module>
from torch.utils import cpp_extension
File "/Users/jclow/pytorch3/torch/utils/cpp_extension.py", line 19, in <module>
from .hipify import hipify_python
File "/Users/jclow/pytorch3/torch/utils/hipify/hipify_python.py", line 34, in <module>
from .cuda_to_hip_mappings import CUDA_TO_HIP_MAPPINGS
File "/Users/jclow/pytorch3/torch/utils/hipify/cuda_to_hip_mappings.py", line 34, in <module>
rocm_path = subprocess.check_output(["hipconfig", "--rocmpath"]).decode("utf-8")
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 415, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 493, in run
with Popen(*popenargs, **kwargs) as process:
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 1706, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: 'hipconfig'
```
[ghstack-poisoned]
I got the following error on OSX, which doesn't have HIP.
As this file is supposed to compile with non-HIP builds,
I added this error to the errors to ignore.
```
Traceback (most recent call last):
File "test/test_profiler.py", line 31, in <module>
from torch.profiler._pattern_matcher import (Pattern, NamePattern,
File "/Users/jclow/pytorch3/torch/profiler/_pattern_matcher.py", line 9, in <module>
import torch.utils.benchmark as benchmark
File "/Users/jclow/pytorch3/torch/utils/benchmark/__init__.py", line 2, in <module>
from torch.utils.benchmark.utils.timer import * # noqa: F403
File "/Users/jclow/pytorch3/torch/utils/benchmark/utils/timer.py", line 8, in <module>
from torch.utils.benchmark.utils import common, cpp_jit
File "/Users/jclow/pytorch3/torch/utils/benchmark/utils/cpp_jit.py", line 13, in <module>
from torch.utils import cpp_extension
File "/Users/jclow/pytorch3/torch/utils/cpp_extension.py", line 19, in <module>
from .hipify import hipify_python
File "/Users/jclow/pytorch3/torch/utils/hipify/hipify_python.py", line 34, in <module>
from .cuda_to_hip_mappings import CUDA_TO_HIP_MAPPINGS
File "/Users/jclow/pytorch3/torch/utils/hipify/cuda_to_hip_mappings.py", line 34, in <module>
rocm_path = subprocess.check_output(["hipconfig", "--rocmpath"]).decode("utf-8")
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 415, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 493, in run
with Popen(*popenargs, **kwargs) as process:
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 1706, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: 'hipconfig'
```
ghstack-source-id: 86da32e
Pull Request resolved: #83009
|
@pytorchmergebot merge |
|
@pytorchbot successfully started a merge job. Check the current status here. |
|
Merge failed |
|
@Gamrix has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
|
@pytorchmergebot merge |
|
@pytorchbot successfully started a merge job. Check the current status here. |
|
Merge failed |
|
@pytorchbot merge |
|
@pytorchbot successfully started a merge job. Check the current status here. |
|
Hey @Gamrix. |
Summary:
I got the following error on OSX, which doesn't have HIP.
As this file is supposed to compile with non-HIP builds,
I added this error to the errors to ignore.
```
Traceback (most recent call last):
File "test/test_profiler.py", line 31, in <module>
from torch.profiler._pattern_matcher import (Pattern, NamePattern,
File "/Users/jclow/pytorch3/torch/profiler/_pattern_matcher.py", line 9, in <module>
import torch.utils.benchmark as benchmark
File "/Users/jclow/pytorch3/torch/utils/benchmark/__init__.py", line 2, in <module>
from torch.utils.benchmark.utils.timer import * # noqa: F403
File "/Users/jclow/pytorch3/torch/utils/benchmark/utils/timer.py", line 8, in <module>
from torch.utils.benchmark.utils import common, cpp_jit
File "/Users/jclow/pytorch3/torch/utils/benchmark/utils/cpp_jit.py", line 13, in <module>
from torch.utils import cpp_extension
File "/Users/jclow/pytorch3/torch/utils/cpp_extension.py", line 19, in <module>
from .hipify import hipify_python
File "/Users/jclow/pytorch3/torch/utils/hipify/hipify_python.py", line 34, in <module>
from .cuda_to_hip_mappings import CUDA_TO_HIP_MAPPINGS
File "/Users/jclow/pytorch3/torch/utils/hipify/cuda_to_hip_mappings.py", line 34, in <module>
rocm_path = subprocess.check_output(["hipconfig", "--rocmpath"]).decode("utf-8")
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 415, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 493, in run
with Popen(*popenargs, **kwargs) as process:
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Users/jclow/opt/anaconda3/envs/pytorch3/lib/python3.8/subprocess.py", line 1706, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: 'hipconfig'
```
Pull Request resolved: #83009
Approved by: https://github.com/malfet
Test Plan:
contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/30af17cea7e983b9e60354e05f7dcc2688183073
Original Phabricator Test Plan:
Imported from OSS
Reviewed By: atalman
Differential Revision: D38766067
Pulled By: Gamrix
fbshipit-source-id: 6fbda8d0939d2eb9113627350856340a05fa0222
| except subprocess.CalledProcessError: | ||
| print(f"Warning: hipconfig --rocmpath failed, assuming {rocm_path}") | ||
| except FileNotFoundError: | ||
| except (FileNotFoundError, PermissionError): |
There was a problem hiding this comment.
@Gamrix How this can change anything? PermissionError was already handled with pass in the next lines.
There was a problem hiding this comment.
Ugh, I think multiple people were fixing this at the same time. That line below was not there when I originally hit the error :/
Stack from ghstack:
I got the following error on OSX, which doesn't have HIP.
As this file is supposed to compile with non-HIP builds,
I added this error to the errors to ignore.
Differential Revision: D38766067