# Libtorch\_cpu.so: undefined symbol

**URL:** <https://discuss.pytorch.org/t/libtorch-cpu-so-undefined-symbol/201101>\
**Category:** Uncategorized\
**Created:** [April 17, 2024, 2:00pm UTC](https://discuss.pytorch.org/t/libtorch-cpu-so-undefined-symbol/201101 "2024-04-17T14:00:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Megidd](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/megidd/32/69332_2.png) [@Megidd](https://discuss.pytorch.org/u/Megidd)\
**Post date:** [April 17, 2024, 2:00pm UTC](https://discuss.pytorch.org/t/libtorch-cpu-so-undefined-symbol/201101/1 "2024-04-17T14:00:23Z")

</div>

# Minimal env

Even a minimal Environment like below would throw similar errors:

```bash
conda create -n minimal_pytorch python=3.6 pytorch torchvision torchaudio -c pytorch
source activate minimal_pytorch && python -c "import torch; print(torch. __version__ )"

```

A similar `undefined symbol` error is thrown:

```auto
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/envs/minimal_pytorch/lib/python3.6/site-packages/torch/ __init__.py", line 197, in <module>
    from torch._C import * # noqa: F403
ImportError: /usr/local/envs/minimal_pytorch/lib/python3.6/site-packages/torch/lib/libtorch_cpu.so: undefined symbol: iJIT_NotifyEvent

```

## Python version

When Python version is omitted while creating the environment:

```bash
conda create -n minimal_pytorch python pytorch torchvision torchaudio -c pytorch

```

The error is resolved:

```auto
source activate minimal_pytorch && python -c "import torch; print(torch. __version__ )"

```

PyTorch version is received without any error:

```auto
2.2.2

```

I’m kind of confused 🙄

Eventually, I guess I have to use a Docker container as suggested here:

> [@Undefined symbol pytorch 1.7.0 and above](https://discuss.pytorch.org/t/undefined-symbol-pytorch-1-7-0-and-above/126640/4):
>
> The only way I found to make it work is to use a docker container with the required PyTorch version in it.

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [April 18, 2024, 4:01am UTC](https://discuss.pytorch.org/t/libtorch-cpu-so-undefined-symbol/201101/2 "2024-04-18T04:01:36Z")

</div>

The PyTorch binaries are not built for Python 3.6 anymore, so the first command should install a `torch<=1.10.2` if I’m not mistaken.  
Use a newer Python version (3.8 - 3.12) and it should work.

---

<div class="post-metadata">

**Author:** ![yrraadi-io](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/yrraadi-io/32/69647_2.png) [@yrraadi-io](https://discuss.pytorch.org/u/yrraadi-io)\
**Post date:** [April 29, 2024, 4:12pm UTC](https://discuss.pytorch.org/t/libtorch-cpu-so-undefined-symbol/201101/3 "2024-04-29T16:12:58Z")

</div>

I’m facing this issue with python 3.9.\*, when installing pytorch via conda.

---

<div class="post-metadata">

**Author:** ![Megidd](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/megidd/32/69332_2.png) [@Megidd](https://discuss.pytorch.org/u/Megidd)\
**Post date:** [April 30, 2024, 6:36am UTC](https://discuss.pytorch.org/t/libtorch-cpu-so-undefined-symbol/201101/4 "2024-04-30T06:36:25Z")

</div>

Eventually, I solved the problem by resolving version mismatches. The exact commands are here:

> <https://github.com/conda/conda/issues/13812#issuecomment-2071445372>
>
> \### Checklist
> 
> \- \[X\] I added a descriptive title
> \- \[X\] I searched open report…s and couldn't find a duplicate
> 
> \### What happened?
> 
> \# Minimal env
> 
> A minimal environment like below is created:
> 
> \`\`\`bash
> conda create -n minimal\_pytorch python=3.6 pytorch torchvision torchaudio -c pytorch
> \`\`\`
> 
> Just getting the PyTorch version by the following command would throw errors:
> 
> \`\`\`bash
> source activate minimal\_pytorch && python -c "import torch; print(torch.\_\_version\_\_)"
> \`\`\`
> 
> This \`undefined symbol\` error is thrown:
> 
> \`\`\`
> Traceback (most recent call last):
> File "\<string\>", line 1, in \<module\>
> File "/usr/local/envs/minimal\_pytorch/lib/python3.6/site-packages/torch/\_\_init\_\_.py", line 197, in \<module\>
> from torch.\_C import \* # noqa: F403
> ImportError: /usr/local/envs/minimal\_pytorch/lib/python3.6/site-packages/torch/lib/libtorch\_cpu.so: undefined symbol: iJIT\_NotifyEvent
> \`\`\`
> 
> \## Python version
> 
> When Python version is omitted while creating the environment:
> 
> \`\`\`bash
> conda create -n minimal\_pytorch python pytorch torchvision torchaudio -c pytorch
> \`\`\`
> 
> The error is resolved:
> 
> \`\`\`
> source activate minimal\_pytorch && python -c "import torch; print(torch.\_\_version\_\_)"
> \`\`\`
> 
> PyTorch version is received without any error:
> 
> \`\`\`
> 2.2.2
> \`\`\`
> 
> \## Note
> 
> I have posted a question here too: https://stackoverflow.com/q/78328401/3405291
> 
> 
> \### Conda Info
> 
> \`\`\`shell
> active environment : minimal\_pytorch
> active env location : /usr/local/envs/minimal\_pytorch
> shell level : 1
> user config file : /root/.condarc
> populated config files : /usr/local/.condarc
> conda version : 23.11.0
> conda-build version : not installed
> python version : 3.10.13.final.0
> solver : libmamba (default)
> virtual packages : \_\_archspec=1=broadwell
> \_\_conda=23.11.0=0
> \_\_glibc=2.35=0
> \_\_linux=6.1.58=0
> \_\_unix=0=0
> base environment : /usr/local (writable)
> conda av data dir : /usr/local/etc/conda
> conda av metadata url : None
> channel URLs : https://conda.anaconda.org/conda-forge/linux-64
> https://conda.anaconda.org/conda-forge/noarch
> package cache : /usr/local/pkgs
> /root/.conda/pkgs
> envs directories : /usr/local/envs
> /root/.conda/envs
> platform : linux-64
> user-agent : conda/23.11.0 requests/2.31.0 CPython/3.10.13 Linux/6.1.58+ ubuntu/22.04.3 glibc/2.35 solver/libmamba conda-libmamba-solver/23.12.0 libmambapy/1.5.5
> UID:GID : 0:0
> netrc file : None
> offline mode : False
> \`\`\`
> 
> 
> \### Conda Config
> 
> \`\`\`shell
> ==\> /usr/local/.condarc \<==
> channels:
> - conda-forge
> always\_yes: True
> \`\`\`
> 
> 
> \### Conda list
> 
> \`\`\`shell
> \# packages in environment at /usr/local/envs/minimal\_pytorch:
> \#
> \# Name Version Build Channel
> \_libgcc\_mutex 0.1 conda\_forge conda-forge
> \_openmp\_mutex 4.5 2\_kmp\_llvm conda-forge
> blas 2.122 mkl conda-forge
> blas-devel 3.9.0 22\_linux64\_mkl conda-forge
> bzip2 1.0.8 hd590300\_5 conda-forge
> ca-certificates 2024.2.2 hbcca054\_0 conda-forge
> cudatoolkit 11.3.1 hb98b00a\_13 conda-forge
> dataclasses 0.8 pyh787bdff\_2 conda-forge
> ffmpeg 4.3 hf484d3e\_0 pytorch
> freetype 2.12.1 h267a509\_2 conda-forge
> gmp 6.3.0 h59595ed\_1 conda-forge
> gnutls 3.6.13 h85f3911\_1 conda-forge
> icu 73.2 h59595ed\_0 conda-forge
> jpeg 9e h0b41bf4\_3 conda-forge
> lame 3.100 h166bdaf\_1003 conda-forge
> lcms2 2.12 hddcbb42\_0 conda-forge
> ld\_impl\_linux-64 2.40 h41732ed\_0 conda-forge
> lerc 3.0 h9c3ff4c\_0 conda-forge
> libblas 3.9.0 22\_linux64\_mkl conda-forge
> libcblas 3.9.0 22\_linux64\_mkl conda-forge
> libdeflate 1.10 h7f98852\_0 conda-forge
> libffi 3.4.2 h7f98852\_5 conda-forge
> libgcc-ng 13.2.0 h807b86a\_5 conda-forge
> libgfortran-ng 13.2.0 h69a702a\_5 conda-forge
> libgfortran5 13.2.0 ha4646dd\_5 conda-forge
> libhwloc 2.10.0 default\_h2fb2949\_1000 conda-forge
> libiconv 1.17 hd590300\_2 conda-forge
> liblapack 3.9.0 22\_linux64\_mkl conda-forge
> liblapacke 3.9.0 22\_linux64\_mkl conda-forge
> libnsl 2.0.1 hd590300\_0 conda-forge
> libpng 1.6.43 h2797004\_0 conda-forge
> libsqlite 3.45.2 h2797004\_0 conda-forge
> libstdcxx-ng 13.2.0 h7e041cc\_5 conda-forge
> libtiff 4.3.0 h0fcbabc\_4 conda-forge
> libuv 1.48.0 hd590300\_0 conda-forge
> libwebp-base 1.4.0 hd590300\_0 conda-forge
> libxml2 2.12.6 h232c23b\_2 conda-forge
> libzlib 1.2.13 hd590300\_5 conda-forge
> llvm-openmp 18.1.3 h4dfa4b3\_0 conda-forge
> mkl 2024.1.0 ha957f24\_692 conda-forge
> mkl-devel 2024.1.0 ha770c72\_692 conda-forge
> mkl-include 2024.1.0 ha957f24\_692 conda-forge
> ncurses 6.4.20240210 h59595ed\_0 conda-forge
> nettle 3.6 he412f7d\_0 conda-forge
> numpy 1.19.5 py36hfc0c790\_2 conda-forge
> olefile 0.46 pyh9f0ad1d\_1 conda-forge
> openh264 2.1.1 h780b84a\_0 conda-forge
> openjpeg 2.5.0 h7d73246\_0 conda-forge
> openssl 1.1.1w hd590300\_0 conda-forge
> pillow 8.3.2 py36h676a545\_0 conda-forge
> pip 21.3.1 pyhd8ed1ab\_0 conda-forge
> python 3.6.15 hb7a2778\_0\_cpython conda-forge
> python\_abi 3.6 2\_cp36m conda-forge
> pytorch 1.10.2 py3.6\_cuda11.3\_cudnn8.2.0\_0 pytorch
> pytorch-mutex 1.0 cuda pytorch
> readline 8.2 h8228510\_1 conda-forge
> setuptools 58.0.4 py36h5fab9bb\_2 conda-forge
> sqlite 3.45.2 h2c6b66d\_0 conda-forge
> tbb 2021.12.0 h00ab1b0\_0 conda-forge
> tk 8.6.13 noxft\_h4845f30\_101 conda-forge
> torchaudio 0.10.2 py36\_cu113 pytorch
> torchvision 0.11.3 py36\_cu113 pytorch
> typing\_extensions 4.1.1 pyha770c72\_0 conda-forge
> wheel 0.37.1 pyhd8ed1ab\_0 conda-forge
> xz 5.2.6 h166bdaf\_0 conda-forge
> zlib 1.2.13 hd590300\_5 conda-forge
> zstd 1.5.5 hfc55251\_0 conda-forge
> \`\`\`
> 
> 
> \### Additional Context
> 
> \_No response\_
