Install libtorch version 1.8.1 on ubuntu 18

username: 2021
cooked: <p>I was trying to install libtorch version 1.8.1 on ubuntu 18 following the following code:</p>
<blockquote>
<p>git clone <a href="https://github.com/pytorch/pytorch.git" class="inline-onebox" rel="noopener nofollow ugc">GitHub - pytorch/pytorch: Tensors and Dynamic neural networks in Python with strong GPU acceleration</a><br>
cd pytorch/<br>
git checkout v1.8.1</p>
<h1>update submodule, this may take a while</h1>
<p>git submodule update --init --recursive</p>
<h1>change protobuf to v3.6.1</h1>
<p>cd third_party/protobuf<br>
git checkout v3.6.1<br>
cd …/…</p>
<h1>activate a conda virtual env with python3.8</h1>
<p>conda activate py38<br>
python setup.py install</p>
<p>sudo mkdir -p /opt/allride/third_party/libtorch<br>
sudo chmod -R 755 /opt/allride<br>
cp -r torch/lib /opt/allride/third_party/libtorch<br>
cp -r torch/share /opt/allride/third_party/libtorch<br>
cp -r torch/include /opt/allride/third_party/libtorch</p>
</blockquote>
<blockquote>
<p>echo “export LD_LIBRARY_PATH=/opt/allride/third_party/libtorch/lib:$LD_LIBRARY_PATH” &gt;&gt; ~/.bashrc</p>
</blockquote>
<p>Yet, I can execute the last two copy command. It told me that torch/share, torch/include directory can not be found.<br>
Then,</p>
<blockquote>
<p>~/pytorch/torch$ libtorch<br>
Error processing line 1 of /home/allride/.local/lib/python3.6/site-packages/google_auth-2.3.0-py3.10-nspkg.pth:</p>
<p>Failed to import the site module<br>
Traceback (most recent call last):<br>
File “/usr/lib/python3.6/site.py”, line 174, in addpackage<br>
exec(line)<br>
File “”, line 1, in <br>
File “/home/allride/pytorch/torch/types.py”, line 1, in <br>
import torch<br>
File “/opt/allride/third_party/libtorch/python2.7/torch/<strong>init</strong>.py”, line 13, in <br>
import platform<br>
File “/usr/lib/python3.6/platform.py”, line 116, in <br>
import sys, os, re, subprocess<br>
File “/usr/lib/python3.6/re.py”, line 122, in <br>
import enum<br>
File “/usr/lib/python3.6/enum.py”, line 2, in <br>
from types import MappingProxyType, DynamicClassAttribute<br>
ImportError: cannot import name ‘MappingProxyType’</p>
<p>During handling of the above exception, another exception occurred:</p>
<p>Traceback (most recent call last):<br>
File “/usr/lib/python3.6/site.py”, line 570, in <br>
main()<br>
File “/usr/lib/python3.6/site.py”, line 556, in main<br>
known_paths = addusersitepackages(known_paths)<br>
File “/usr/lib/python3.6/site.py”, line 291, in addusersitepackages<br>
addsitedir(user_site, known_paths)<br>
File “/usr/lib/python3.6/site.py”, line 213, in addsitedir<br>
addpackage(sitedir, name, known_paths)<br>
File “/usr/lib/python3.6/site.py”, line 184, in addpackage<br>
import traceback<br>
File “/usr/lib/python3.6/traceback.py”, line 5, in <br>
import linecache<br>
File “/usr/lib/python3.6/linecache.py”, line 8, in <br>
import functools<br>
File “/usr/lib/python3.6/functools.py”, line 22, in <br>
from types import MappingProxyType<br>
File “/home/allride/pytorch/torch/types.py”, line 1, in <br>
import torch<br>
File “/opt/allride/third_party/libtorch/python2.7/torch/<strong>init</strong>.py”, line 13, in <br>
import platform<br>
File “/usr/lib/python3.6/platform.py”, line 116, in <br>
import sys, os, re, subprocess<br>
File “/usr/lib/python3.6/re.py”, line 122, in <br>
import enum<br>
File “/usr/lib/python3.6/enum.py”, line 2, in <br>
from types import MappingProxyType, DynamicClassAttribute<br>
ImportError: cannot import name ‘MappingProxyType’</p>
</blockquote>
<p>I searched this error message online and it told me that one possible cause is because of the use of type in one self-defined module.</p>
<p>I do not know how to proceed. Any comments are greatly appreciated.</p>