如何从tar.bz2源代码安装pytorch for cpu with conda?

xe55xuns  于 2023-03-23  发布在  其他
关注(0)|答案(1)|浏览(148)

我知道有很多与pytorch安装相关的问题。到目前为止,没有一个结合了我所有的要求,他们的解决方案在这种情况下不起作用:
我需要在一个无法访问互联网的孤立Windows环境中安装torch。理想情况下,解决方案将使用conda(或mambamicromamba)。到目前为止,我在anaconda.org上下载了源代码后尝试使用conda install --offline package_name.tar.bz2
以下是一个可重复的失败尝试:

> conda create -n last_test
> conda activate last_test
> conda install -y python==3.10
> conda install -y --offline pytorch-1.13.1-py3.10_cpu_0.tar.bz2 torchvision-0.14.1-py310_cpu.tar.bz2 cpuonly-2.0-0.tar.bz2
> conda -V
conda 22.9.0
> python -V
3.10.0
> python -c "import torch;"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\$user\AppData\Local\mambaforge\envs\pytorch_test\lib\site-packages\torch\__init__.py", line 139, in <module>
    raise err
OSError: [WinError 126] Can't find specified module. Error loading "C:\Users\$user\AppData\Local\mambaforge\envs\pytorch_test\lib\site-packages\torch\lib\shm.dll" or one of its dependencies.
8ljdwjyq

8ljdwjyq1#

对于那些谁可能在这个问题上绊倒在未来。

**TL;DR:**只需从wheel文件测试pip安装。您可以在www.example.com上找到这些文件https://pypi.org/project/torch/#files。

> mamba create -n myenv
> conda activate myenv
> mamba install -y python==3.10 numpy matplotlib
> pip install -v torch-2.0.0-cp310-cp310-win_amd64.whl
> pip -V
> python -V
> python -c "import torch; print('torch ok')"
torch ok

cudavscpu没有区别:这里torch version 2.0.0 for python version3.10.0 torch-2.0.0-cp310-cp310-win_amd64.whl似乎可以做到这一点:

> import torch
> torch.rand(10)
tensor([0.2073, 0.0535, 0.7752, 0.9340, 0.6420, 0.8352, 0.9674, 0.3964, 0.6906,
        0.5436])

错误可能原因:文件(某些DLL)丢失。此问题可能与以下问题有关:

  • anaconda.org为某些版本的torch提供Windows DLL文件的方式(我尝试了depends.exe工具,确实有一些丢失的DLL)
  • torch如何发现系统上DLL文件

注意:一些使用Anaconda的人在So上发布了重新安装Anaconda的技巧;其他使用torch的GPU版本通过删除损坏的DLL文件解决了这个问题。
要重现最终环境myenv,您可以用途:

conda create -n myenv -f env.yml

env.yml

