Failed clean install of Pytorch

mathias: <p>Hi!<br>
I have a fresh install of Anaconda on Ubuntu 20.04 LTS and tried to install the latest version of Pytorch in a newly created conda environment but it “fails” - specifically, when I try to import torch, get the following error<br>
OSError: libcufft.so.10: cannot open shared object file: No such file or directory</p>
<p>This is correct - the installation installs v11:<br>
/home/mathias/anaconda3/envs/pytorch13/lib/libcufft.so     /home/mathias/anaconda3/envs/pytorch13/lib/libcufft.so.11.0.0.21  /home/mathias/anaconda3/envs/pytorch13/lib/libcufftw.so.11<br>
/home/mathias/anaconda3/envs/pytorch13/lib/libcufft.so.11  /home/mathias/anaconda3/envs/pytorch13/lib/libcufftw.so           /home/mathias/anaconda3/envs/pytorch13/lib/libcufftw.so.11.0.0.21</p>
<p>What am I doing wrong and how do I rectify this ?<br>
Best regards and thanks in advance,<br>
Mathias</p>
<p>More details - step by step of what I did:<br>
(base) mathias@mathias-System-Product-Name:~$ conda create -n pytorch13<br>
Collecting package metadata (current_repodata.json): done<br>
Solving environment: done</p>
<p>==&gt; WARNING: A newer version of conda exists. &lt;==<br>
current version: 22.9.0<br>
latest version: 22.11.1</p>
<p>Please update conda by running</p>
<pre><code>$ conda update -n base -c defaults conda
</code></pre>
<h2><a name="package-plan-1" class="anchor" href="#package-plan-1"></a>Package Plan</h2>
<p>environment location: /home/mathias/anaconda3/envs/pytorch13</p>
<p>Proceed ([y]/n)? y</p>
<p>Preparing transaction: done<br>
Verifying transaction: done<br>
Executing transaction: done</p>
<h1><a name="h-2" class="anchor" href="#h-2"></a></h1>
<h1><a name="to-activate-this-environment-use-3" class="anchor" href="#to-activate-this-environment-use-3"></a>To activate this environment, use</h1>
<h1><a name="h-4" class="anchor" href="#h-4"></a></h1>
<h1><a name="conda-activate-pytorch13-5" class="anchor" href="#conda-activate-pytorch13-5"></a>$ conda activate pytorch13</h1>
<h1><a name="h-6" class="anchor" href="#h-6"></a></h1>
<h1><a name="to-deactivate-an-active-environment-use-7" class="anchor" href="#to-deactivate-an-active-environment-use-7"></a>To deactivate an active environment, use</h1>
<h1><a name="h-8" class="anchor" href="#h-8"></a></h1>
<h1><a name="conda-deactivate-9" class="anchor" href="#conda-deactivate-9"></a>$ conda deactivate</h1>
<p>Retrieving notices: …working… done<br>
(base) mathias@mathias-System-Product-Name:~$ conda activate pytorch13</p>
<p>(pytorch13) mathias@mathias-System-Product-Name:~$ conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia</p>
<p>Collecting package metadata (current_repodata.json): done<br>
Solving environment: failed with initial frozen solve. Retrying with flexible solve.<br>
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.<br>
Collecting package metadata (repodata.json): done<br>
Solving environment: done</p>
<p>==&gt; WARNING: A newer version of conda exists. &lt;==<br>
current version: 22.9.0<br>
latest version: 22.11.1</p>
<p>Please update conda by running</p>
<pre><code>$ conda update -n base -c defaults conda
</code></pre>
<h2><a name="package-plan-10" class="anchor" href="#package-plan-10"></a>Package Plan</h2>
<p>environment location: /home/mathias/anaconda3/envs/pytorch13</p>
<p>added / updated specs:<br>
- pytorch<br>
- pytorch-cuda=11.7<br>
- torchaudio<br>
- torchvision</p>
<p>The following packages will be downloaded:<br>
(Long list of packages …)<br>
The following NEW packages will be INSTALLED:<br>
(Long list of packages …)</p>
<p>Proceed ([y]/n)? y</p>
<p>Downloading and Extracting Packages<br>
(Packages are being downloaded …)</p>
<p>(pytorch13) mathias@mathias-System-Product-Name:~$ which python<br>
/home/mathias/anaconda3/envs/pytorch13/bin/python</p>
<p>(pytorch13) mathias@mathias-System-Product-Name:~$ python<br>
Python 3.10.8 (main, Nov 24 2022, 14:13:03) [GCC 11.2.0] on linux<br>
Type “help”, “copyright”, “credits” or “license” for more information.</p>
<blockquote>
<blockquote>
<blockquote>
<p>import torch<br>
Traceback (most recent call last):<br>
File “”, line 1, in <br>
File “/home/mathias/anaconda3/envs/pytorch13/lib/python3.10/site-packages/torch/<strong>init</strong>.py”, line 191, in <br>
_load_global_deps()<br>
File “/home/mathias/anaconda3/envs/pytorch13/lib/python3.10/site-packages/torch/<strong>init</strong>.py”, line 153, in _load_global_deps<br>
ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL)<br>
File “/home/mathias/anaconda3/envs/pytorch13/lib/python3.10/ctypes/<strong>init</strong>.py”, line 374, in <strong>init</strong><br>
self._handle = _dlopen(self._name, mode)<br>
OSError: libcufft.so.10: cannot open shared object file: No such file or directory</p>
</blockquote>
</blockquote>
</blockquote>
<p>Additional info (if it matters):<br>
(pytorch13) mathias@mathias-System-Product-Name:~$ nvidia-smi<br>
Mon Dec 12 00:34:56 2022<br>
±----------------------------------------------------------------------------+<br>
| NVIDIA-SMI 515.86.01    Driver Version: 515.86.01    CUDA Version: 11.7     |<br>
|-------------------------------±---------------------±---------------------+</p>
<p>(pytorch13) mathias@mathias-System-Product-Name:~/anaconda3/envs/pytorch13/lib$ conda list</p>
<h1><a name="packages-in-environment-at-homemathiasanaconda3envspytorch13-11" class="anchor" href="#packages-in-environment-at-homemathiasanaconda3envspytorch13-11"></a>packages in environment at /home/mathias/anaconda3/envs/pytorch13:</h1>
<h1><a name="h-12" class="anchor" href="#h-12"></a></h1>
<h1><a name="name-version-build-channel-13" class="anchor" href="#name-version-build-channel-13"></a>Name                    Version                   Build  Channel</h1>
<p>_libgcc_mutex             0.1                        main<br>
_openmp_mutex             5.1                       1_gnu<br>
blas                      1.0                         mkl<br>
brotlipy                  0.7.0           py310h7f8727e_1002<br>
bzip2                     1.0.8                h7b6447c_0<br>
ca-certificates           2022.10.11           h06a4308_0<br>
certifi                   2022.9.24       py310h06a4308_0<br>
cffi                      1.15.1          py310h5eee18b_3<br>
charset-normalizer        2.0.4              pyhd3eb1b0_0<br>
cryptography              38.0.1          py310h9ce1e76_0<br>
cuda                      11.7.1                        0    nvidia<br>
cuda-cccl                 11.7.91                       0    nvidia<br>
cuda-command-line-tools   11.7.1                        0    nvidia<br>
cuda-compiler             11.7.1                        0    nvidia<br>
cuda-cudart               11.7.99                       0    nvidia<br>
cuda-cudart-dev           11.7.99                       0    nvidia<br>
cuda-cuobjdump            11.7.91                       0    nvidia<br>
cuda-cupti                11.7.101                      0    nvidia<br>
cuda-cuxxfilt             11.7.91                       0    nvidia<br>
cuda-demo-suite           12.0.76                       0    nvidia<br>
cuda-documentation        12.0.76                       0    nvidia<br>
cuda-driver-dev           11.7.99                       0    nvidia<br>
cuda-gdb                  12.0.90                       0    nvidia<br>
cuda-libraries            11.7.1                        0    nvidia<br>
cuda-libraries-dev        11.7.1                        0    nvidia<br>
cuda-memcheck             11.8.86                       0    nvidia<br>
cuda-nsight               12.0.78                       0    nvidia<br>
cuda-nsight-compute       12.0.0                        0    nvidia<br>
cuda-nvcc                 11.7.99                       0    nvidia<br>
cuda-nvdisasm             12.0.76                       0    nvidia<br>
cuda-nvml-dev             11.7.91                       0    nvidia<br>
cuda-nvprof               12.0.90                       0    nvidia<br>
cuda-nvprune              11.7.91                       0    nvidia<br>
cuda-nvrtc                11.7.99                       0    nvidia<br>
cuda-nvrtc-dev            11.7.99                       0    nvidia<br>
cuda-nvtx                 11.7.91                       0    nvidia<br>
cuda-nvvp                 12.0.90                       0    nvidia<br>
cuda-runtime              11.7.1                        0    nvidia<br>
cuda-sanitizer-api        12.0.90                       0    nvidia<br>
cuda-toolkit              11.7.1                        0    nvidia<br>
cuda-tools                11.7.1                        0    nvidia<br>
cuda-visual-tools         11.7.1                        0    nvidia<br>
ffmpeg                    4.3                  hf484d3e_0    pytorch<br>
flit-core                 3.6.0              pyhd3eb1b0_0<br>
freetype                  2.12.1               h4a9f257_0<br>
gds-tools                 1.5.0.59                      0    nvidia<br>
giflib                    5.2.1                h7b6447c_0<br>
gmp                       6.2.1                h295c915_3<br>
gnutls                    3.6.15               he1e5248_0<br>
idna                      3.4             py310h06a4308_0<br>
intel-openmp              2021.4.0          h06a4308_3561<br>
jpeg                      9e                   h7f8727e_0<br>
lame                      3.100                h7b6447c_0<br>
lcms2                     2.12                 h3be6417_0<br>
ld_impl_linux-64          2.38                 h1181459_1<br>
lerc                      3.0                  h295c915_0<br>
libcublas                 12.0.1.189                    0    nvidia<br>
libcublas-dev             12.0.1.189                    0    nvidia<br>
libcufft                  11.0.0.21                     0    nvidia<br>
libcufft-dev              11.0.0.21                     0    nvidia<br>
libcufile                 1.5.0.59                      0    nvidia<br>
libcufile-dev             1.5.0.59                      0    nvidia<br>
libcurand                 10.3.1.50                     0    nvidia<br>
libcurand-dev             10.3.1.50                     0    nvidia<br>
libcusolver               11.4.2.57                     0    nvidia<br>
libcusolver-dev           11.4.2.57                     0    nvidia<br>
libcusparse               12.0.0.76                     0    nvidia<br>
libcusparse-dev           12.0.0.76                     0    nvidia<br>
libdeflate                1.8                  h7f8727e_5<br>
libffi                    3.4.2                h6a678d5_6<br>
libgcc-ng                 11.2.0               h1234567_1<br>
libgomp                   11.2.0               h1234567_1<br>
libiconv                  1.16                 h7f8727e_2<br>
libidn2                   2.3.2                h7f8727e_0<br>
libnpp                    12.0.0.30                     0    nvidia<br>
libnpp-dev                12.0.0.30                     0    nvidia<br>
libnvjpeg                 12.0.0.28                     0    nvidia<br>
libnvjpeg-dev             12.0.0.28                     0    nvidia<br>
libpng                    1.6.37               hbc83047_0<br>
libstdcxx-ng              11.2.0               h1234567_1<br>
libtasn1                  4.16.0               h27cfd23_0<br>
libtiff                   4.4.0                hecacb30_2<br>
libunistring              0.9.10               h27cfd23_0<br>
libuuid                   1.41.5               h5eee18b_0<br>
libwebp                   1.2.4                h11a3e52_0<br>
libwebp-base              1.2.4                h5eee18b_0<br>
lz4-c                     1.9.3                h295c915_1<br>
mkl                       2021.4.0           h06a4308_640<br>
mkl-service               2.4.0           py310h7f8727e_0<br>
mkl_fft                   1.3.1           py310hd6ae3a3_0<br>
mkl_random                1.2.2           py310h00e6091_0<br>
ncurses                   6.3                  h5eee18b_3<br>
nettle                    3.7.3                hbbd107a_1<br>
nsight-compute            2022.4.0.15                   0    nvidia<br>
numpy                     1.23.4          py310hd5efca6_0<br>
numpy-base                1.23.4          py310h8e6c178_0<br>
openh264                  2.1.1                h4ff587b_0<br>
openssl                   1.1.1s               h7f8727e_0<br>
pillow                    9.2.0           py310hace64e9_1<br>
pip                       22.3.1          py310h06a4308_0<br>
pycparser                 2.21               pyhd3eb1b0_0<br>
pyopenssl                 22.0.0             pyhd3eb1b0_0<br>
pysocks                   1.7.1           py310h06a4308_0<br>
python                    3.10.8               h7a1cb2a_1<br>
pytorch                   1.13.0          py3.10_cuda11.7_cudnn8.5.0_0    pytorch<br>
pytorch-cuda              11.7                 h67b0de4_0    pytorch<br>
pytorch-mutex             1.0                        cuda    pytorch<br>
readline                  8.2                  h5eee18b_0<br>
requests                  2.28.1          py310h06a4308_0<br>
setuptools                65.5.0          py310h06a4308_0<br>
six                       1.16.0             pyhd3eb1b0_1<br>
sqlite                    3.40.0               h5082296_0<br>
tk                        8.6.12               h1ccaba5_0<br>
torchaudio                0.13.0              py310_cu117    pytorch<br>
torchvision               0.14.0              py310_cu117    pytorch<br>
typing_extensions         4.4.0           py310h06a4308_0<br>
tzdata                    2022g                h04d1e81_0<br>
urllib3                   1.26.13         py310h06a4308_0<br>
wheel                     0.37.1             pyhd3eb1b0_0<br>
xz                        5.2.8                h5eee18b_0<br>
zlib                      1.2.13               h5eee18b_0<br>
zstd                      1.5.2                ha4553b6_0</p>

