ViLT(Vision-and-Language Transformer)是一种多模态AI模型,可以给出图片的文字描述,最近阅读学习相关论文(https://paperswithcode.com/paper/vilt-vision-and-language-transformer-without)的过程中,尝试在本地部署ViLT,经历一系列波折,终于成功部署,现回顾踩坑过程。
坑一:Python版本不匹配
我创建conda环境默认选择的是python3.11,这导致我在运行pip install -r requirements.txt
时会与一些库版本不匹配,于是我创建了python3.8的conda环境。
具体可参考如下报错:
(ViLT) E:\github\ViLT-master>pip install -r requirements.txt
Collecting git+https://github.com/rwightman/pytorch-image-models.git (from -r requirements.txt (line 11))
Cloning https://github.com/rwightman/pytorch-image-models.git to c:\users\asus\appdata\local\temp\pip-req-build-ncduowrs
Running command git clone --filter=blob:none --quiet https://github.com/rwightman/pytorch-image-models.git 'C:\Users\Asus\AppData\Local\Temp\pip-req-build-ncduowrs'
Resolved https://github.com/rwightman/pytorch-image-models.git to commit f2fdd97e9f859285363c05988820c9350b737e59
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting pytorch_lightning==1.1.4 (from -r requirements.txt (line 1))
Using cached pytorch_lightning-1.1.4-py3-none-any.whl (684 kB)
Collecting transformers==4.2.1 (from -r requirements.txt (line 2))
Using cached transformers-4.2.1-py3-none-any.whl (1.8 MB)
Collecting Pillow==8.2.0 (from -r requirements.txt (line 3))
Using cached Pillow-8.2.0.tar.gz (47.9 MB)
Preparing metadata (setup.py) ... done
Collecting tqdm==4.56.0 (from -r requirements.txt (line 4))
Using cached tqdm-4.56.0-py2.py3-none-any.whl (72 kB)
Collecting ipdb==0.13.4 (from -r requirements.txt (line 5))
Using cached ipdb-0.13.4.tar.gz (15 kB)
Preparing metadata (setup.py) ... done
Collecting numpy==1.19.5 (from -r requirements.txt (line 6))
Using cached numpy-1.19.5.zip (7.3 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [290 lines of output]
setup.py:67: RuntimeWarning: NumPy 1.19.5 may not yet support Python 3.11.
warnings.warn(
Running from numpy source directory.
setup.py:480: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
run_build = parse_setuppy_commands()
Processing numpy/random\_bounded_integers.pxd.in
Processing numpy/random\bit_generator.pyx
Processing numpy/random\mtrand.pyx
Processing numpy/random\_bounded_integers.pyx.in
Processing numpy/random\_common.pyx
Processing numpy/random\_generator.pyx
Processing numpy/random\_mt19937.pyx
Processing numpy/random\_pcg64.pyx
Processing numpy/random\_philox.pyx
Processing numpy/random\_sfc64.pyx
Cythonizing sources
blas_opt_info:
blas_mkl_info:
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries mkl_rt not found in ['C:\\Users\\Asus\\.conda\\envs\\ViLT\\lib', 'C:\\', 'C:\\Users\\Asus\\.conda\\envs\\ViLT\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
NOT AVAILABLE
blis_info:
libraries blis not found in ['C:\\Users\\Asus\\.conda\\envs\\ViLT\\lib', 'C:\\', 'C:\\Users\\Asus\\.conda\\envs\\ViLT\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
NOT AVAILABLE
openblas_info:
libraries openblas not found in ['C:\\Users\\Asus\\.conda\\envs\\ViLT\\lib', 'C:\\', 'C:\\Users\\Asus\\.conda\\envs\\ViLT\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
get_default_fcompiler: matching types: '['gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95', 'intelvem', 'intelem', 'flang']'
customize GnuFCompiler
Could not locate executable g77
Could not locate executable f77
customize IntelVisualFCompiler
Could not locate executable ifort
Could not locate executable ifl
customize AbsoftFCompiler
Could not locate executable f90
customize CompaqVisualFCompiler
Could not locate executable DF
customize IntelItaniumVisualFCompiler
Could not locate executable efl
customize Gnu95FCompiler
Could not locate executable gfortran
Could not locate executable f95
customize G95FCompiler
Could not locate executable g95
customize IntelEM64VisualFCompiler
customize IntelEM64TFCompiler
Could not locate executable efort
Could not locate executable efc
customize PGroupFlangCompiler
Could not locate executable flang
don't know how to compile Fortran code on platform 'nt'
NOT AVAILABLE
atlas_3_10_blas_threads_info:
Setting PTATLAS=ATLAS
libraries tatlas not found in ['C:\\Users\\Asus\\.conda\\envs\\ViLT\\lib', 'C:\\', 'C:\\Users\\Asus\\.conda\\envs\\ViLT\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
NOT AVAILABLE
atlas_3_10_blas_info:
libraries satlas not found in ['C:\\Users\\Asus\\.conda\\envs\\ViLT\\lib', 'C:\\', 'C:\\Users\\Asus\\.conda\\envs\\ViLT\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
NOT AVAILABLE
atlas_blas_threads_info:
Setting PTATLAS=ATLAS
libraries ptf77blas,ptcblas,atlas not found in ['C:\\Users\\Asus\\.conda\\envs\\ViLT\\lib', 'C:\\', 'C:\\Users\\Asus\\.conda\\envs\\ViLT\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
NOT AVAILABLE
atlas_blas_info:
libraries f77blas,cblas,atlas not found in ['C:\\Users\\Asus\\.conda\\envs\\ViLT\\lib', 'C:\\', 'C:\\Users\\Asus\\.conda\\envs\\ViLT\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
NOT AVAILABLE
accelerate_info:
NOT AVAILABLE
C:\Users\Asus\AppData\Local\Temp\pip-install-ohfv24u0\numpy_1bb2a5793e1047f4b642d681e5fdbb46\numpy\distutils\system_info.py:1914: UserWarning:
Optimized (vendor) Blas libraries are not found.
Falls back to netlib Blas library which has worse performance.
A better performance should be easily gained by switching
Blas library.
if self._calc_info(blas):
blas_info:
libraries blas not found in ['C:\\Users\\Asus\\.conda\\envs\\ViLT\\lib', 'C:\\', 'C:\\Users\\Asus\\.conda\\envs\\ViLT\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
NOT AVAILABLE
C:\Users\Asus\AppData\Local\Temp\pip-install-ohfv24u0\numpy_1bb2a5793e1047f4b642d681e5fdbb46\numpy\distutils\system_info.py:1914: UserWarning:
Blas (http://www.netlib.org/blas/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [blas]) or by setting
the BLAS environment variable.
if self._calc_info(blas):
blas_src_info:
NOT AVAILABLE
C:\Users\Asus\AppData\Local\Temp\pip-install-ohfv24u0\numpy_1bb2a5793e1047f4b642d681e5fdbb46\numpy\distutils\system_info.py:1914: UserWarning:
Blas (http://www.netlib.org/blas/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [blas_src]) or by setting
the BLAS_SRC environment variable.
if self._calc_info(blas):
NOT AVAILABLE
non-existing path in 'numpy\\distutils': 'site.cfg'
lapack_opt_info:
lapack_mkl_info:
libraries mkl_rt not found in ['C:\\Users\\Asus\\.conda\\envs\\ViLT\\lib', 'C:\\', 'C:\\Users\\Asus\\.conda\\envs\\ViLT\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
NOT AVAILABLE
openblas_lapack_info:
libraries openblas not found in ['C:\\Users\\Asus\\.conda\\envs\\ViLT\\lib', 'C:\\', 'C:\\Users\\Asus\\.conda\\envs\\ViLT\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
NOT AVAILABLE
openblas_clapack_info:
libraries openblas,lapack not found in ['C:\\Users\\Asus\\.conda\\envs\\ViLT\\lib', 'C:\\', 'C:\\Users\\Asus\\.conda\\envs\\ViLT\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
NOT AVAILABLE
flame_info:
libraries flame not found in ['C:\\Users\\Asus\\.conda\\envs\\ViLT\\lib', 'C:\\', 'C:\\Users\\Asus\\.conda\\envs\\ViLT\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
NOT AVAILABLE
atlas_3_10_threads_info:
Setting PTATLAS=ATLAS
libraries lapack_atlas not found in C:\Users\Asus\.conda\envs\ViLT\lib
libraries tatlas,tatlas not found in C:\Users\Asus\.conda\envs\ViLT\lib
libraries lapack_atlas not found in C:\
libraries tatlas,tatlas not found in C:\
libraries lapack_atlas not found in C:\Users\Asus\.conda\envs\ViLT\libs
libraries tatlas,tatlas not found in C:\Users\Asus\.conda\envs\ViLT\libs
libraries lapack_atlas not found in C:\ProgramData\anaconda3\Library\lib
libraries tatlas,tatlas not found in C:\ProgramData\anaconda3\Library\lib
<class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
NOT AVAILABLE
atlas_3_10_info:
libraries lapack_atlas not found in C:\Users\Asus\.conda\envs\ViLT\lib
libraries satlas,satlas not found in C:\Users\Asus\.conda\envs\ViLT\lib
libraries lapack_atlas not found in C:\
libraries satlas,satlas not found in C:\
libraries lapack_atlas not found in C:\Users\Asus\.conda\envs\ViLT\libs
libraries satlas,satlas not found in C:\Users\Asus\.conda\envs\ViLT\libs
libraries lapack_atlas not found in C:\ProgramData\anaconda3\Library\lib
libraries satlas,satlas not found in C:\ProgramData\anaconda3\Library\lib
<class 'numpy.distutils.system_info.atlas_3_10_info'>
NOT AVAILABLE
atlas_threads_info:
Setting PTATLAS=ATLAS
libraries lapack_atlas not found in C:\Users\Asus\.conda\envs\ViLT\lib
libraries ptf77blas,ptcblas,atlas not found in C:\Users\Asus\.conda\envs\ViLT\lib
libraries lapack_atlas not found in C:\
libraries ptf77blas,ptcblas,atlas not found in C:\
libraries lapack_atlas not found in C:\Users\Asus\.conda\envs\ViLT\libs
libraries ptf77blas,ptcblas,atlas not found in C:\Users\Asus\.conda\envs\ViLT\libs
libraries lapack_atlas not found in C:\ProgramData\anaconda3\Library\lib
libraries ptf77blas,ptcblas,atlas not found in C:\ProgramData\anaconda3\Library\lib
<class 'numpy.distutils.system_info.atlas_threads_info'>
NOT AVAILABLE
atlas_info:
libraries lapack_atlas not found in C:\Users\Asus\.conda\envs\ViLT\lib
libraries f77blas,cblas,atlas not found in C:\Users\Asus\.conda\envs\ViLT\lib
libraries lapack_atlas not found in C:\
libraries f77blas,cblas,atlas not found in C:\
libraries lapack_atlas not found in C:\Users\Asus\.conda\envs\ViLT\libs
libraries f77blas,cblas,atlas not found in C:\Users\Asus\.conda\envs\ViLT\libs
libraries lapack_atlas not found in C:\ProgramData\anaconda3\Library\lib
libraries f77blas,cblas,atlas not found in C:\ProgramData\anaconda3\Library\lib
<class 'numpy.distutils.system_info.atlas_info'>
NOT AVAILABLE
lapack_info:
libraries lapack not found in ['C:\\Users\\Asus\\.conda\\envs\\ViLT\\lib', 'C:\\', 'C:\\Users\\Asus\\.conda\\envs\\ViLT\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
NOT AVAILABLE
C:\Users\Asus\AppData\Local\Temp\pip-install-ohfv24u0\numpy_1bb2a5793e1047f4b642d681e5fdbb46\numpy\distutils\system_info.py:1748: UserWarning:
Lapack (http://www.netlib.org/lapack/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [lapack]) or by setting
the LAPACK environment variable.
return getattr(self, '_calc_info_{}'.format(name))()
lapack_src_info:
NOT AVAILABLE
C:\Users\Asus\AppData\Local\Temp\pip-install-ohfv24u0\numpy_1bb2a5793e1047f4b642d681e5fdbb46\numpy\distutils\system_info.py:1748: UserWarning:
Lapack (http://www.netlib.org/lapack/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [lapack_src]) or by setting
the LAPACK_SRC environment variable.
return getattr(self, '_calc_info_{}'.format(name))()
NOT AVAILABLE
numpy_linalg_lapack_lite:
FOUND:
language = c
define_macros = [('HAVE_BLAS_ILP64', None), ('BLAS_SYMBOL_SUFFIX', '64_')]
C:\Users\Asus\AppData\Local\Temp\pip-build-env-coj1ts0k\overlay\Lib\site-packages\setuptools\_distutils\dist.py:275: UserWarning: Unknown distribution option: 'define_macros'
warnings.warn(msg)
running dist_info
running build_src
build_src
building py_modules sources
creating build
creating build\src.win-amd64-3.11
creating build\src.win-amd64-3.11\numpy
creating build\src.win-amd64-3.11\numpy\distutils
building library "npymath" sources
Traceback (most recent call last):
File "C:\Users\Asus\.conda\envs\ViLT\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
main()
File "C:\Users\Asus\.conda\envs\ViLT\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Asus\.conda\envs\ViLT\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 149, in prepare_metadata_for_build_wheel
return hook(metadata_directory, config_settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Asus\AppData\Local\Temp\pip-build-env-coj1ts0k\overlay\Lib\site-packages\setuptools\build_meta.py", line 157, in prepare_metadata_for_build_wheel
self.run_setup()
File "C:\Users\Asus\AppData\Local\Temp\pip-build-env-coj1ts0k\overlay\Lib\site-packages\setuptools\build_meta.py", line 249, in run_setup
self).run_setup(setup_script=setup_script)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Asus\AppData\Local\Temp\pip-build-env-coj1ts0k\overlay\Lib\site-packages\setuptools\build_meta.py", line 142, in run_setup
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 508, in <module>
setup_package()
File "setup.py", line 500, in setup_package
setup(**metadata)
File "C:\Users\Asus\AppData\Local\Temp\pip-install-ohfv24u0\numpy_1bb2a5793e1047f4b642d681e5fdbb46\numpy\distutils\core.py", line 169, in setup
return old_setup(**new_attr)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Asus\AppData\Local\Temp\pip-build-env-coj1ts0k\overlay\Lib\site-packages\setuptools\__init__.py", line 165, in setup
return distutils.core.setup(**attrs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Asus\AppData\Local\Temp\pip-build-env-coj1ts0k\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\Asus\AppData\Local\Temp\pip-build-env-coj1ts0k\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 967, in run_commands
self.run_command(cmd)
File "C:\Users\Asus\AppData\Local\Temp\pip-build-env-coj1ts0k\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
cmd_obj.run()
File "C:\Users\Asus\AppData\Local\Temp\pip-build-env-coj1ts0k\overlay\Lib\site-packages\setuptools\command\dist_info.py", line 31, in run
egg_info.run()
File "C:\Users\Asus\AppData\Local\Temp\pip-install-ohfv24u0\numpy_1bb2a5793e1047f4b642d681e5fdbb46\numpy\distutils\command\egg_info.py", line 24, in run
self.run_command("build_src")
File "C:\Users\Asus\AppData\Local\Temp\pip-build-env-coj1ts0k\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\Asus\AppData\Local\Temp\pip-build-env-coj1ts0k\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
cmd_obj.run()
File "C:\Users\Asus\AppData\Local\Temp\pip-install-ohfv24u0\numpy_1bb2a5793e1047f4b642d681e5fdbb46\numpy\distutils\command\build_src.py", line 144, in run
self.build_sources()
File "C:\Users\Asus\AppData\Local\Temp\pip-install-ohfv24u0\numpy_1bb2a5793e1047f4b642d681e5fdbb46\numpy\distutils\command\build_src.py", line 155, in build_sources
self.build_library_sources(*libname_info)
File "C:\Users\Asus\AppData\Local\Temp\pip-install-ohfv24u0\numpy_1bb2a5793e1047f4b642d681e5fdbb46\numpy\distutils\command\build_src.py", line 288, in build_library_sources
sources = self.generate_sources(sources, (lib_name, build_info))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Asus\AppData\Local\Temp\pip-install-ohfv24u0\numpy_1bb2a5793e1047f4b642d681e5fdbb46\numpy\distutils\command\build_src.py", line 378, in generate_sources
source = func(extension, build_dir)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "numpy\core\setup.py", line 658, in get_mathlib_info
st = config_cmd.try_link('int main(void) { return 0;}')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Asus\AppData\Local\Temp\pip-build-env-coj1ts0k\overlay\Lib\site-packages\setuptools\_distutils\command\config.py", line 243, in try_link
self._link(body, headers, include_dirs,
File "C:\Users\Asus\AppData\Local\Temp\pip-install-ohfv24u0\numpy_1bb2a5793e1047f4b642d681e5fdbb46\numpy\distutils\command\config.py", line 162, in _link
return self._wrap_method(old_config._link, lang,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Asus\AppData\Local\Temp\pip-install-ohfv24u0\numpy_1bb2a5793e1047f4b642d681e5fdbb46\numpy\distutils\command\config.py", line 96, in _wrap_method
ret = mth(*((self,)+args))
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Asus\AppData\Local\Temp\pip-build-env-coj1ts0k\overlay\Lib\site-packages\setuptools\_distutils\command\config.py", line 137, in _link
(src, obj) = self._compile(body, headers, include_dirs, lang)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Asus\AppData\Local\Temp\pip-install-ohfv24u0\numpy_1bb2a5793e1047f4b642d681e5fdbb46\numpy\distutils\command\config.py", line 105, in _compile
src, obj = self._wrap_method(old_config._compile, lang,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Asus\AppData\Local\Temp\pip-install-ohfv24u0\numpy_1bb2a5793e1047f4b642d681e5fdbb46\numpy\distutils\command\config.py", line 96, in _wrap_method
ret = mth(*((self,)+args))
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Asus\AppData\Local\Temp\pip-build-env-coj1ts0k\overlay\Lib\site-packages\setuptools\_distutils\command\config.py", line 132, in _compile
self.compiler.compile([src], include_dirs=include_dirs)
File "C:\Users\Asus\AppData\Local\Temp\pip-build-env-coj1ts0k\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 401, in compile
self.spawn(args)
File "C:\Users\Asus\AppData\Local\Temp\pip-build-env-coj1ts0k\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 505, in spawn
return super().spawn(cmd, env=env)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Asus\AppData\Local\Temp\pip-install-ohfv24u0\numpy_1bb2a5793e1047f4b642d681e5fdbb46\numpy\distutils\ccompiler.py", line 90, in <lambda>
m = lambda self, *args, **kw: func(self, *args, **kw)
^^^^^^^^^^^^^^^^^^^^^^^
TypeError: CCompiler_spawn() got an unexpected keyword argument 'env'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
坑二:没有下载vilt模型
vilt的github页面(https://github.com/dandelin/vilt)给出的仅仅是运行模型的前端代码,“vilt_200k_mlm_itm.ckpt”大约有1.5G,需要专门下载!
坑三:gradio版本过老
我参考 README.md 的提示,运行了pip install gradio==1.6.4
,正常来说,用作者建议的python库版本应该是可行的,但是本地运行python demo.py with num_gpus=0 load_path="vilt_200k_mlm_itm.ckpt"
确实会出现一些莫名其妙的报错(远程主机强迫关闭了一 个现有的连接?)
INFO - ViLT - Running command 'main'
INFO - ViLT - Started
IMPORTANT: You are using gradio version 1.6.4, however version 3.14.0 is available, please upgrade.
--------
This share link will expire in 24 hours. If you need a permanent link, visit: https://gradio.app/introducing-hosted (NEW!)
ERROR - paramiko.transport - Exception (client): Error reading SSH protocol banner[WinError 10054] 远程主机强迫关闭了一 个现有的连接。
ERROR - paramiko.transport - Traceback (most recent call last):
ERROR - paramiko.transport - File "C:\Users\Asus\.conda\envs\test_python38\lib\site-packages\paramiko\transport.py", line 2327, in _check_banner
ERROR - paramiko.transport - buf = self.packetizer.readline(timeout)
ERROR - paramiko.transport - File "C:\Users\Asus\.conda\envs\test_python38\lib\site-packages\paramiko\packet.py", line 381, in readline
ERROR - paramiko.transport - buf += self._read_timeout(timeout)
ERROR - paramiko.transport - File "C:\Users\Asus\.conda\envs\test_python38\lib\site-packages\paramiko\packet.py", line 616, in _read_timeout
ERROR - paramiko.transport - x = self.__socket.recv(128)
ERROR - paramiko.transport - ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。
ERROR - paramiko.transport -
ERROR - paramiko.transport - During handling of the above exception, another exception occurred:
ERROR - paramiko.transport -
ERROR - paramiko.transport - Traceback (most recent call last):
ERROR - paramiko.transport - File "C:\Users\Asus\.conda\envs\test_python38\lib\site-packages\paramiko\transport.py", line 2143, in run
ERROR - paramiko.transport - self._check_banner()
ERROR - paramiko.transport - File "C:\Users\Asus\.conda\envs\test_python38\lib\site-packages\paramiko\transport.py", line 2331, in _check_banner
ERROR - paramiko.transport - raise SSHException(
ERROR - paramiko.transport - paramiko.ssh_exception.SSHException: Error reading SSH protocol banner[WinError 10054] 远程主机强迫关闭了一个现有的连接。
当我更换网络连接后,又出现另一个莫名其妙的报错(MissingSchema: Invalid URL 'None': No scheme supplied.):
INFO - ViLT - Running command 'main'
INFO - ViLT - Started
IMPORTANT: You are using gradio version 1.6.4, however version 3.14.0 is available, please upgrade.
--------
This share link will expire in 24 hours. If you need a permanent link, visit: https://gradio.app/introducing-hosted (NEW!)
Interface loading below...
ERROR - ViLT - Failed after 0:00:44!
Traceback (most recent call last):
File "C:\Users\Asus\.conda\envs\test_python38\lib\site-packages\sacred\experiment.py", line 312, in run_commandline
return self.run(
File "C:\Users\Asus\.conda\envs\test_python38\lib\site-packages\sacred\experiment.py", line 276, in run
run()
File "C:\Users\Asus\.conda\envs\test_python38\lib\site-packages\sacred\run.py", line 238, in __call__
self.result = self.main_function(*args)
File "C:\Users\Asus\.conda\envs\test_python38\lib\site-packages\sacred\config\captured_function.py", line 42, in captured_function
result = wrapped(*args, **kwargs)
File "demo.py", line 233, in main
interface.launch(debug=True)
File "C:\Users\Asus\.conda\envs\test_python38\lib\site-packages\gradio\interface.py", line 443, in launch
while not networking.url_ok(share_url):
File "C:\Users\Asus\.conda\envs\test_python38\lib\site-packages\gradio\networking.py", line 325, in url_ok
r = requests.head(url, timeout=3)
File "C:\Users\Asus\.conda\envs\test_python38\lib\site-packages\requests\api.py", line 100, in head
return request("head", url, **kwargs)
File "C:\Users\Asus\.conda\envs\test_python38\lib\site-packages\requests\api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\Asus\.conda\envs\test_python38\lib\site-packages\requests\sessions.py", line 575, in request
prep = self.prepare_request(req)
File "C:\Users\Asus\.conda\envs\test_python38\lib\site-packages\requests\sessions.py", line 486, in prepare_request
p.prepare(
File "C:\Users\Asus\.conda\envs\test_python38\lib\site-packages\requests\models.py", line 368, in prepare
self.prepare_url(url, params)
File "C:\Users\Asus\.conda\envs\test_python38\lib\site-packages\requests\models.py", line 439, in prepare_url
raise MissingSchema(
requests.exceptions.MissingSchema: Invalid URL 'None': No scheme supplied. Perhaps you meant https://None?
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "demo.py", line 23, in <module>
def main(_config):
File "C:\Users\Asus\.conda\envs\test_python38\lib\site-packages\sacred\experiment.py", line 190, in automain
self.run_commandline()
File "C:\Users\Asus\.conda\envs\test_python38\lib\site-packages\sacred\experiment.py", line 347, in run_commandline
print_filtered_stacktrace()
File "C:\Users\Asus\.conda\envs\test_python38\lib\site-packages\sacred\utils.py", line 493, in print_filtered_stacktrace
print(format_filtered_stacktrace(filter_traceback), file=sys.stderr)
File "C:\Users\Asus\.conda\envs\test_python38\lib\site-packages\sacred\utils.py", line 528, in format_filtered_stacktrace
return "".join(filtered_traceback_format(tb_exception))
File "C:\Users\Asus\.conda\envs\test_python38\lib\site-packages\sacred\utils.py", line 568, in filtered_traceback_format
current_tb = tb_exception.exc_traceback
AttributeError: 'TracebackException' object has no attribute 'exc_traceback'
If you suspect this is an IPython 8.12.3 bug, please report it at:
https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@python.org
You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.
Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
%config Application.verbose_crash=True
于是,我参考ChatGPT的建议,更新我的gradio为最新版本(大家在配环境时不要一开始就用最新版本,先严格按照文档的提示配置,能直接配好最好!)
坑四:gradio的接口调整
新版的gradio接口有所调整,需要专门修改demo.py中的相关代码
我首先运行了pip install --upgrade gradio
来更新我的gradio,当我再次跑模型时会出现如下报错:
AttributeError: module 'gradio' has no attribute 'inputs'
根据ChatGPT的解释,gradio对相关接口进行了调整,于是我不得不修改demo.py的代码:
"""
inputs = [
gr.inputs.Textbox(
label="Url of an image.",
lines=5,
),
gr.inputs.Textbox(label="Caption with [MASK] tokens to be filled.", lines=5),
gr.inputs.Slider(
minimum=0,
maximum=38,
step=1,
label="Index of token for heatmap visualization (ignored if zero)",
),
]
"""
inputs = [
gr.components.Textbox(
label="Url of an image.",
lines=5,
),
gr.components.Textbox(label="Caption with [MASK] tokens to be filled.", lines=5),
gr.components.Slider(
minimum=0,
maximum=38,
step=1,
label="Index of token for heatmap visualization (ignored if zero)",
),
]
"""
outputs = [
gr.outputs.Image(label="Image"),
gr.outputs.Textbox(label="description"),
gr.outputs.Textbox(label="selected token"),
]
"""
outputs = [
gr.components.Image(label="Image"),
gr.components.Textbox(label="Description"),
gr.components.Textbox(label="Selected Token")
]
经过如上一番折腾后,再次运行
python demo.py with num_gpus=0 load_path="vilt_200k_mlm_itm.ckpt"
终于,模型可以在本地正常运行了: