Skip to content

Commit 138a0b3

Browse files
committed
fix the CUDA VISIBLE DEVICES in celery queue
1 parent c673994 commit 138a0b3

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

jobqueues/celeryfiles/tasks.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ def execute_gpu_job(folder, runsh, sentinel, datadir, copyextensions, jobname=No
2828

2929
jobsh = os.path.join(folder, "job.sh")
3030
stdfile = os.path.join(folder, "celery.out")
31-
_createJobScript(
32-
jobsh, folder, runsh, worker_index, sentinel, datadir, copyextensions
33-
)
31+
_createJobScript(jobsh, folder, runsh, gpu_index, sentinel, datadir, copyextensions)
3432

3533
# Sleep for a short bit so that the OS can pick up on the new file before executing it
3634
time.sleep(0.2)
@@ -91,12 +89,6 @@ def _createJobScript(
9189
)
9290
f.write("\n")
9391
if deviceid is not None:
94-
visible_devices = os.environ.get("CUDA_VISIBLE_DEVICES", None)
95-
if visible_devices is not None:
96-
visible_devices = [int(d) for d in visible_devices.split(",")]
97-
if deviceid >= len(visible_devices):
98-
deviceid = deviceid % len(visible_devices)
99-
deviceid = visible_devices[deviceid]
10092
f.write(f"export CUDA_VISIBLE_DEVICES={deviceid}\n\n")
10193

10294
f.write(f"cd {os.path.abspath(workdir)}\n")

0 commit comments

Comments
 (0)