torchaudio C++ extension is not available - pytorch

Warning (from warnings module):
File "C:\Users\A\AppData\Local\Programs\Python\Python36\lib\site-packages\torchaudio\extension\extension.py", line 14
warnings.warn('torchaudio C++ extension is not available.')
UserWarning: torchaudio C++ extension is not available.
Can anyone help me with this...

Related

Cupy DLL load failed

I am trying to use cupy to speed up some background numpy operations in my python code but when attempting to import cupy I am told that the DLL load failed, importError: DLL load failed.
I am fairly inexperienced when it comes to handling things like this so any help would be greatly appreciated. The entire error message and trace is copied below:
when I tried pip install cupy-cuda112, cupy import is working but pytorch import is not working.
Error loading "C:\Users\CT1\miniconda3\envs\DentiumRIP\lib\site-packages\torch\lib\cublas64_11.dll" or one of its dependencies.
And, when I do conda install pytorch torchvision torchaudio cudatoolkit=11.2 -c pytorch -c conda-forge, the cupy import doesn't work.
please tell me how to fix it..
Failed to import CuPy.
If you installed CuPy via wheels (cupy-cudaXXX or cupy-rocm-X-X), make sure that the package matches with the version of CUDA or ROCm installed.
On Linux, you may need to set LD_LIBRARY_PATH environment variable depending on how you installed CUDA/ROCm.
On Windows, try setting CUDA_PATH environment variable.
Check the Installation Guide for details:
https://docs.cupy.dev/en/latest/install.html
Original error:
ImportError: DLL load failed: 지정된 프로시저를 찾을 수 없습니다.

how does one fix when torch can't find cuda, error: version libcublasLt.so.11 not defined in file libcublasLt.so.11 with link time reference?

I get this error with a pytorch import python -c "import torch":
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/afs/cs.stanford.edu/u/brando9/ultimate-utils/ultimate-utils-proj-src/uutils/__init__.py", line 13, in <module>
import torch
File "/dfs/scratch0/brando9/miniconda/envs/metalearning_gpu/lib/python3.9/site-packages/torch/__init__.py", line 191, in <module>
_load_global_deps()
File "/dfs/scratch0/brando9/miniconda/envs/metalearning_gpu/lib/python3.9/site-packages/torch/__init__.py", line 153, in _load_global_deps
ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL)
File "/dfs/scratch0/brando9/miniconda/envs/metalearning_gpu/lib/python3.9/ctypes/__init__.py", line 382, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /dfs/scratch0/brando9/miniconda/envs/metalearning_gpu/lib/python3.9/site-packages/torch/lib/../../nvidia/cublas/lib/libcublas.so.11: symbol cublasLtHSHMatmulAlgoInit, version libcublasLt.so.11 not defined in file libcublasLt.so.11 with link time reference
how does one fix it?
related:
Could not load dynamic library 'libcublasLt.so.11'; dlerror: libcublasLt.so.11: cannot open shared object file: No such file or directory
https://github.com/pytorch/pytorch/issues/51080
The error is from dlopen libcublas.so from .../python3.9/site-packages/torch/lib/nvidia/cublas/lib/, which is the pip package "nvidia-cuda-runtime" install location.
libcublasLt.so.11 is dynamically linked to libcublas.so.11. The problem is that when you have a different cuda runtime installation (usually in /usr/local/cuda), dlopen probably gets the wrong one. You can run ldd .../python3.9/site-packages/torch/lib/nvidia/cublas/lib/libcublas.so to check the actual path of libcublasLt.so.11, which is supposed to be the one under .../python3.9/site-packages/torch/lib/nvidia/cublas/lib/
Workarounds:
Set env LD_LIBRARY_PATH=.../python3.9/site-packages/torch/lib/nvidia/cublas/lib/:$LD_LIBRARY_PATH when launching python. So that dlopen can firstly look for .so files in that directory.
Using older torch. It was since 1.13.0 torch pip install started using pip nvidia-* packages. Before that cuda libs are statically linked. That's why older torch pip install has no problem even if you have existing cuda install.
like eval said, it is because pytorch1.13 automatically install nvidia_cublas_cu11,nvidia_cuda_nvrtc_cu11,nvidia_cuda_runtime_cu11 and nvidia_cudnn_cu11. While I have my own CUDA toolKit already installed, I have the same problem.
In my case, I used pip uninstall nvidia_cublas_cu11 and solved the problem.
I think the pytorch team should solve this, since users often have their own CUDAtoolkit installed.
I don't know why this works but this worked for me:
source cuda11.1
# To see Cuda version in use
nvcc -V
pip3 install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html
but if you look through the git issue these might also work:
conda install -y -c pytorch -c conda-forge cudatoolkit=11.1 pytorch torchvision torchaudio
pip3 install torch+cu111 torchvision torchaudio -f https://download.pytorch.org/whl/torch_stable.html
I think the conda one looks like the most robust because you can specify exactly the cudatoolkit you need, so I'd recommend that one.
I wanted to work on an images detection problem using yolov7, and I installed default dependencies as provided by yolov7 https://github.com/WongKinYiu/yolov7/blob/main/requirements.txt, but when I tried even to check the help manual I got this error
OSError: .../yolov7_env/lib/python3.8/site-packages/torch/lib/../../nvidia/cublas/lib/libcublas.so.11: undefined symbol: cublasLtGetStatusString, version libcublasLt.so.11
Then I tried to install some other dependencies using the following command:
pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 --extra-index-url https://download.pytorch.org/whl/cu113
this's how I solved the problem.

