导入pytorch时出现ImportError

ImportError when importing pytorch

当我尝试在 jupyter notebook 中导入 pytorch 时出现以下错误:

ImportError: dlopen: cannot load any more object with static TLS pytorch

import torch

从命令行(不是 jupyter notebook)导入 torch 时没有错误

由于我还无法解释的原因,我发现只有当我在同一个虚拟环境中安装 Keras 时才会发生这种情况,而当我卸载 Keras 时它就会消失。

所以解决方案是

pip uninstall keras