what does os.environ['KMP_DUPLICATE_LIB_OK'] actually do?
I faced some issue while trying to use pytorch on jupyter (module not found). I used pip install but my kernel kept failing.
However after adding the following code within my jupyter notebook, I managed to use pytorch without issue.
However, may I know what does this code do? Especially KMP_DUPLICATE_LIB_OK.
Thank you!


It sets the environment variable KMP_DUPLICATE_LIB_OK to True. This is the same thing that happens if you run export KMP_DUPLICATE_LIB_OK=True on the command line (depending on which shell you are using).
Environment variables are a kind of &quot;ambient&quot; input to programs that can be used to hold general information about the environment where the program is running - hence the name - such as the current username, home directory, and PATH. (Many of these are redundant, only kept for historical reasons, and it's a pain when they get out of sync with the actual data)
Since they are &quot;ambient&quot; - they are available from anywhere in any child process - they can also be a convenient way to enable various hacks and workarounds such as LD_PRELOAD.
Apparently (and I found no good source for this) the specific variable KMP_DUPLICATE_LIB_OK=True tells OpenMP to not complain if it notices that two copies of OpenMP are loaded. This doesn't necessarily mean it will work, but it does mean it won't stop you from trying to make it work.
