Minimum glibc version for installation of pytorch when installing from source

Rishav_Sapahia: <p>Hi,<br>
Is there a minimum version of glibc required for installation of pytorch when installing from source.<br>
My system’s glibc is 2.12. I am trying to install pytorch = 1.3 on it.</p>

albanD: <p>I am not sure. Are you seeing any error with this glibc?</p>

Rishav_Sapahia: <p>Yes, a lot.<br>
I am installing pytorch from source on a remote server which already have some versions of <code>Cuda, CMake, gcc, python</code> installed.<br>
OS is <code>Cent OS - 6.5</code><br>
As installing from source requires installing from <code>conda</code> so I installed it. I have to set it explicitly by using <br><code>unset PYTHONPATH</code><br><code>unset PYTHONHOME</code> because otherwise it was picking up system’s python path.<br>
Now, I am getting <a href="https://discuss.pytorch.org/t/installing-pytorch-from-the-source-using-pip/59522/7">these errors</a><br>
I am not sure whether these errors are creeping up because conda is picking the system’s <code>gcc,CMake </code>or whether it is because of glibc error which this <a href="https://stackoverflow.com/questions/58616298/install-pytorch-from-the-source-using-pip/58616665?noredirect=1#comment103582235_58616665" rel="nofollow noopener">Stackoverflow answer is pointing.</a></p>

albanD: <p>you shouldn’t need to change the pythonpath and home in conda.<br>
Did you properly activate the conda environment?</p>

Rishav_Sapahia: <p>if I am not changing the pythonpath and home then I am getting <br><code>from conda.cli import main ModuleNotFoundError: No module named 'conda'</code></p>

albanD: <p>Did you properly activate the conda environment?</p>

Rishav_Sapahia: <p>No, because it is not getting activated as I am getting <br><br>
<code>from conda.cli import main ModuleNotFoundError: No module named 'conda'</code><br>
when I am trying to activate it.</p>

albanD: <p>Ho, sorry I did not understood that from your previous post.<br>
I would solve this issue first before trying to install pytorch. Because if it is not activated properly, then the given instructions won’t work.</p>
<p>Have you checked google for that error? Answers like: <a href="https://stackoverflow.com/questions/19825250/after-anaconda-installation-conda-command-fails-with-importerror-no-module-na" rel="nofollow noopener">https://stackoverflow.com/questions/19825250/after-anaconda-installation-conda-command-fails-with-importerror-no-module-na</a> seem relevant to your problem.</p>

Rishav_Sapahia: <p>No problem, let me sum it up my issues<br>
I have solved the activation of conda environment problem by using<br>
<code>unset PYTHONPATH</code><br><br>
<code>unset PYTHONHOME</code><br><br>
Now, the conda environment is activated. Now, when I run<br>
<code>python setup.py install --user</code> as directed from the <a href="https://github.com/pytorch/pytorch#get-the-pytorch-source" rel="nofollow noopener">source</a>,<br>
I am getting</p>
<pre><code class="lang-auto">Building wheel torch-1.4.0a0+c63e15a
-- Building version 1.4.0a0+c63e15a
cmake --build . --target install --config Release -- -j 16
/nethome/rxs1576/anaconda3/bin/ninja: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.18' not found (required by /nethome/rxs1576/anaconda3/bin/ninja)
/nethome/rxs1576/anaconda3/bin/ninja: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /nethome/rxs1576/anaconda3/bin/ninja)
/nethome/rxs1576/anaconda3/bin/ninja: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /nethome/rxs1576/anaconda3/bin/ninja)
Traceback (most recent call last):
  File "setup.py", line 751, in &lt;module&gt;
    build_deps()
  File "setup.py", line 310, in build_deps
    cmake=cmake)
  File "/nethome/rxs1576/pytorch/tools/build_pytorch_libs.py", line 59, in build_caffe2
    cmake.build(my_env)
  File "/nethome/rxs1576/pytorch/tools/setup_helpers/cmake.py", line 334, in build
    self.run(build_args, my_env)
  File "/nethome/rxs1576/pytorch/tools/setup_helpers/cmake.py", line 142, in run
    check_call(command, cwd=self.build_dir, env=env)
  File "/nethome/rxs1576/anaconda3/envs/conda_env/lib/python3.6/subprocess.py", line 291, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'install', '--config', 'Release', '--', '-j', '16']' returned non-zero exit status 1.

