ImportError: OSError: .../libpyg.so: undefined symbol when I import pyg_lib

ImportError: OSError: .../lib/python3.9/site-packages/libpyg.so: undefined symbol: _ZNK5torch8autograd4Node4nameEv when I import pyg_lib

Dear community,
I have installed v1.12.0 of PyTorch from source in an Anaconda environment.

>>> import torch
>>> print(torch.__version__)
1.12.0a0+git67ece03
>>>
>>> print(torch.version.cuda)
11.3
>>> print(torch.cuda.is_available())
True
>>> print(torch.cuda.device_count())
2

Here is a partial list from conda list :

$ conda list | grep cud
cudatoolkit               11.6.2              hfc3e2af_12    conda-forge
cudnn                     8.3.2.44             hed8a83a_1    conda-forge

$ conda list | grep torch
# packages in environment at /home/whp/anaconda3/envs/pytorch_compile_pt112cp39:
torch                     1.12.0a0+git67ece03          pypi_0    pypi
torch-scatter             2.1.0+pt112cu116          pypi_0    pypi

When I import pyg_lib,the following error occurs:

>>> import pyg_lib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/myDir/lib/python3.9/site-packages/pyg_lib/__init__.py", line 39, in <module>
    load_library('libpyg')
  File "/myDir/lib/python3.9/site-packages/pyg_lib/__init__.py", line 36, in load_library
    torch.ops.load_library(spec.origin)
  File "/myDir/lib/python3.9/site-packages/torch/_ops.py", line 255, in load_library
    ctypes.CDLL(path)
  File "/myDir/lib/python3.9/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /myDir/lib/python3.9/site-packages/libpyg.so: undefined symbol: _ZNK5torch8autograd4Node4nameEv
>>>

When I import torch_scatter,the following error occurs:

>>> import torch_scatter
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/myDir/lib/python3.9/site-packages/torch_scatter/__init__.py", line 16, in <module>
    torch.ops.load_library(spec.origin)
  File "/myDir/lib/python3.9/site-packages/torch/_ops.py", line 255, in load_library
    ctypes.CDLL(path)
  File "/myDir/lib/python3.9/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /myDir/lib/python3.9/site-packages/torch_scatter/_version_cuda.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKSs
>>>

In another conda environment, I installed PyTorch through binaries:

conda install pytorch==1.12.0 torchvision==0.13.0 torchaudio==0.12.0 cudatoolkit=11.3 -c pytorch

and both packages can be referenced successfully.

What caused these errors?

Your PyG packages might be incompatible with the PyTorch version you have installed or did you check the version compatibility between these libs?

I installed the dependencies of PyG using the wheel.
Below are the versions of the dependencies.

$ ls
pyg_lib-0.3.1+pt112cu113-cp39-cp39-linux_x86_64.whl        
torch_scatter-2.1.0+pt112cu113-cp39-cp39-linux_x86_64.whl  
torch_spline_conv-1.2.1+pt112cu113-cp39-cp39-linux_x86_64.whl
torch_cluster-1.6.0+pt112cu113-cp39-cp39-linux_x86_64.whl  
torch_sparse-0.6.16+pt112cu113-cp39-cp39-linux_x86_64.whl

When I installed PyTorch through binaries:

conda install pytorch==1.12.0 torchvision==0.13.0 torchaudio==0.12.0 cudatoolkit=11.3 -c pytorch

These versions of the wheel can be installed and imported successfully.

Is it an issue with the open-source Torch version I downloaded?