Skip to content

Commit

Permalink
Add workaround for pytorch device selection issue (#711)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexAUT authored Feb 6, 2025
1 parent e0635db commit eb7e015
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/perf-kernels/streamk/tune_streamk.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ def profile_batch_kernels(M, N, K, gpuid, gpus, jobs, verbose):
if gpuIdx + 1 > jobs:
return
os.environ['ROCR_VISIBLE_DEVICES'] = str(gpuid)
# ROCR_VISIBLE_DEVICES is not parsed correctly by all pytorch versions which produces an out of bounds access
# To workaround this issue force it to use the first HIP_VISIBLE_DEVICE which is the one we select with ROCR_VISIBLE_DEVICES
# https://github.com/pytorch/pytorch/issues/140318 we need to keep this even after the fix is merged because we might use older pytorch versions
os.environ['HIP_VISIBLE_DEVICES'] = '0'
jobId = gpuIdx
while jobId < jobs:
kernelname = get_filename_profile_driver(M, N, K, jobId)
Expand Down
4 changes: 4 additions & 0 deletions python/perf-kernels/tools/tune_gemm/tune_gemm.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ def profile_batch_kernels(M, N, K, gpuid, gpus, jobs, verbose):
if gpuIdx + 1 > jobs:
return
os.environ['ROCR_VISIBLE_DEVICES'] = str(gpuid)
# ROCR_VISIBLE_DEVICES is not parsed correctly by all pytorch versions which produces an out of bounds access
# To workaround this issue force it to use the first HIP_VISIBLE_DEVICE which is the one we select with ROCR_VISIBLE_DEVICES
# https://github.com/pytorch/pytorch/issues/140318 we need to keep this even after the fix is merged because we might use older pytorch versions
os.environ['HIP_VISIBLE_DEVICES'] = '0'
jobId = gpuIdx
while jobId < jobs:
kernel_name = get_filename_profile_driver(M, N, K, jobId)
Expand Down

0 comments on commit eb7e015

Please sign in to comment.