</code></pre>

albanD: <p>Hi,</p>
<p>After looking internally, the oldest version we support is the one from RHEL7 I’m afraid <img src="https://discuss.pytorch.org/images/emoji/apple/confused.png?v=9" title=":confused:" class="emoji" alt=":confused:"><br>
Maybe you can use conda to get a more recent glibc package than your system one <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>

Rishav_Sapahia: <p>I just updated my <code>glibc</code> version from <code>2.12</code> to <code>2.18</code>.Now, on doing<br>
<code>python setup.py install</code>, I am getting<br>
<code>Segmentation fault (core dumped)</code></p>

albanD: <p>Make sure to clean the previous installs / other libraries that you already installed with the older glibc.</p>

Rishav_Sapahia: <p>still the same error.<img src="https://discuss.pytorch.org/images/emoji/apple/frowning_face.png?v=9" title=":frowning_face:" class="emoji" alt=":frowning_face:"></p>

albanD: <p>Where does the segfault happens? do you have a proper compiler to work with this new glibc?</p>

Rishav_Sapahia: <p>I think i am having an issue of having multiple <code>glibc</code> versions now.<br>
On running,</p>
<pre><code class="lang-auto">ldd (GNU libc) 2.18
Copyright (C) 2013 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.
Written by Roland McGrath and Ulrich Drepper.
</code></pre>
<p>while on running<br>
<code>/lib/libc.so.6 </code>,I am getting-</p>
<pre><code class="lang-auto">GNU C Library stable release version 2.12, by Roland McGrath et al.
Copyright (C) 2010 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.
Compiled by GNU CC version 4.4.7 20120313 (Red Hat 4.4.7-4).
Compiled on a Linux 2.6.32 system on 2013-11-21.
Available extensions:
	The C stubs add-on version 2.1.2.
	crypt add-on version 2.1 by Michael Glad and others
	GNU Libidn by Simon Josefsson
	Native POSIX Threads Library by Ulrich Drepper et al
	BIND-8.2.3-T5B
	RT using linux kernel aio
libc ABIs: UNIQUE IFUNC
For bug reporting instructions, please see:
&lt;http://www.gnu.org/software/libc/bugs.html&gt;.
</code></pre>

albanD: <p>If you installed the second one with conda. The original one that was in your system should still be there. Just that the conda version should always be found first when your conda environment is activated.</p>

Rishav_Sapahia: <p>Then I don’t know where I am doing wrong.<br>
Where does the segfault happens?<br>
When running <code>python setup.py install</code> or even starting <code>python</code> in terminal.<br>
do you have a proper compiler to work with this new glibc?<br>
I have a gcc-4.4, though I can upgrade it to <code>5.5</code>.</p>

albanD: <blockquote>
<p>When running  <code>python setup.py install</code>  or even starting  <code>python</code>  in terminal.</p>
</blockquote>
<p>If just running python segfaults then the issue is not with pytorch. Most likely your python expects the old glibc and crash with the new one. You will need to get a python that works with this new glibc. Once you can run python with no error in the terminal, you can try to install pytorch again.</p>
<blockquote>
<p>I have a gcc-4.4, though I can upgrade it to  <code>5.5</code> .</p>
</blockquote>
<p>Pytorch now requires gcc 5+ to compile. So you should upgrade your compiler (inside conda if you don’t want to change the system one).</p>

Rishav_Sapahia: <p>I am trying to update my python to <code>3.7</code>, I’ll update you after installing it.<br>
Also, is there any <code>cuda version</code> limitation when installing pytorch from source. I have <code>cuda version of 9.1</code>.</p>

albanD: <p>I don’t remember on top of my head but the most recent the better (especially cudnn for speed). Here again you have conda packages that contain that, so it should be fairly easy to upgrade.</p>