Search code examples
ubuntuzshintelintel-vtuneintel-oneapi

Intel OneAPI setvarsh.sh not set pernamently (Ubuntu)


I am struggling with the usage of intel OneAPI, specifically compiler (DPC++/C++) and Vtune Profiler.

I've installed everything successfully, used source setvarsh.sh in the installation directory and everything worked fine until I closed the shell.

It appears that after setting the environmental variables they only last in an active terminal session and do not stay with me permanently. Directly after using source setvars.sh I am able to use icx or vtune-gui command. After starting new session I get only command not found error.

Is it something wrong with the script or should I use a specific switch or something?

System info:
System: Ubuntu 22.04. LTS 64-bit
GNOME Version: 42.0
Shell: Zsh
Vtune Profiler: 2022.1.0.98
Intel Compiler: 2022.0.2.84

For now I've solved the problem partially by adding an alias in .zshrc to run the setvars.sh script using one command but that seems like a very non-elegant solution. I'd appreciate any hints. Thanks!


Solution

  • That is the expected behavior, source can only affect the current environment. There is no "nice" way to set the environment variables permanently from a script, you need to edit your config files.

    What you can do is to automatically setup the environment when starting a new zsh session. That can be done by adding source /opt/intel/oneapi/setvars.sh to your .zshrc.