How to solve the import cv problem in vs studio?

File "c:\Users\csany\Documents\PYTHON_BEGINEERS\read.py", line 1, in
import cv2 as cv
File "C:\Users\csany\AppData\Local\Programs\Python\Python39\lib\site-packages\cv2_init_.py", line 5, in
from .cv2 import *
ImportError: DLL load failed while importing cv2: The specified module could not be found.
Every time I try to run the code i get this error. I have installed OpenCV module through its source I have changed its path yet it still won't work in vs studio for python. Please help me out
You can download the latest OpenCV 3.2.0 for Python 3.6 on Windows 32-bit or 64-bit machine, look for file starts withopencv_python‑3.2.0‑cp36‑cp36m, from this unofficial site. Then type below command to install it:
pip install opencv_python‑3.2.0‑cp36‑cp36m‑win32.whl (32-bit version)
pip install opencv_python‑3.2.0‑cp36‑cp36m‑win_amd64.whl (64-bit version)
I think it would be easier.
Update on 2017-09-15:
OpenCV 3.3.0 wheel files are now available in the unofficial site and replaced OpenCV 3.2.0.
Update on 2018-02-15:
OpenCV 3.4.0 wheel files are now available in the unofficial site and replaced OpenCV 3.3.0.
Update on 2018-06-19:
OpenCV 3.4.1 wheel files are now available in the unofficial site with CPython 3.5/3.6/3.7 support, and replaced OpenCV 3.4.0.
Update on 2018-10-03:
OpenCV 3.4.3 wheel files are now available in the unofficial site with CPython 3.5/3.6/3.7 support, and replaced OpenCV 3.4.1.
Update on 2019-01-30:
OpenCV 4.0.1 wheel files are now available in the unofficial site with CPython 3.5/3.6/3.7 support.
Update on 2019-06-10:
OpenCV 3.4.6 and OpenCV 4.1.0 wheel files are now available in the unofficial site with CPython 3.5/3.6/3.7 support.
src : https://stackoverflow.com/a/43190144/13319197

pyinstaller not working with several warnings and errors

I am trying to turn my script into .exe file. When I use Pyinstaller I get several warnings and errors and it does not work:
193691 WARNING: Unable to find package for requirement greenlet from package gevent. 193691 WARNING: Unable to find package for requirement zope.event from package gevent. 193691 WARNING: Unable to find package for requirement zope.interface from package gevent.
I installed gevent package but these warnings still appear
2)\anaconda3\lib\site-packages\numpy\__init__.py:138: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
I installed mkl-service package but this message still appears
3)ImportError: DLL load failed while importing _multiarray_umath: The module is not found.
I am using Anaconda navigator and I dont have any additional virtual environment. I have numpy 1.19.2 and Python3.8.
Finally I get PyInstaller.exceptions.ImportErrorWhenRunningHook: Failed to import module __PyInstaller_hooks_0_numpy_core required by hook for module anaconda3\lib\site-packages\PyInstaller\hooks\hook-numpy.core.py. Please check whether module __PyInstaller_hooks_0_numpy_core actually exists and whether the hook is compatible with your version of \anaconda3\lib\site-packages\PyInstaller\hooks\hook-numpy.core.py:
I tried uninstalling anaconda and numpy and reinstalling it. I tried checking Path environment variable. all with no luck.

Matplotlib pylab savefig runtime error in python 3.2.3

