Run VTune Profiler in a Container
Install a Docker* image with
Intel® VTune™
and profile native or Java* applications running inside the same container or outside the container.
Profiler
Prerequisites
- Configure a Docker image:
- For the pre-installed Intel® oneAPI Base Toolkit includingVTune, you may pull an existing Docker image from the Docker Hub repository:Profilerhost> image=amr-registry.caas.intel.com/oneapi/oneapi:base-dev-ubuntu18.04 host> docker pull "$image"
- To enable profiling from the container and have all host processes visible from the container, run your Docker image with--pid=hostas follows:host> docker run --pid=host --cap-add=SYS_ADMIN --cap-add=SYS_PTRACE -it "$image"where theSYS_ADMINvalue adds a capability to run hardware event-based sampling analysis; theSYS_PTRACEvalue enables user-mode sampling analysis.
- To profile a target application running in the same container whereVTuneis installed, do the following:Profiler
- Copy your application to the running Docker container. For example:host> docker cp /home/samples/matrix.tar 98fec14f0c08:/var/localwhere98fec14f0c08is your container ID.
- Compile your target in the container, if required.
Install and Run
VTune
Profiler in a Container
VTune
in a Container Profiler
These steps are NOT required if you use a Docker image with pre-installed Intel oneAPI Base Toolkit.
- Install the command-line interface ofVTuneinside your Docker container.ProfilerMake sure to select the[2] Custom installation>[3] Change components to installand de-select components that are not required in the container environment:[3] Graphical user interfaceand[4] Platform Profiler.
- After installation, set up environment variables for theVTune. For example, forProfilerVTunein Intel oneAPI Base Toolkit:Profilercontainer> source /opt/intel/oneapi/vtune/version/env/vars.sh
Run Analysis for Your Container Target
Set up your analysis for a target running in the container, using the following supported target and analysis types:
Target Type
| Analysis Type
|
---|---|
|
|
To run an analysis, enter:
vtune -collect <
analysis_type
> [options
] -- [container_target
]For example:
container> vtune -collect hotspots -knob sampling-mode=hw -- /home/samples/matrix
Run Analysis for Your Host Target
Set up your analysis for a target running on the host, using the following supported target and analysis types:
Target Type
| Analysis Type
|
---|---|
|
|
To run an analysis, enter:
vtune -collect <
analysis_type
> [options
] -- [host_target
]For example:
container> vtune -collect hotspots -target-process java
Known Issues:
- Issue:Function-level analysis is not available by default.VTunemaps the samples to the binaries from user target app but it cannot resolve the functions because the binaries from the host are not available from the container.ProfilerSolution:Run the Docker container with the mounted host folder containing the binaries and specify a search directory as an argument to thevtunecommand.
- Issue:VTuneis run in the container by the root user while the app on the host is run by a non-root user. As a result, User-Mode Sampling Hotspots analysis fails to run with an error "ProfilerBoth target and VTune Profiler should be run by the same user".Solution:Make sure the same user runsVTunein the container and the target app outside the container.Profiler