Reputation: 3
Recently, I want to run some pytorch codes on centos6. However, no matter I perform either "pip install torch" or "conda install torch", the prompt shows:
>>> import torch
Traceback (most recent call last):
File "", line 1, in
File "XXX/anaconda3/envs/XXX/lib/python3.6/site-packages/torch/init.py", line 56, in
from torch._C import *
ImportError: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by XXX/anaconda3/envs/XXX/lib/python3.6/site-packages/torch/_C.cpython-36m-x86_64-linux-gnu.so)
My enviroment:
OS: CentOS release 6.7
How you installed PyTorch (conda, pip, source): pip & conda
Python version: 3.6.5
I tried mannually compiling glibc-2.19, but when I put the library path into LD_LIBRARY_PATH, I can't use commands like "ls", "make", etc. And I got "segment fault". I also tried just copying the *.so to the lib directory under the python virtual environment, no wonder, python crashed with "segment fault". I understand plenty of components rely on a specific glibc library. I just wonder how I can run pytorch on centos6 without switching to a new linux distribution.
PS: I need to deploy such python environments on the product environment, whose OS is centos6.
Upvotes: 0
Views: 743
Reputation: 13626
It's a tough one. You can either downgrade to a very old version of torch ( v0.3.1 as I remember was running ok on Centos 6.5 ), or upgrade to Centos 7. Having 2 version of glibc is hell.
If you really need Centos 6 to live with the latest version of torch, try installing glibc into non standard location and compiling both Python and pytorch from source.
update
You can't replace system's glibc and but you can install it somewhere else, like /opt/myglibc
.
Pytorch stopped supporting Centos 6 since v0.4.1. So you will have to build it using gcc v5+ and linking it to your glibc version. Here are the instructions. But since you don't invoke pytorch directly, you need to build Python also. Then you can run your program by setting glibc path specifically for your program.
LD_LIBRARY_PATH=/opt/myglibc python my_program.py
Upvotes: 1