undefined symbol: THPVariableClaload_textures.cpython-37m-x86_64-linux-gnu.so: undefined symbol: THPVariableClass
Do you know how I could fix this? I am trying to use https://github.com/benjiebob/SMALViewer/issues/3 repo however I get error on neural_renderer port:
$ python smal_viewer.py 
Traceback (most recent call last):
  File &quot;smal_viewer.py&quot;, line 2, in &lt;module&gt;
    import pyqt_viewer
  File &quot;/home/mona/research/3danimals/SMALViewer/pyqt_viewer.py&quot;, line 13, in &lt;module&gt;
    from smal.smal3d_renderer import SMAL3DRenderer
  File &quot;/home/mona/research/3danimals/SMALViewer/smal/smal3d_renderer.py&quot;, line 6, in &lt;module&gt;
    import neural_renderer as nr
  File &quot;/home/mona/anaconda3/lib/python3.7/site-packages/neural_renderer/__init__.py&quot;, line 3, in &lt;module&gt;
    from .load_obj import load_obj
  File &quot;/home/mona/anaconda3/lib/python3.7/site-packages/neural_renderer/load_obj.py&quot;, line 8, in &lt;module&gt;
    import neural_renderer.cuda.load_textures as load_textures_cuda
ImportError: /home/mona/anaconda3/lib/python3.7/site-packages/neural_renderer/cuda/load_textures.cpython-37m-x86_64-linux-gnu.so: undefined symbol: THPVariableClass

Here is some details:
$ python
Python 3.7.6 (default, Jan  8 2020, 19:59:22) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; import torch
&gt;&gt;&gt; torch.__version__
'1.6.0'
&gt;&gt;&gt; torch.version.cuda
'10.1'
&gt;&gt;&gt; torch.cuda.is_available()
True


$ gcc --version
gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


$ lsb_release -a
LSB Version:    core-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:    20.04
Codename:   focal

Here is the neural renderer git repo: https://github.com/daniilidis-group/neural_renderer
I installed the neural renderer using pip install neural_renderer_pytorch

It looks like you didn't build the neural_renderer_pytorch yourself, but used a wheel. However, this wheel was built with an older pytorch version and doesn't work with the current pytorch version on your machine.
Build neural_renderer from the source (after deinstalling neural_renderer you have now) using your current pytorch-version  i.e.
$ pip uninstall neural-renderer-pytorch

$ pip install https://github.com/daniilidis-group/neural_renderer/zipball/master

and it should work.

Until pytorch 1.5, it used a someway brittle way of building extensions on Linux: despite depending on torch, extensions didn't link explicitly against libtorch.so. The missing symbols were provided only because import torch loaded libtorch.so with RTLD_GLOBAL, thus making its symbols globally visibile/accessible - this is the reason why prior to loading those extensions (e.g. neural_renderer_pytorch like here) one had to import torch.
One could enforce the old behavior setting RTLD_GLOBAL prior to importing torch for the very first time it is happening:
import sys; import ctypes;
sys.setdlopenflags(sys.getdlopenflags() | ctypes.RTLD_GLOBAL)
import torch # now all symbols of torch
             # have global visibility and can be used in 
             # other extensions

However, using RTLD_GLOBAL is quite dangerous as it could possibly interpose symbols that are unrelated and lead to subtle bugs or even crashes.
Thus, since 1.5 pytorch no longer uses RTLD_GLOBAL, but links explicitly against libpytorch.so (see this commit) and extensions built with older pytorch versions will not work.
