1717default_logger = logging .getLogger (__name__ )
1818
1919# Nsight options used when runtime_env={"_nsight": "default"}
20- NSIGHT_DEFAULT_CONFIG = {
21- "t" : "cuda,cudnn,cublas,nvtx" ,
22- "o" : "'worker_process_%p'" ,
23- "stop-on-exit" : "true" ,
24- }
25-
20+ # use default cnperf config, no need to specify any options
21+ NSIGHT_DEFAULT_CONFIG = {}
2622
2723def parse_nsight_config (nsight_config : Dict [str , str ]) -> List [str ]:
2824 """
@@ -32,7 +28,7 @@ def parse_nsight_config(nsight_config: Dict[str, str]) -> List[str]:
3228 The function returns:
3329 - List[str]: nsys profile cmd line split into list of str
3430 """
35- nsight_cmd = ["nsys " , "profile " ]
31+ nsight_cmd = ["cnperf-cli " , "record " ]
3632 for option , option_val in nsight_config .items ():
3733 # option standard based on
3834 # https://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html
@@ -68,10 +64,11 @@ async def _check_nsight_script(
6864
6965 # use empty as nsight report test filename
7066 nsight_config_copy = copy .deepcopy (nsight_config )
71- nsight_config_copy ["o" ] = str (Path (self ._nsight_dir ) / "empty" )
67+ try_to_create_directory (Path (self ._nsight_dir ) / "empty" )
68+ nsight_config_copy ["o" ] = str (Path (self ._nsight_dir ) / "empty/test" )
7269 nsight_cmd = parse_nsight_config (nsight_config_copy )
7370 try :
74- nsight_cmd = nsight_cmd + [sys . executable , "-c" , '""' ]
71+ nsight_cmd = nsight_cmd + ["python" , "-c" , '""' ]
7572 process = await asyncio .create_subprocess_exec (
7673 * nsight_cmd ,
7774 stdout = subprocess .PIPE ,
@@ -80,8 +77,8 @@ async def _check_nsight_script(
8077 stdout , stderr = await process .communicate ()
8178 error_msg = stderr .strip () if stderr .strip () != "" else stdout .strip ()
8279
83- # cleanup test.nsys -rep file
84- clean_up_cmd = ["rm" , f"{ nsight_config_copy ['o' ]} .nsys -rep" ]
80+ # cleanup test.cnperf -rep file
81+ clean_up_cmd = ["rm" , f"{ nsight_config_copy ['o' ]} .cnperf -rep" ]
8582 cleanup_process = await asyncio .create_subprocess_exec (
8683 * clean_up_cmd ,
8784 stdout = subprocess .PIPE ,
@@ -93,7 +90,7 @@ async def _check_nsight_script(
9390 else :
9491 return False , error_msg
9592 except FileNotFoundError :
96- return False , ("nsight is not installed" )
93+ return False , ("cnperf-cli is not installed" )
9794
9895 async def create (
9996 self ,
@@ -108,7 +105,7 @@ async def create(
108105
109106 if nsight_config and sys .platform != "linux" :
110107 raise RuntimeEnvSetupError (
111- "Nsight CLI is only available in Linux.\n "
108+ "CNPerf CLI is only available in Linux.\n "
112109 "More information can be found in "
113110 "https://docs.nvidia.com/nsight-compute/NsightComputeCli/index.html"
114111 )
@@ -120,21 +117,16 @@ async def create(
120117 raise RuntimeEnvSetupError (
121118 f"Unsupported nsight config: { nsight_config } . "
122119 "The supported config is 'default' or "
123- "Dictionary of nsight options"
120+ "Dictionary of cnperf options"
124121 )
125122
126123 is_valid_nsight_cmd , error_msg = await self ._check_nsight_script (nsight_config )
127124 if not is_valid_nsight_cmd :
128125 logger .warning (error_msg )
129126 raise RuntimeEnvSetupError (
130- "nsight profile failed to run with the following "
127+ "cnperf-cli failed to run with the following "
131128 f"error message:\n { error_msg } "
132129 )
133- # add set output path to logs dir
134- nsight_config ["o" ] = str (
135- Path (self ._nsight_dir ) / nsight_config .get ("o" , NSIGHT_DEFAULT_CONFIG ["o" ])
136- )
137-
138130 self .nsight_cmd = parse_nsight_config (nsight_config )
139131 return 0
140132
@@ -145,5 +137,5 @@ def modify_context(
145137 context : RuntimeEnvContext ,
146138 logger : Optional [logging .Logger ] = default_logger ,
147139 ):
148- logger .info ("Running nsight profiler" )
149140 context .py_executable = " " .join (self .nsight_cmd ) + " python"
141+ logger .info ("Running CNPerf cmd: %s" , context .py_executable )
0 commit comments