dependencies:
  - anyio=3.6.2=pyhd8ed1ab_0
  - argon2-cffi=21.3.0=pyhd8ed1ab_0
  - argon2-cffi-bindings=21.2.0=py310h8d17308_3
  - asttokens=2.2.1=pyhd8ed1ab_0
  - attrs=22.2.0=pyh71513ae_0
  - backcall=0.2.0=pyh9f0ad1d_0
  - backports=1.0=pyhd8ed1ab_3
  - backports.functools_lru_cache=1.6.4=pyhd8ed1ab_0
  - beautifulsoup4=4.11.2=pyha770c72_0
  - bleach=6.0.0=pyhd8ed1ab_0
  - brotli=1.0.9=hcfcfb64_8
  - brotli-bin=1.0.9=hcfcfb64_8
  - brotlipy=0.7.0=py310h8d17308_1005
  - bzip2=1.0.8=h8ffe710_4
  - ca-certificates=2022.12.7=h5b45459_0
  - certifi=2022.12.7=pyhd8ed1ab_0
  - cffi=1.15.1=py310h628cb3f_3
  - charset-normalizer=2.1.1=pyhd8ed1ab_0
  - colorama=0.4.6=pyhd8ed1ab_0
  - comm=0.1.2=pyhd8ed1ab_0
  - contourpy=1.0.7=py310h232114e_0
  - cryptography=39.0.2=py310h6e82f81_0
  - cycler=0.11.0=pyhd8ed1ab_0
  - debugpy=1.6.6=py310h00ffb61_0
  - decorator=5.1.1=pyhd8ed1ab_0
  - defusedxml=0.7.1=pyhd8ed1ab_0
  - entrypoints=0.4=pyhd8ed1ab_0
  - executing=1.2.0=pyhd8ed1ab_0
  - flit-core=3.8.0=pyhd8ed1ab_0
  - fonttools=4.39.2=py310h8d17308_0
  - freetype=2.12.1=h546665d_1
  - gettext=0.21.1=h5728263_0
  - glib=2.74.1=h12be248_1
  - glib-tools=2.74.1=h12be248_1
  - gst-plugins-base=1.22.0=h001b923_2
  - gstreamer=1.22.0=h6b5321d_2
  - icu=70.1=h0e60522_0
  - idna=3.4=pyhd8ed1ab_0
  - importlib-metadata=6.1.0=pyha770c72_0
  - importlib_metadata=6.1.0=hd8ed1ab_0
  - importlib_resources=5.12.0=pyhd8ed1ab_0
  - intel-openmp=2023.0.0=h57928b3_25922
  - ipykernel=6.21.3=pyh025b116_0
  - ipython=8.11.0=pyh08f2357_0
  - ipython_genutils=0.2.0=py_1
  - ipywidgets=8.0.4=pyhd8ed1ab_0
  - jedi=0.18.2=pyhd8ed1ab_0
  - jinja2=3.1.2=pyhd8ed1ab_1
  - joblib=1.2.0=pyhd8ed1ab_0
  - jsonschema=4.17.3=pyhd8ed1ab_0
  - jupyter=1.0.0=py310h5588dad_8
  - jupyter_client=8.0.3=pyhd8ed1ab_0
  - jupyter_console=6.6.3=pyhd8ed1ab_0
  - jupyter_core=5.3.0=py310h5588dad_0
  - jupyter_events=0.6.3=pyhd8ed1ab_0
  - jupyter_server=2.5.0=pyhd8ed1ab_0
  - jupyter_server_terminals=0.4.4=pyhd8ed1ab_1
  - jupyterlab_pygments=0.2.2=pyhd8ed1ab_0
  - jupyterlab_widgets=3.0.5=pyhd8ed1ab_0
  - kiwisolver=1.4.4=py310h232114e_1
  - krb5=1.20.1=heb0366b_0
  - lcms2=2.15=h3e3b177_1
  - lerc=4.0.0=h63175ca_0
  - libblas=3.9.0=16_win64_mkl
  - libbrotlicommon=1.0.9=hcfcfb64_8
  - libbrotlidec=1.0.9=hcfcfb64_8
  - libbrotlienc=1.0.9=hcfcfb64_8
  - libcblas=3.9.0=16_win64_mkl
  - libclang=15.0.7=default_h77d9078_1
  - libclang13=15.0.7=default_h77d9078_1
  - libdeflate=1.17=hcfcfb64_0
  - libffi=3.4.2=h8ffe710_5
  - libglib=2.74.1=he8f3873_1
  - libhwloc=2.9.0=h51c2c0f_0
  - libiconv=1.17=h8ffe710_0
  - libjpeg-turbo=2.1.5.1=hcfcfb64_0
  - liblapack=3.9.0=16_win64_mkl
  - libogg=1.3.4=h8ffe710_1
  - libpng=1.6.39=h19919ed_0
  - libsodium=1.0.18=h8d14728_1
  - libsqlite=3.40.0=hcfcfb64_0
  - libtiff=4.5.0=hc3b8658_5
  - libvorbis=1.3.7=h0e60522_0
  - libwebp-base=1.3.0=hcfcfb64_0
  - libxcb=1.13=hcd874cb_1004
  - libxml2=2.10.3=hc3477c8_3
  - libzlib=1.2.13=hcfcfb64_4
  - m2w64-gcc-libgfortran=5.3.0=6
  - m2w64-gcc-libs=5.3.0=7
  - m2w64-gcc-libs-core=5.3.0=7
  - m2w64-gmp=6.1.0=2
  - m2w64-libwinpthread-git=5.0.0.4634.697f757=2
  - markupsafe=2.1.2=py310h8d17308_0
  - matplotlib=3.7.1=py310h5588dad_0
  - matplotlib-base=3.7.1=py310h51140c5_0
  - matplotlib-inline=0.1.6=pyhd8ed1ab_0
  - mistune=2.0.5=pyhd8ed1ab_0
  - mkl=2022.1.0=h6a75c08_874
  - msys2-conda-epoch=20160418=1
  - munkres=1.1.4=pyh9f0ad1d_0
  - nbclassic=0.5.3=pyhb4ecaf3_3
  - nbclient=0.7.2=pyhd8ed1ab_0
  - nbconvert=7.2.9=pyhd8ed1ab_0
  - nbconvert-core=7.2.9=pyhd8ed1ab_0
  - nbconvert-pandoc=7.2.9=pyhd8ed1ab_0
  - nbformat=5.7.3=pyhd8ed1ab_0
  - nest-asyncio=1.5.6=pyhd8ed1ab_0
  - notebook=6.5.3=pyha770c72_0
  - notebook-shim=0.2.2=pyhd8ed1ab_0
  - numpy=1.24.2=py310hd02465a_0
  - openjpeg=2.5.0=ha2aaf27_2
  - openssl=3.1.0=hcfcfb64_0
  - packaging=23.0=pyhd8ed1ab_0
  - pandas=1.5.3=py310h1c4a608_0
  - pandoc=3.1.1=h57928b3_0
  - pandocfilters=1.5.0=pyhd8ed1ab_0
  - parso=0.8.3=pyhd8ed1ab_0
  - pcre2=10.40=h17e33f8_0
  - pickleshare=0.7.5=py_1003
  - pillow=9.4.0=py310h3dcae36_2
  - pip=23.0.1=pyhd8ed1ab_0
  - pkgutil-resolve-name=1.3.10=pyhd8ed1ab_0
  - platformdirs=3.1.1=pyhd8ed1ab_0
  - ply=3.11=py_1
  - pooch=1.7.0=pyhd8ed1ab_0
  - prometheus_client=0.16.0=pyhd8ed1ab_0
  - prompt-toolkit=3.0.38=pyha770c72_0
  - prompt_toolkit=3.0.38=hd8ed1ab_0
  - psutil=5.9.4=py310h8d17308_0
  - pthread-stubs=0.4=hcd874cb_1001
  - pthreads-win32=2.9.1=hfa6e2cd_3
  - pure_eval=0.2.2=pyhd8ed1ab_0
  - pycparser=2.21=pyhd8ed1ab_0
  - pygments=2.14.0=pyhd8ed1ab_0
  - pyopenssl=23.0.0=pyhd8ed1ab_0
  - pyparsing=3.0.9=pyhd8ed1ab_0
  - pyqt=5.15.7=py310h1fd54f2_3
  - pyqt5-sip=12.11.0=py310h00ffb61_3
  - pyrsistent=0.19.3=py310h8d17308_0
  - pysocks=1.7.1=pyh0701188_6
  - python=3.10.0=hcf16a7b_3_cpython
  - python-dateutil=2.8.2=pyhd8ed1ab_0
  - python-fastjsonschema=2.16.3=pyhd8ed1ab_0
  - python-json-logger=2.0.7=pyhd8ed1ab_0
  - python_abi=3.10=3_cp310
  - pytz=2022.7.1=pyhd8ed1ab_0
  - pywin32=304=py310h00ffb61_2
  - pywinpty=2.0.10=py310h00ffb61_0
  - pyyaml=6.0=py310h8d17308_5
  - pyzmq=25.0.1=py310hcd737a0_0
  - qt-main=5.15.8=h88fe7eb_7
  - qtconsole=5.4.1=pyhd8ed1ab_0
  - qtconsole-base=5.4.1=pyha770c72_0
  - qtpy=2.3.0=pyhd8ed1ab_0
  - requests=2.28.2=pyhd8ed1ab_0
  - rfc3339-validator=0.1.4=pyhd8ed1ab_0
  - rfc3986-validator=0.1.1=pyh9f0ad1d_0
  - scikit-learn=1.2.2=py310had3394f_0
  - scipy=1.10.1=py310h578b7cb_0
  - send2trash=1.8.0=pyhd8ed1ab_0
  - setuptools=67.6.0=pyhd8ed1ab_0
  - sip=6.7.7=py310h00ffb61_0
  - six=1.16.0=pyh6c4a22f_0
  - sniffio=1.3.0=pyhd8ed1ab_0
  - soupsieve=2.3.2.post1=pyhd8ed1ab_0
  - sqlite=3.40.0=hcfcfb64_0
  - stack_data=0.6.2=pyhd8ed1ab_0
  - tbb=2021.8.0=h91493d7_0
  - terminado=0.17.0=pyh08f2357_0
  - threadpoolctl=3.1.0=pyh8a188c0_0
  - tinycss2=1.2.1=pyhd8ed1ab_0
  - tk=8.6.12=h8ffe710_0
  - toml=0.10.2=pyhd8ed1ab_0
  - tornado=6.2=py310h8d17308_1
  - traitlets=5.9.0=pyhd8ed1ab_0
  - typing-extensions=4.5.0=hd8ed1ab_0
  - typing_extensions=4.5.0=pyha770c72_0
  - tzdata=2022g=h191b570_0
  - ucrt=10.0.22621.0=h57928b3_0
  - unicodedata2=15.0.0=py310h8d17308_0
  - urllib3=1.26.15=pyhd8ed1ab_0
  - vc=14.3=hb6edc58_10
  - vs2015_runtime=14.34.31931=h4c5c07a_10
  - wcwidth=0.2.6=pyhd8ed1ab_0
  - webencodings=0.5.1=py_1
  - websocket-client=1.5.1=pyhd8ed1ab_0
  - wheel=0.40.0=pyhd8ed1ab_0
  - widgetsnbextension=4.0.5=pyhd8ed1ab_0
  - win_inet_pton=1.1.0=pyhd8ed1ab_6
  - winpty=0.4.3=4
  - xorg-libxau=1.0.9=hcd874cb_0
  - xorg-libxdmcp=1.1.3=hcd874cb_0
  - xz=5.2.6=h8d14728_0
  - yaml=0.2.5=h8ffe710_2
  - zeromq=4.3.4=h0e60522_1
  - zipp=3.15.0=pyhd8ed1ab_0
  - zstd=1.5.2=h12be248_6
  - pip:
    - filelock==3.10.0
    - mpmath==1.3.0
    - networkx==3.0
    - sympy==1.11.1
    - torch==2.0.0

相关问题