I am trying to test whether matplotlib installed properly in python3. I am following this basic tutorial: http://www.scipy.org/Plotting_Tutorial
This question is similar to one asked previously but unfortunately did not report the final solution explicitly and this is a different operating system.
The operating system for this is Mac OS X 10.6.8. Running the script in Python 3.2 does not work, but running it in Python 2.7 does. Unfortunately I need 3.2.
When the savefig line is commented out, it works fine.
"""
Example: simple line plot.
Show how to make and save a simple line plot with labels, title and grid
"""
import numpy
import pylab
t = numpy.arange(0.0, 1.0+0.01, 0.01)
s = numpy.cos(2*2*numpy.pi*t)
pylab.plot(t, s)
pylab.xlabel('time (s)')
pylab.ylabel('voltage (mV)')
pylab.title('About as simple as it gets, folks')
pylab.grid(True)
pylab.savefig('/Users/USERNAME/Documents/simple_plot.png', format='png')
pylab.show()
The code above returned the same error regardless of whether the path was set explicitly. I tried the following in addition to the above:
pylab.savefig('simple_plot.png', format='png')
pylab.savefig('simple_plot')
I tried setting the path explicitly as the other question said (as in the longer example above), but that resulted in the following errors. Note: mplex.py is the name of the script.
libpng warning: Application was compiled with png.h from libpng-1.2.44
libpng warning: Application is running with png.c from libpng-1.4.11
libpng warning: Incompatible libpng version in application and library
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "mplex.py", line 16, in <module>
pylab.savefig('/Users/USERNAME/Documents/simple_plot.png', format='png')
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/matplotlib/pyplot.py", line 474, in savefig
return fig.savefig(*args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/matplotlib/figure.py", line 1225, in savefig
self.canvas.print_figure(*args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/matplotlib/backend_bases.py", line 2075, in print_figure
**kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/matplotlib/backend_bases.py", line 1846, in print_png
return agg.print_png(*args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/matplotlib/backends/backend_agg.py", line 497, in print_png
filename_or_obj, self.figure.dpi)
RuntimeError: Could not create write struct
Ideas? Is there another way to explicitly set the destination aside from what I tried in the savefig line?
I'm not sure what package manager you're using, and I'm on Python 2.7 (not 3.2.3), but I'm using Fink and had a similar problem (with different libpng version numbers).
In iPython --pylab, I was seeing this:
In [3]: savefig('foo.png')
libpng warning: Application is running with png.c from libpng-1.4.11
libpng warning: Incompatible libpng version in application and library
libpng warning: Application was compiled with png.h from libpng-1.5.11
Checking my Fink installations of libpng, I saw this:
$ fink list libpng
Information about 6268 packages read in 0 seconds.
i libpng14 1.4.11-1 PNG image format handling library
i libpng14-shlibs 1.4.11-1 Shared libraries for libpng14 package
libpng15 1.5.10-1 PNG image format handling library
libpng15-32bit 1.5.10-1 PNG library (32-bit)
libpng15-32bit-shli 1.5.10-1 Shared libraries for libpng15 package
i libpng15-shlibs 1.5.10-1 Shared libraries for libpng15 package
libpng3 1:1.2.49-1 PNG image format handling library
libpng3-shlibs 1:1.2.49-1 Shared libraries for libpng3 package
i system-pkgconfig-li 1.5.11-1 [virtual pkgconfig package representing libpng]
i system-pkgconfig-li 1.5.11-1 [virtual pkgconfig package representing libpng15]
After running "fink install libpng15", my libpng package versions looked like this:
$ fink list libpng
Information about 6268 packages read in 1 seconds.
libpng14 1.4.11-1 PNG image format handling library
i libpng14-shlibs 1.4.11-1 Shared libraries for libpng14 package
i libpng15 1.5.10-1 PNG image format handling library
libpng15-32bit 1.5.10-1 PNG library (32-bit)
libpng15-32bit-shli 1.5.10-1 Shared libraries for libpng15 package
i libpng15-shlibs 1.5.10-1 Shared libraries for libpng15 package
libpng3 1:1.2.49-1 PNG image format handling library
libpng3-shlibs 1:1.2.49-1 Shared libraries for libpng3 package
i system-pkgconfig-li 1.5.11-1 [virtual pkgconfig package representing libpng]
i system-pkgconfig-li 1.5.11-1 [virtual pkgconfig package representing libpng15]
As you can see, libpng14 is no longer installed and libpng15 is installed.
Next, "pip uninstall matplotlib" and "pip install matplotlib" yields a matplotlib build summary like this:
$ pip install matplotlib
Downloading/unpacking matplotlib
Downloading matplotlib-1.2.0.tar.gz (36.9Mb): 36.9Mb downloaded
Running setup.py egg_info for package matplotlib
basedirlist is: ['/usr/local/', '/usr', '/usr/X11', '/opt/local']
============================================================================
BUILDING MATPLOTLIB
matplotlib: 1.2.0
python: 2.7.3 (default, Jul 27 2012, 16:40:57) [GCC 4.2.1
Compatible Apple Clang 3.1
(tags/Apple/clang-318.0.61)]
platform: darwin
REQUIRED DEPENDENCIES
numpy: 1.6.2
freetype2: 15.0.9
OPTIONAL BACKEND DEPENDENCIES
libpng: 1.5.10
Tkinter: Tkinter: 81008, Tk: 8.5, Tcl: 8.5
Gtk+: no
* Building for Gtk+ requires pygtk; you must be able
* to "import gtk" in your build/install environment
Mac OS X native: yes
Qt: no
Qt4: no
PySide: no
Cairo: no
OPTIONAL DATE/TIMEZONE DEPENDENCIES
dateutil: 1.5
pytz: 2012b
OPTIONAL USETEX DEPENDENCIES
dvipng: no
ghostscript: 9.05
latex: no
You can see that the build will now pick up libpng 1.5.10. Previously, it was picking up 1.4.11 for the build.
Avoid using the standard console and the error will not appear by double clicking the yourcode.py or yourcode.pyw file.

Resources