Skip to content

Commit eb7e015

Browse files
authored
Add workaround for pytorch device selection issue (#711)
1 parent e0635db commit eb7e015

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

python/perf-kernels/streamk/tune_streamk.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ def profile_batch_kernels(M, N, K, gpuid, gpus, jobs, verbose):
203203
if gpuIdx + 1 > jobs:
204204
return
205205
os.environ['ROCR_VISIBLE_DEVICES'] = str(gpuid)
206+
# ROCR_VISIBLE_DEVICES is not parsed correctly by all pytorch versions which produces an out of bounds access
207+
# To workaround this issue force it to use the first HIP_VISIBLE_DEVICE which is the one we select with ROCR_VISIBLE_DEVICES
208+
# 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
209+
os.environ['HIP_VISIBLE_DEVICES'] = '0'
206210
jobId = gpuIdx
207211
while jobId < jobs:
208212
kernelname = get_filename_profile_driver(M, N, K, jobId)

python/perf-kernels/tools/tune_gemm/tune_gemm.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ def profile_batch_kernels(M, N, K, gpuid, gpus, jobs, verbose):
193193
if gpuIdx + 1 > jobs:
194194
return
195195
os.environ['ROCR_VISIBLE_DEVICES'] = str(gpuid)
196+
# ROCR_VISIBLE_DEVICES is not parsed correctly by all pytorch versions which produces an out of bounds access
197+
# To workaround this issue force it to use the first HIP_VISIBLE_DEVICE which is the one we select with ROCR_VISIBLE_DEVICES
198+
# 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
199+
os.environ['HIP_VISIBLE_DEVICES'] = '0'
196200
jobId = gpuIdx
197201
while jobId < jobs:
198202
kernel_name = get_filename_profile_driver(M, N, K, jobId)

0 commit comments

Comments
 (0)