'GLIBCXX_3.4.30' not found

jS5t3r: <p>Hi,<br>
I have installed the latest torch version in a fresh environment and get the following error when executing <code>python run_glue.py</code>:</p>
<pre><code class="lang-auto">/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /home/user/.conda/envs/env/lib/python3.8/site-packages/torch/lib/libtorch_python.so)
</code></pre>
<p>I already have tried to to install:</p>
<ul>
<li>conda install libgcc</li>
<li>conda install -c conda-forge libstdcxx-ng=12</li>
<li>conda install -c conda-forge gcc=12.1.0</li>
</ul>
<p>strings ~/.conda/envs/env/lib/libstdc++.so.6 | grep ‘GLIBCXX_3’</p>
<pre><code class="lang-auto">GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBCXX_3.4.22
GLIBCXX_3.4.23
GLIBCXX_3.4.24
GLIBCXX_3.4.25
GLIBCXX_3.4.26
GLIBCXX_3.4.27
GLIBCXX_3.4.28
GLIBCXX_3.4.29
GLIBCXX_3.4.30
</code></pre>
<p>Any ideas how to fix this?</p>

ptrblck: <p>How did you install PyTorch? Using the official install commands or from <code>conda-forge</code>? I’ve seen these GLIBC incompatibilities in <code>coda-forge</code> before as it seems some of the libs use the latest standards.</p>

jS5t3r: <p>I used this command:<br>
<code>conda install pytorch torchvision pytorch-cuda=11.8 -c pytorch -c nvidia</code></p>

ptrblck: <p>Could you post a minimal and executable code snippet to reproduce the issue or is it already failing during the import?<br>
I’ve created a new and clean conda environment and cannot reproduce any issues:</p>
<pre data-code-wrap="python"><code class="lang-python">&gt;&gt;&gt; import torch
&gt;&gt;&gt; torch.randn(1).cuda()
tensor([0.2782], device='cuda:0')                                                                                                                                                                                  
&gt;&gt;&gt; torch.__version__
'2.2.0'                                                                                                                                                                                                            
&gt;&gt;&gt; torch.version.cuda
'11.8'   
</code></pre>
<p>installed via:</p>
<pre data-code-wrap="python"><code class="lang-python">conda install pytorch torchvision pytorch-cuda=11.8 -c pytorch -c nvidia
</code></pre>

malfet: <p>Do you mind sharing <code>conda list</code> and <code>env</code> when you are executing this command?</p>

jS5t3r: <p>I reinstalled using the command above and it automatically selects conda-forge and CPU, what I don’t want:</p>
<pre><code class="lang-auto">    pytorch-2.1.0              | cpu_generic_py38had2c7df_0        71.6 MB  conda-forge
    torchvision-0.16.1       | cpu_py38h901811f_2         9.7 MB  conda-forge
</code></pre>
<p>I get this conda warning, when installing any conda package:</p>
<pre><code class="lang-auto">Collecting package metadata (current_repodata.json): WARNING conda.models.version:get_matcher(542): Using .* with relational operator is superfluous and deprecated and will be removed in a future version of conda. Your spec was 1.7.1.*, but conda is ignoring the .* and treating it as 1.7.1
done
</code></pre>
<p>My conda env might be restricted by the admin.</p>
<p>Then, I changed the install command:</p>
<pre><code class="lang-auto">conda install pytorch==2.1.1 torchvision==0.16.1  pytorch-cuda=11.8 -c pytorch -c nvidia
</code></pre>
<pre><code class="lang-auto">The following packages will be UPDATED:

  pytorch            conda-forge::pytorch-2.1.0-cpu_generi~ --&gt; pytorch::pytorch-2.1.1-py3.8_cuda11.8_cudnn8.7.0_0 None

The following packages will be SUPERSEDED by a higher-priority channel:

  torchvision        conda-forge::torchvision-0.16.1-cpu_p~ --&gt; pytorch::torchvision-0.16.1-py38_cu118 None

The following packages will be DOWNGRADED:

  _openmp_mutex                                   4.5-2_gnu --&gt; 4.5-2_kmp_llvm None
  libblas                         3.9.0-21_linux64_openblas --&gt; 3.9.0-16_linux64_mkl None
  libcblas                        3.9.0-21_linux64_openblas --&gt; 3.9.0-16_linux64_mkl None
  liblapack                       3.9.0-21_linux64_openblas --&gt; 3.9.0-16_linux64_mkl None