ptrblck: <p>I cannot reproduce the issue using the <code>1.13.0</code> conda binaries with the CUDA 11.7 runtime:</p>
<pre><code class="lang-auto">conda create -n 1.13.0_conda_cu117 python=3.8
...
conda activate 1.13.0_conda_cu117
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
...
The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    cuda-11.7.1                |                0           1 KB  nvidia
    cuda-cccl-11.7.91          |                0         1.2 MB  nvidia
    cuda-command-line-tools-11.7.1|                0           1 KB  nvidia
    cuda-compiler-11.7.1       |                0           1 KB  nvidia
    cuda-cudart-11.7.99        |                0         194 KB  nvidia
    cuda-cudart-dev-11.7.99    |                0         1.1 MB  nvidia
    cuda-cuobjdump-11.7.91     |                0         158 KB  nvidia
    cuda-cupti-11.7.101        |                0        22.9 MB  nvidia
    cuda-cuxxfilt-11.7.91      |                0         293 KB  nvidia
    cuda-demo-suite-12.0.76    |                0         5.0 MB  nvidia
    cuda-documentation-12.0.76 |                0          89 KB  nvidia
    cuda-driver-dev-11.7.99    |                0          16 KB  nvidia
    cuda-gdb-12.0.90           |                0         5.3 MB  nvidia
    cuda-libraries-11.7.1      |                0           1 KB  nvidia
    cuda-libraries-dev-11.7.1  |                0           2 KB  nvidia
    cuda-nsight-12.0.78        |                0       113.6 MB  nvidia
    cuda-nsight-compute-12.0.0 |                0           1 KB  nvidia
    cuda-nvcc-11.7.99          |                0        42.7 MB  nvidia
    cuda-nvdisasm-12.0.76      |                0        47.9 MB  nvidia
    cuda-nvml-dev-11.7.91      |                0          80 KB  nvidia
    cuda-nvprof-12.0.90        |                0         4.3 MB  nvidia
    cuda-nvprune-11.7.91       |                0          64 KB  nvidia
    cuda-nvrtc-11.7.99         |                0        17.3 MB  nvidia
    cuda-nvrtc-dev-11.7.99     |                0        16.9 MB  nvidia
    cuda-nvtx-11.7.91          |                0          57 KB  nvidia
    cuda-nvvp-12.0.90          |                0       114.3 MB  nvidia
    cuda-runtime-11.7.1        |                0           1 KB  nvidia
    cuda-sanitizer-api-12.0.90 |                0        16.6 MB  nvidia
    cuda-toolkit-11.7.1        |                0           1 KB  nvidia
    cuda-tools-11.7.1          |                0           1 KB  nvidia
    cuda-visual-tools-11.7.1   |                0           1 KB  nvidia
    gds-tools-1.5.0.59         |                0        40.9 MB  nvidia
    libcublas-12.0.1.189       |                0       323.3 MB  nvidia
    libcublas-dev-12.0.1.189   |                0          74 KB  nvidia
    libcufft-11.0.0.21         |                0        75.5 MB  nvidia
    libcufft-dev-11.0.0.21     |                0          14 KB  nvidia
    libcufile-1.5.0.59         |                0         754 KB  nvidia
    libcufile-dev-1.5.0.59     |                0          13 KB  nvidia
    libcurand-10.3.1.50        |                0        51.7 MB  nvidia
    libcurand-dev-10.3.1.50    |                0         449 KB  nvidia
    libcusolver-11.4.2.57      |                0        98.3 MB  nvidia
    libcusolver-dev-11.4.2.57  |                0          50 KB  nvidia
    libcusparse-12.0.0.76      |                0       133.6 MB  nvidia
    libcusparse-dev-12.0.0.76  |                0       133.6 MB  nvidia
    libnpp-12.0.0.30           |                0       139.3 MB  nvidia
    libnpp-dev-12.0.0.30       |                0         513 KB  nvidia
    libnvjpeg-12.0.0.28        |                0         2.3 MB  nvidia
    libnvjpeg-dev-12.0.0.28    |                0          13 KB  nvidia
    nsight-compute-2022.4.0.15 |                0       764.0 MB  nvidia
    pytorch-1.13.0             |py3.8_cuda11.7_cudnn8.5.0_0        1.15 GB  pytorch
    pytorch-cuda-11.7          |       h67b0de4_0           7 KB  pytorch
    pytorch-mutex-1.0          |             cuda           3 KB  pytorch
    torchaudio-0.13.0          |       py38_cu117         6.5 MB  pytorch
    torchvision-0.14.0         |       py38_cu117        29.5 MB  pytorch
    ------------------------------------------------------------
                                           Total:        3.30 GB
