Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29487 Discussions

How to select version in /opt/intel/oneapi/setvars.sh

caplanr
New Contributor II
542 Views

Hi,

 

I have two versions of the oneapi-hpc toolkits installed on my machine (the latest one and an older one for compatibility issues).

 

Is there a way to specify which version to load into my environment when I source `/opt/intel/oneapi/setvars.sh`?

 

Thanks

 

 -  Ron

0 Kudos
1 Solution
MarcGrodent
New Contributor II
478 Views

Yo can you the "--config=file" option to specify the compiler you want to use.

For instance, let's say there are two versions of the compiler installed on your machine:

    - /opt/intel/oneapi/compiler/2024.0

    - /opt/intel/oneapi/compiler/2025.3.2

By default, running "setvars.sh" will select the latest version installed (2025.3.2).

Now, you can create a configuration file, say ~/config_intel_compiler

In this file, add the following line:

  compiler=2024.0

 

Finally, run the script with the following command:

  source /opt/intel/oneapi/setvars.sh --config="~/config_intel_compiler"

And finally check your current compiler version:

  which ifx

You should see that the old version is active.

 

    

View solution in original post

0 Kudos
7 Replies
Steve_Lionel
Honored Contributor III
522 Views

You would need to select the desired one from its installation folder.

0 Kudos
caplanr
New Contributor II
507 Views

How?

 

I usually just source the script with:
`. /opt/intel/oneapi/setvars.sh`

How do I select the one I want?  

Is there optional arguments to the script?

 

 - Ron

0 Kudos
MarcGrodent
New Contributor II
479 Views

Yo can you the "--config=file" option to specify the compiler you want to use.

For instance, let's say there are two versions of the compiler installed on your machine:

    - /opt/intel/oneapi/compiler/2024.0

    - /opt/intel/oneapi/compiler/2025.3.2

By default, running "setvars.sh" will select the latest version installed (2025.3.2).

Now, you can create a configuration file, say ~/config_intel_compiler

In this file, add the following line:

  compiler=2024.0

 

Finally, run the script with the following command:

  source /opt/intel/oneapi/setvars.sh --config="~/config_intel_compiler"

And finally check your current compiler version:

  which ifx

You should see that the old version is active.

 

    

0 Kudos
MarcGrodent
New Contributor II
471 Views

In addition to my reply, you can force setvars to re-run if the Intel environment has already been configured. For instance:

  source /opt/intel/oneapi/setvars.sh --force --config="$HOME/config_intel_compiler"

Then check with:

   which ifx

or

   ifx --version

0 Kudos
caplanr
New Contributor II
425 Views

Hi,

 

Thanks for the help, but I can't seem to get it to work.

 

I have:


# ls /opt/intel/oneapi/compiler/ -la
total 16
drwxr-xr-x 4 root root 4096 Feb 5 11:46 .
drwxr-xr-x 27 root root 4096 Jan 29 15:31 ..
drwxr-xr-x 10 root root 4096 Nov 7 14:07 2025.2
drwxr-xr-x 10 root root 4096 Feb 5 11:45 2025.3
lrwxrwxrwx 1 root root 6 Feb 5 11:46 latest -> 2025.3

So I have both 2025.3 and 2025.2

 

I made a config file that looks like:

 

$ cat ~/config_intel_compiler_2502
compiler=2025.2

 

I then source with:

$ . /opt/intel/oneapi/setvars.sh --config="~/config_intel_compiler_2502"

 

But I am still on the newest compiler:

$ ifx -v
ifx version 2025.3.2

 

Am I missing something?

 

 - Ron

 

 

 

 

0 Kudos
MarcGrodent
New Contributor II
417 Views

This is strange, it works perfectly on my Ubuntu machine.

Is "setvars.sh" executed automatically when you log in (by means of a similar command in file ~/.bashrc for instance)? If this is the case, your command with the "--config" option is skipped. Can you try forcing the execution of the bash script?

$ . /opt/intel/oneapi/setvars.sh --force --config="~/config_intel_compiler_2502"

 

caplanr
New Contributor II
414 Views

Hi,

 

It works now.

 

I have a system "load" script and I had copied it to my home dir but forgot to use "./" when sourcing the local one.

 

Thanks! 

 

Problem solved!

0 Kudos
Reply