1

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!

Dr. Ske
  • 69
  • 6

1 Answers1

2

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.

aland
  • 4,829
  • 2
  • 24
  • 42
  • 2
    Traditionally, env vars only need to be set from your `.profile` or `.zsh_profile` (once per *login*, not when starting subshells like if you run `zsh` at the command line). But some desktop environments don't run each terminal window as a login shell, but also don't get env vars from your profile, so yes the easy way is to redo it in `.zshrc`, although that can lead to redundant `$PATH` entries if the script doesn't check for a path already being in `$PATH`. – Peter Cordes May 06 '22 at 04:38