</code></pre>
<p>Output:</p>
<pre><code class="lang-python">python
&gt;&gt;&gt; import torch
&gt;&gt;&gt; torch.__version__
'1.13.0'
&gt;&gt;&gt; torch.version.cuda
'11.7'
&gt;&gt;&gt; torch.randn(1).cuda()
tensor([0.5558], device='cuda:0')
</code></pre>

mathias: <p>Thank you for your prompt reply. Unfortunately, I still have the same problem.</p>
<p>Do you get any of the following while solving the environment ?<br>
Solving environment: failed with initial frozen solve. Retrying with flexible solve.<br>
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.</p>
<p>Also, do you know how I can change the input to<br>
lib/python3.8/site-packages/torch/<strong>init</strong>.py<br>
so that it wants v11 instead of v10 ?</p>
<p>Thanks again!<br>
Mathias</p>

ptrblck: <aside class="quote no-group" data-username="mathias" data-post="3" data-topic="168107">
<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/bbe5ce/48.png" class="avatar"> mathias:</div>
<blockquote>
<p>Also, do you know how I can change the input to<br>
lib/python3.8/site-packages/torch/<strong>init</strong>.py<br>
so that it wants v11 instead of v10 ?</p>
</blockquote>
</aside>
<p>I don’t think you should try to manipulate any installed PyTorch files, as the issue seems to come from your conda env and fixing one issues could result in other failures.<br>
Could you check if your base conda env contains any PyTorch installations and delete them if that’s the case?</p>

mathias: <p>Good idea. I had a Pytorch version installed, but removing it did not resolve the issue.<br>
However, I managed to get the 2.0-version to work, so maybe I’ll just stick to that one.<br>
Thank you for all your help.</p>