Visible to Intel only — GUID: GUID-3DED6C3B-46DD-4189-9B4C-EB5E8408FD12
Visible to Intel only — GUID: GUID-3DED6C3B-46DD-4189-9B4C-EB5E8408FD12
Use the setvars Script with Linux* or MacOS*
Most of the component tool folders contain an environment script named vars.sh that configures the environment variables needed by that component to support oneAPI development work. For example, in a default installation, the Intel® Integrated Performance Primitives (Intel® IPP) vars script on Linux or macOS is located at: /opt/intel/ipp/latest/env/vars.sh. This pattern is shared by all oneAPI components that include an environment vars setup script.
These component tool vars scripts can be called directly or collectively. To call them collectively, a script named setvars.sh is provided in the oneAPI installation folder. For example, in a default installation on a Linux or macOS machine: /opt/intel/setvars.sh.
Sourcing the setvars.sh script without any arguments causes it to locate and source all <component>/latest/env/vars.sh scripts in the installation. Changes made to the environment by these scripts can be seen by running the env command after running the environment setup scripts.
Command Line Arguments
The setvars.sh script supports several command-line arguments, which are displayed using the --help option. For example:
source /opt/intel/oneapi/setvars.sh --help
The --config=file argument and the ability to include arguments that will be passed to the vars.sh scripts that are called by the setvars.sh script can be used to customize the environment setup.
The --config=file argument provides the ability to limit environment initialization to a specific set of oneAPI components. It also provides a way to initialize the environment for specific component versions. For example, to limit environment setup to just the Intel® IPP library and the Intel® oneAPI Math Kernel Library (Intel® oneMKL), pass a config file that tells the setvars.sh script to only call the vars.sh environment scripts for those two oneAPI components. More details and examples are provided in Use a Config file for setvars.sh on Linux or macOS.
Any extra arguments passed on the setvars.sh command line that are not described in the setvars.sh help message will be passed to every called vars.sh script. That is, if the setvars.sh script does not recognize an argument, it assumes the argument is meant for use by one or more component scripts and passes those extra arguments to every component vars.sh script that it calls. The most common extra arguments are ia32 and intel64, which are used by the Intel compilers and the IPP, MKL, and TBB libraries to specify the application target architecture.
Inspect the individual vars.sh scripts to determine which, if any, command line arguments they accept.
How to Run
source <install-dir>/setvars.sh
$ bash -c 'source <install-dir>/setvars.sh ; exec csh'
Alternatively, use the modulefiles scripts to set up your development environment. The modulefiles scripts work with all Linux shells.
If you wish to fine tune the list of components and the version of those components, use a setvars config file to set up your development environment.
How to Verify
After sourcing the setvars.sh script, verify success by searching for the SETVARS_COMPLETED environment variables. If setvars.sh was successful, then the SETVARS_COMPLETED environment variable will have a value of 1:
env | grep SETVARS_COMPLETED
Return value
SETVARS_COMPLETED=1
If the return value is anything other than SETVARS_COMPLETED=1, then the test failed and setvars.sh did not complete properly.
Multiple Runs
Because many of the individual env/vars.sh scripts make significant changes to PATH, CPATH, and other environment variables, the top-level setvars.sh script will not allow multiple invocations of itself in the same session. This is done to ensure that your environment variables do not become too long due to redundant path references, especially the $PATH environment variable.
This behavior can be overridden by passing setvars.sh the --force flag. In this example, the user tries to run setvars.sh twice. The second instance is stopped because setvars.sh has already been run.
> source <install-dir>/setvars.sh
.. code-block:: initializing environment ...
(SNIP: lot of output)
.. code-block:: oneAPI environment initialized ::
> source <install-dir>/setvars.sh
.. code-block:: WARNING: setvars.sh has already been run. Skipping re-execution.
To force a re-execution of setvars.sh, use the '--force' option.
Using '--force' can result in excessive use of your environment variables
In the third instance, the user runs setvars.sh --force and the initialization is successful.
> source <install-dir>/setvars.sh --force
.. code-block:: initializing environment ...
(SNIP: lot of output)
.. code-block:: oneAPI environment initialized ::
ONEAPI_ROOT Environment Variable
The ONEAPI_ROOT variable is set by the top-level setvars.sh script when that script is sourced. If there is already a ONEAPI_ROOT environment variable defined, setvars.sh temporarily overwrites it in the terminal session in which you sourced the setvars.sh script. This variable is primarily used by the oneapi-cli sample browser and the Eclipse* and Visual Studio Code* sample browsers to help them locate oneAPI tools and components, especially for in locating the setvars.sh script if the SETVARS_CONFIG feature has been enabled. For more information about the SETVARS_CONFIG feature, see Automate the setvars.sh Script with Eclipse*.
On Linux and macOS systems, the installer does not add the ONEAPI_ROOT variable to the environment. To add it to the default environment, define the variable in your local shell initialization file(s) or in the system’s /etc/environment file.