</code></pre>
<p>Following your instructions:</p>
<pre><code class="lang-auto">&gt;&gt;&gt; import torch
torch.randn(1).cuda()
&gt;&gt;&gt; torch.randn(1).cuda()
tensor([0.5221], device='cuda:0')
&gt;&gt;&gt; torch.__version__
'2.1.1'
&gt;&gt;&gt; torch.version.cuda
'11.8'
</code></pre>
<p>I also started my script. And the glib error is gone <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>

ptrblck: <p>Great! So for some reason the <code>conda-forge</code> packages were indeed installed. <img src="https://discuss.pytorch.org/images/emoji/apple/confused.png?v=12" title=":confused:" class="emoji" alt=":confused:" loading="lazy" width="20" height="20"><br>
Note that we do not maintain them but I’ve seen similar compatibility issues in the past when trying to mix packages from <code>conda-forge</code> with other libs.</p>

mw0: <p>I used</p>
<pre data-code-wrap="bash"><code class="lang-bash">mamba install pytorch torchvision pytorch-cuda=12.2 -c pytorch -c nvidia
</code></pre>
<p>which yielded no complaints. Afterward, <code>mamba list torch</code> returned:</p>
<pre data-code-wrap="bash"><code class="lang-bash"># packages in environment at /home/ec2-user/anaconda3/envs/LLM:
#
# Name                    Version                   Build  Channel
pytorch                   2.2.2              py3.12_cpu_0    pytorch
pytorch-cuda              12.2                 h5ef38aa_0    https://aws-ml-conda.s3.us-west-2.amazonaws.com
pytorch-mutex             1.0                         cpu    pytorch
torchaudio                2.2.2                 py312_cpu    pytorch
torchvision               0.17.2                py312_cpu    pytorch
</code></pre>
<p>But here is the weird thing:</p>
<pre data-code-wrap="bash"><code class="lang-bash">python -c 'import torch; print(torch.version.cuda); print(torch.__version__); print(torch.cuda.is_available())'
</code></pre>
<p>returns</p>
<pre data-code-wrap="bash"><code class="lang-bash">None
2.2.2
False
</code></pre>
<p>The environment variables <code>CONDA_HOME</code>, <code>PATH</code> and <code>LD_LIBRARY_PATH</code> all point to <code>/usr/local/cuda-12.2</code> or the <code>lib64</code> subdirectory, as does the logical link <code>/usr/local/cuda</code>. Furthermore, I was able to compile a trivial CUDA hello program, suggesting that the installation is good.</p>
<p>Any suggestions?</p>

ptrblck: <aside class="quote no-group" data-username="mw0" data-post="9" data-topic="196875">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/m/87869e/48.png" class="avatar"> mw0:</div>
<blockquote>
<p><code>pytorch                   2.2.2              py3.12_cpu_0    pytorch</code></p>
</blockquote>
</aside>
<p>You’ve installed the CPU-only binary and would need to install the one with CUDA support.</p>

mw0: <p>Thank you for catching this <a class="mention" href="/u/ptrblck">@ptrblck</a>! In the end, the usual installs failed to handle CUDA Version 12.2, falling through to CPU type. After downgrading to CUDA Version 12.1 the GPU versions did install, and all is well.</p>

ptrblck: <p>Good to hear it’s working!<br>
Yes, <code>pytorch-cuda=12.2</code> is not built by us and we recommend sticking to the official <a href="https://pytorch.org/get-started/locally/">install instructions</a>.</p>

danial_javady: <p>I’ve also run into this problem yesterday on <code>main</code> and it was solved by installing gcc 12.3 on conda, I’m on cuda 12.4 and wsl.</p>
<p>Similar to OP i also had 3.4.30 in my system path but it didn’t work.</p>

malfet: <p>This is specific to Conda environment, where it prefers all the apps to use libstdc++ from its environment, rather than a system one. Ugly hack I sometimes have to revert to is to delete it and symlink system libstdc++ there.</p>
<p>By the way, are you running into this issue when you are trying to use compile?</p>