Hi, I’ve seen this covered on SO but there’s a lot of contradictory info so hoping a best practice exists among users here.
Background:
MacOs 12.4 on 2016 MacBook Pro (16Gb, 2.7GHz)
Clean install of Anaconda then installed PyTorch per Getting Started
conda create --prefix ./envs
conda install pytorch torchvision torchaudio -c pytorch
conda install ipython ipykernel
conda install matplotlib
Working in VSCode. Above python env activated/selected for notebooks
Was able to run all the .ipynb notebooks from “Introduction to PyTorch” tutorials
Issue:
Trying to run the notebook for What is torch.nn really? — PyTorch Tutorials 2.1.1+cu121 documentation
led to kernel crash with no meaningful error at:
import torch
x_train, y_train, x_valid, y_valid = map(
torch.tensor, (x_train, y_train, x_valid, y_valid)
)
n, c = x_train.shape
print(x_train, y_train)
print(x_train.shape)
print(y_train.min(), y_train.max())
Attempted:
Ran the commands from an ipython session and got this error:
OMP: Error #15: Initializing libiomp5.dylib, but found libomp.dylib already initialized.
OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see http://www.intel.com/software/products/support/.
I saw proposed solution to use:
conda install nomkl
I gave this a shot but it failed with conflicts in my environment so looking to see if this is the right track.