This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MXNET-857] Add initial NVTX profiler implementation (#12328)
* [MXNET-857] Enable CUDA NVTX extensions for profiler These extensions mark readable ranges in the NVIDIA Visual Profiler which helps show correlations between kernel launches and graph node executions. Example shown here: https://user-images.githubusercontent.com/7443219/33946110-34296d18-e021-11e7-8d18-6d40b797405c.png The additional information enabled is in the 'Markers and Ranges' row. * [MXNET-857] Add initial NVTX profiler implementation This commit removes NVTX headers from the Amalgamation build process, but this is a CUDA/CMake only feature, so it's not relevant to Amalagamation builds. * [MXNET-857] Use macro for NVTX specific code * [MXNET-857] Add integration test. * Turn on NVTX by default in Unix. * Fixed typos and added NTVX info to profiler.md * Add NVTX example to profiling tutorial * Add NVTX flags for make
- Loading branch information
1 parent
4796851
commit b22ee95
Showing
15 changed files
with
277 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
set(NVTX_ROOT_DIR "" CACHE PATH "Folder contains NVIDIA NVTX") | ||
|
||
find_path(NVTX_INCLUDE_DIRS | ||
NAMES nvToolsExt.h | ||
PATHS $ENV{NVTOOLSEXT_PATH} ${NVTX_ROOT_DIR} ${CUDA_TOOLKIT_ROOT_DIR} | ||
PATH_SUFFIXES include | ||
) | ||
|
||
find_library(NVTX_LIBRARIES | ||
NAMES nvToolsExt64_1.lib nvToolsExt32_1.lib nvToolsExt | ||
PATHS $ENV{NVTOOLSEXT_PATH} ${NVTX_ROOT_DIR} ${CUDA_TOOLKIT_ROOT_DIR} | ||
PATH_SUFFIXES lib lib64 lib/Win32 lib/x64 | ||
) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(NVTX DEFAULT_MSG NVTX_INCLUDE_DIRS NVTX_LIBRARIES) | ||
|
||
if(NVTX_FOUND) | ||
message(STATUS "Found NVTX (include: ${NVTX_INCLUDE_DIRS}, library: ${NVTX_LIBRARIES})") | ||
mark_as_advanced(NVTX_ROOT_DIR NVTX_INCLUDE_DIRS NVTX_LIBRARIES) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
|
||
#include "nvtx.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
|
||
#ifndef MXNET_PROFILER_NVTX_H_ | ||
#define MXNET_PROFILER_NVTX_H_ | ||
|
||
#if MXNET_USE_NVTX | ||
|
||
#include <string> | ||
#include <unordered_map> | ||
#include "nvToolsExt.h" | ||
|
||
namespace mxnet { | ||
namespace profiler { | ||
namespace nvtx { | ||
|
||
class NVTXDuration { | ||
public: | ||
explicit NVTXDuration(const char *name) noexcept | ||
: range_id_(0), name_(name) {} | ||
|
||
inline void start() { | ||
range_id_ = nvtxRangeStartA(name_); | ||
} | ||
|
||
inline void stop() { | ||
nvtxRangeEnd(range_id_); | ||
} | ||
|
||
private: | ||
nvtxRangeId_t range_id_; | ||
const char *name_; | ||
}; | ||
|
||
|
||
|
||
} // namespace nvtx | ||
} // namespace profiler | ||
} // namespace mxnet | ||
|
||
#endif // MXNET_USE_NVTX | ||
#endif // MXNET_PROFILER_NVTX_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
import mxnet as mx | ||
from mxnet.gluon import nn | ||
|
||
|
||
def simple_forward(): | ||
ctx = mx.gpu() | ||
mx.profiler.set_config(profile_all=True) | ||
mx.profiler.set_state('run') | ||
|
||
# define simple gluon network with random weights | ||
net = nn.Sequential() | ||
with net.name_scope(): | ||
net.add(nn.Dense(128, activation='relu')) | ||
net.add(nn.Dense(64, activation='relu')) | ||
net.add(nn.Dense(10)) | ||
net.initialize(mx.init.Xavier(magnitude=2.24), ctx=ctx) | ||
|
||
input = mx.nd.zeros((128,), ctx=ctx) | ||
predictions = net(input) | ||
print('Ran simple NN forward, results:') | ||
print(predictions.asnumpy()) | ||
|
||
|
||
if __name__ == '__main__': | ||
simple_forward() |
Oops, something went wrong.