Skip to content

Commit

Permalink
Use tempfile in cuML benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
jakirkham committed Jul 26, 2023
1 parent 519f8fb commit 2e8c03b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions python/cuml/benchmark/nvtx_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,22 @@

import os
import sys
import tempfile
from subprocess import run
import json


class Profiler:
def __init__(self, tmp_path="/tmp/nsys_report"):
self.nsys_file = tmp_path + "/report.nsys-rep"
self.json_file = tmp_path + "/report.json"
self._execute(["rm", "-rf", tmp_path])
self._execute(["mkdir", "-p", tmp_path])
def __init__(self, tmp_path=None):
self.tmp_dir = tempfile.TemporaryDirectory(dir=tmp_path)
self.nsys_file = os.path.join(self.tmp_dir.name, "report.nsys-rep")
self.json_file = os.path.join(self.tmp_dir.name, "report.json")
self._execute(["rm", "-rf", self.tmp_dir.name])
self._execute(["mkdir", "-p", self.tmp_dir.name])

def __del__(self):
self.tmp_dir.cleanup()
self.tmp_dir = None

@staticmethod
def _execute(command):
Expand Down

0 comments on commit 2e8c03b

Please sign in to comment.